diff --git a/.gitignore b/.gitignore index c45b30ef..257f8977 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ temp_dirs/undodir/* -sources_non_forked/* +sources_non_forked_cache/* temp_dirs/yankring_history_v2.txt sources_forked/yankring/doc/tags my_plugins/ diff --git a/sources_non_forked/ack.vim/.gitignore b/sources_non_forked/ack.vim/.gitignore new file mode 100644 index 00000000..6e92f57d --- /dev/null +++ b/sources_non_forked/ack.vim/.gitignore @@ -0,0 +1 @@ +tags diff --git a/sources_non_forked/ack.vim/LICENSE b/sources_non_forked/ack.vim/LICENSE new file mode 100644 index 00000000..056ea36c --- /dev/null +++ b/sources_non_forked/ack.vim/LICENSE @@ -0,0 +1,89 @@ +ack.vim is distributed under the same license terms as Vim itself, which you +can find in full with `:help license` within Vim, or copied in full herein. + +Copyright (c) 2007-2015 Antoine Imbert + and contributors. + +Maintainers may be contacted via GitHub Issues at: + + https://github.com/mileszs/ack.vim/issues + + +VIM LICENSE + +I) There are no restrictions on distributing unmodified copies of Vim except + that they must include this license text. You can also distribute + unmodified parts of Vim, likewise unrestricted except that they must + include this license text. You are also allowed to include executables + that you made from the unmodified Vim sources, plus your own usage + examples and Vim scripts. + +II) It is allowed to distribute a modified (or extended) version of Vim, + including executables and/or source code, when the following four + conditions are met: + 1) This license text must be included unmodified. + 2) The modified Vim must be distributed in one of the following five ways: + a) If you make changes to Vim yourself, you must clearly describe in + the distribution how to contact you. When the maintainer asks you + (in any way) for a copy of the modified Vim you distributed, you + must make your changes, including source code, available to the + maintainer without fee. The maintainer reserves the right to + include your changes in the official version of Vim. What the + maintainer will do with your changes and under what license they + will be distributed is negotiable. If there has been no negotiation + then this license, or a later version, also applies to your changes. + The current maintainer is Bram Moolenaar . If this + changes it will be announced in appropriate places (most likely + vim.sf.net, www.vim.org and/or comp.editors). When it is completely + impossible to contact the maintainer, the obligation to send him + your changes ceases. Once the maintainer has confirmed that he has + received your changes they will not have to be sent again. + b) If you have received a modified Vim that was distributed as + mentioned under a) you are allowed to further distribute it + unmodified, as mentioned at I). If you make additional changes the + text under a) applies to those changes. + c) Provide all the changes, including source code, with every copy of + the modified Vim you distribute. This may be done in the form of a + context diff. You can choose what license to use for new code you + add. The changes and their license must not restrict others from + making their own changes to the official version of Vim. + d) When you have a modified Vim which includes changes as mentioned + under c), you can distribute it without the source code for the + changes if the following three conditions are met: + - The license that applies to the changes permits you to distribute + the changes to the Vim maintainer without fee or restriction, and + permits the Vim maintainer to include the changes in the official + version of Vim without fee or restriction. + - You keep the changes for at least three years after last + distributing the corresponding modified Vim. When the maintainer + or someone who you distributed the modified Vim to asks you (in + any way) for the changes within this period, you must make them + available to him. + - You clearly describe in the distribution how to contact you. This + contact information must remain valid for at least three years + after last distributing the corresponding modified Vim, or as long + as possible. + e) When the GNU General Public License (GPL) applies to the changes, + you can distribute the modified Vim under the GNU GPL version 2 or + any later version. + 3) A message must be added, at least in the output of the ":version" + command and in the intro screen, such that the user of the modified Vim + is able to see that it was modified. When distributing as mentioned + under 2)e) adding the message is only required for as far as this does + not conflict with the license used for the changes. + 4) The contact information as required under 2)a) and 2)d) must not be + removed or changed, except that the person himself can make + corrections. + +III) If you distribute a modified version of Vim, you are encouraged to use + the Vim license for your changes and make them available to the + maintainer, including the source code. The preferred way to do this is + by e-mail or by uploading the files to a server and e-mailing the URL. + If the number of changes is small (e.g., a modified Makefile) e-mailing a + context diff will do. The e-mail address to be used is + + +IV) It is not allowed to remove this license from the distribution of the Vim + sources, parts of it or from a modified version. You may use this + license for previous Vim releases instead of the license that they came + with, at your option. diff --git a/sources_non_forked/ack.vim/README.md b/sources_non_forked/ack.vim/README.md new file mode 100644 index 00000000..378fc3e3 --- /dev/null +++ b/sources_non_forked/ack.vim/README.md @@ -0,0 +1,163 @@ +# ack.vim + +Run your favorite search tool from Vim, with an enhanced results list. + +This plugin was designed as a Vim frontend for the programmer's search tool +[ack]. ack can be used as a replacement for 99% of the uses of `grep`. The +plugin allows you to search with ack from within Vim and shows the results in a +split window. + +But here's a little secret for the Vim-seasoned: it's just a light wrapper for +Vim's [grepprg] and the [quickfix] window for match results. This makes it easy +to integrate with your own Vim configuration and use existing knowledge of core +features. It also means the plugin is flexible to use with other search tools. + +[grepprg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg' +[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix + +## Installation + +### ack + +You will need ack (>= 2.0), of course. To install it follow the +[manual](http://beyondgrep.com/install/). + +### The Plugin + +It is recommended to use one of the popular plugin managers for Vim. There are +many and you probably already have a preferred one, but a few examples for your +copy-and-paste convenience: + +#### Pathogen + + $ git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack.vim + +#### Vundle + +```vim +Plugin 'mileszs/ack.vim' +``` + +#### NeoBundle + +```vim +NeoBundle 'mileszs/ack.vim' +``` + +#### Manual (not recommended) + +[Download][releases] the plugin and extract it in `~/.vim/` (or +`%PROGRAMFILES%/Vim/vimfiles` on Windows). + +## Usage + + :Ack [options] {pattern} [{directories}] + +Search recursively in `{directories}` (which defaults to the current directory) +for the `{pattern}`. + +Files containing the search term will be listed in the quickfix window, along +with the line number of the occurrence, once for each occurrence. `` on +a line in this window will open the file and place the cursor on the matching +line. + +Just like where you use `:grep`, `:grepadd`, `:lgrep`, and :`lgrepadd`, you can +use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `:help Ack` +after installing, or [`doc/ack.txt`][doc] in the repo, for more information.) + +For more ack help see [ack documentation](http://beyondgrep.com/documentation/). + +[doc]: https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt + +### Keyboard Shortcuts + +The quickfix results window is augmented with these convenience mappings: + + ? a quick summary of these keys, repeat to close + o to open (same as Enter) + O to open and close the quickfix window + go to preview file, open but maintain focus on ack.vim results + t to open in new tab + T to open in new tab without moving to it + h to open in horizontal split + H to open in horizontal split, keeping focus on the results + v to open in vertical split + gv to open in vertical split, keeping focus on the results + q to close the quickfix window + +### Gotchas + +To search for a pattern that contains whitespace, you need to enclose the +pattern in single quotes. For example: `:Ack 'foo bar'` to search for +'foo bar'. + +Some characters have special meaning, and need to be escaped in your search +pattern. For instance, `#`. You need to escape it with `:Ack '\\\#define +foo'` to search for '#define foo'. See [issue #5]. + +[issue #5]: https://github.com/mileszs/ack.vim/issues/5 + +## Possibly FAQ + +#### Can I use `ag` ([The Silver Searcher]) with this? + +Absolutely, and probably other tools if their output is similar or you can +write a pattern match for it--just set `g:ackprg`. If you like, you can fall +back to Ack in case you use your vimrc on a system without Ag available: + +```vim +if executable('ag') + let g:ackprg = 'ag --vimgrep' +endif +``` + +Since Ack is quite portable you might check a copy of it into your dotfiles +repository in `~/bin` so you'll nearly always have it available. + +#### What's the difference from ag.vim? + +Well... not a lot really. + +Present maintainer, yours truly, [kind of wishes they never forked][sadface], +contributes to both, and wouldn't mind seeing them merged again. ag.vim got a +nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked +up a few features that haven't made their way to ag.vim, like `:AckWindow`, +optional background search execution with [vim-dispatch], and auto-previewing. + +#### I don't want to jump to the first result automatically. #### + +Use `:Ack!`, with bang. If you want this behavior most of the time, you might +like an abbreviation or mapping in your personal config, something like these: + +```vim +cnoreabbrev Ack Ack! +nnoremap a :Ack! +``` + +Most of the `:[L]Ack*` commands support this. Note that this behavior follows +the convention of Vim's built-in `:grep` and `:make` commands. + +[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher +[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145 + +## Changelog + +Please see [the GitHub releases page][releases]. + +## Credits + +This plugin is derived from Antoine Imbert's blog post [ack and Vim +Integration][] (in particular, the function in the update to the post). [Miles +Sterrett][mileszs] packaged it up as a plugin and documented it in Vim's help +format, and since then [many contributors][contributors] have submitted +enhancements and fixes. + +And of course, where would we be without [ack]. And, you know, Vim. + +[ack and Vim Integration]: http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html +[mileszs]: https://github.com/mileszs +[contributors]: https://github.com/mileszs/ack.vim/graphs/contributors +[ack]: http://beyondgrep.com/ + +[vim-dispatch]: https://github.com/tpope/vim-dispatch +[releases]: https://github.com/mileszs/ack.vim/releases diff --git a/sources_non_forked/ack.vim/autoload/ack.vim b/sources_non_forked/ack.vim/autoload/ack.vim new file mode 100644 index 00000000..b6afdba4 --- /dev/null +++ b/sources_non_forked/ack.vim/autoload/ack.vim @@ -0,0 +1,246 @@ +if exists('g:autoloaded_ack') || &cp + finish +endif + +if exists('g:ack_use_dispatch') + if g:ack_use_dispatch && !exists(':Dispatch') + call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.') + let g:ack_use_dispatch = 0 + endif +else + let g:ack_use_dispatch = 0 +endif + +"----------------------------------------------------------------------------- +" Public API +"----------------------------------------------------------------------------- + +function! ack#Ack(cmd, args) "{{{ + call s:Init(a:cmd) + redraw + + " Local values that we'll temporarily set as options when searching + let l:grepprg = g:ackprg + let l:grepformat = '%f:%l:%c:%m,%f:%l:%m' " Include column number + + " Strip some options that are meaningless for path search and set match + " format accordingly. + if s:SearchingFilepaths() + let l:grepprg = substitute(l:grepprg, '-H\|--column', '', 'g') + let l:grepformat = '%f' + endif + + " Check user policy for blank searches + if empty(a:args) + if !g:ack_use_cword_for_empty_search + echo "No regular expression found." + return + endif + endif + + " If no pattern is provided, search for the word under the cursor + let l:grepargs = empty(a:args) ? expand("") : a:args . join(a:000, ' ') + + "Bypass search if cursor is on blank string + if l:grepargs == "" + echo "No regular expression found." + return + endif + + " NOTE: we escape special chars, but not everything using shellescape to + " allow for passing arguments etc + let l:escaped_args = escape(l:grepargs, '|#%') + + echo "Searching ..." + + if g:ack_use_dispatch + call s:SearchWithDispatch(l:grepprg, l:escaped_args, l:grepformat) + else + call s:SearchWithGrep(a:cmd, l:grepprg, l:escaped_args, l:grepformat) + endif + + " Dispatch has no callback mechanism currently, we just have to display the + " list window early and wait for it to populate :-/ + call ack#ShowResults() + call s:Highlight(l:grepargs) +endfunction "}}} + +function! ack#AckFromSearch(cmd, args) "{{{ + let search = getreg('/') + " translate vim regular expression to perl regular expression. + let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g') + call ack#Ack(a:cmd, '"' . search . '" ' . a:args) +endfunction "}}} + +function! ack#AckHelp(cmd, args) "{{{ + let args = a:args . ' ' . s:GetDocLocations() + call ack#Ack(a:cmd, args) +endfunction "}}} + +function! ack#AckWindow(cmd, args) "{{{ + let files = tabpagebuflist() + + " remove duplicated filenames (files appearing in more than one window) + let files = filter(copy(sort(files)), 'index(files,v:val,v:key+1)==-1') + call map(files, "bufname(v:val)") + + " remove unnamed buffers as quickfix (empty strings before shellescape) + call filter(files, 'v:val != ""') + + " expand to full path (avoid problems with cd/lcd in au QuickFixCmdPre) + let files = map(files, "shellescape(fnamemodify(v:val, ':p'))") + let args = a:args . ' ' . join(files) + + call ack#Ack(a:cmd, args) +endfunction "}}} + +function! ack#ShowResults() "{{{ + let l:handler = s:UsingLocList() ? g:ack_lhandler : g:ack_qhandler + execute l:handler + call s:ApplyMappings() + redraw! +endfunction "}}} + +"----------------------------------------------------------------------------- +" Private API +"----------------------------------------------------------------------------- + +function! s:ApplyMappings() "{{{ + if !s:UsingListMappings() || &filetype != 'qf' + return + endif + + let l:wintype = s:UsingLocList() ? 'l' : 'c' + let l:closemap = ':' . l:wintype . 'close' + let g:ack_mappings.q = l:closemap + + nnoremap ? :call QuickHelp() + + if g:ack_autoclose + " We just map the 'go' and 'gv' mappings to close on autoclose, wtf? + for key_map in items(g:ack_mappings) + execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1) . l:closemap) + endfor + + execute "nnoremap " . l:closemap + else + for key_map in items(g:ack_mappings) + execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1)) + endfor + endif + + if exists("g:ackpreview") " if auto preview in on, remap j and k keys + nnoremap j j + nnoremap k k + nmap j + nmap k + endif +endfunction "}}} + +function! s:GetDocLocations() "{{{ + let dp = '' + for p in split(&rtp, ',') + let p = p . '/doc/' + if isdirectory(p) + let dp = p . '*.txt ' . dp + endif + endfor + + return dp +endfunction "}}} + +function! s:Highlight(args) "{{{ + if !g:ackhighlight + return + endif + + let @/ = matchstr(a:args, "\\v(-)\@", "n") +endfunction "}}} + +" Initialize state for an :Ack* or :LAck* search +function! s:Init(cmd) "{{{ + let s:searching_filepaths = (a:cmd =~# '-g$') ? 1 : 0 + let s:using_loclist = (a:cmd =~# '^l') ? 1 : 0 + + if g:ack_use_dispatch && s:using_loclist + call s:Warn('Dispatch does not support location lists! Proceeding with quickfix...') + let s:using_loclist = 0 + endif +endfunction "}}} + +function! s:QuickHelp() "{{{ + execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt') + + silent normal gg + setlocal buftype=nofile bufhidden=hide nobuflisted + setlocal nomodifiable noswapfile + setlocal filetype=help + setlocal nonumber norelativenumber nowrap + setlocal foldmethod=diff foldlevel=20 + + nnoremap ? :q!:call ack#ShowResults() +endfunction "}}} + +function! s:SearchWithDispatch(grepprg, grepargs, grepformat) "{{{ + let l:makeprg_bak = &l:makeprg + let l:errorformat_bak = &l:errorformat + + " We don't execute a :grep command for Dispatch, so add -g here instead + if s:SearchingFilepaths() + let l:grepprg = a:grepprg . ' -g' + else + let l:grepprg = a:grepprg + endif + + try + let &l:makeprg = l:grepprg . ' ' . a:grepargs + let &l:errorformat = a:grepformat + + Make + finally + let &l:makeprg = l:makeprg_bak + let &l:errorformat = l:errorformat_bak + endtry +endfunction "}}} + +function! s:SearchWithGrep(grepcmd, grepprg, grepargs, grepformat) "{{{ + let l:grepprg_bak = &l:grepprg + let l:grepformat_bak = &grepformat + + try + let &l:grepprg = a:grepprg + let &grepformat = a:grepformat + + silent execute a:grepcmd a:grepargs + finally + let &l:grepprg = l:grepprg_bak + let &grepformat = l:grepformat_bak + endtry +endfunction "}}} + +" Are we finding matching files, not lines? (the -g option -- :AckFile) +function! s:SearchingFilepaths() "{{{ + return get(s:, 'searching_filepaths', 0) +endfunction "}}} + +" Predicate for whether mappings are enabled for list type of current search. +function! s:UsingListMappings() "{{{ + if s:UsingLocList() + return g:ack_apply_lmappings + else + return g:ack_apply_qmappings + endif +endfunction "}}} + +" Were we invoked with a :LAck command? +function! s:UsingLocList() "{{{ + return get(s:, 'using_loclist', 0) +endfunction "}}} + +function! s:Warn(msg) "{{{ + echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None +endf "}}} + +let g:autoloaded_ack = 1 +" vim:set et sw=2 ts=2 tw=78 fdm=marker diff --git a/sources_non_forked/ack.vim/doc/ack.txt b/sources_non_forked/ack.vim/doc/ack.txt new file mode 100644 index 00000000..22e884bc --- /dev/null +++ b/sources_non_forked/ack.vim/doc/ack.txt @@ -0,0 +1,315 @@ +*ack.txt* Plugin that integrates ack with Vim + +============================================================================== +Author: Antoine Imbert *ack-author* +License: Same terms as Vim itself (see |license|) + +This plugin is only available if 'compatible' is not set. + +{Vi does not have any of this} + +============================================================================== +INTRODUCTION *ack* + +This plugin is a front for the Perl module App::Ack. Ack can be used as a +replacement for grep. This plugin will allow you to run ack from vim, and +shows the results in a split window. + +:Ack[!] [options] {pattern} [{directory}] *:Ack* + + Search recursively in {directory} (which defaults to the current + directory) for the {pattern}. Behaves just like the |:grep| command, but + will open the |Quickfix| window for you. If [!] is not given the first + occurrence is jumped to. + +:AckAdd [options] {pattern} [{directory}] *:AckAdd* + + Just like |:Ack|, but instead of making a new list, the matches are + appended to the current |quickfix| list. + +:AckFromSearch [{directory}] *:AckFromSearch* + + Just like |:Ack| but the pattern is from previous search. + +:LAck [options] {pattern} [{directory}] *:LAck* + + Just like |:Ack| but instead of the |quickfix| list, matches are placed in + the current |location-list|. + +:LAckAdd [options] {pattern} [{directory}] *:LAckAdd* + + Just like |:AckAdd| but instead of the |quickfix| list, matches are added + to the current |location-list| + +:AckFile [options] {pattern} [{directory}] *:AckFile* + + Search recursively in {directory} (which defaults to the current + directory) for filenames matching the {pattern}. Behaves just like the + |:grep| command, but will open the |Quickfix| window for you. + +:AckHelp[!] [options] {pattern} *:AckHelp* + + Search vim documentation files for the {pattern}. Behaves just like the + |:Ack| command, but searches only vim documentation .txt files + +:LAckHelp [options] {pattern} *:LAckHelp* + + Just like |:AckHelp| but instead of the |quickfix| list, matches are placed + in the current |location-list|. + +:AckWindow[!] [options] {pattern} *:AckWindow* + + Search all buffers visible in the screen (current tab page only) files for + the {pattern}. + +:LAckWindow [options] {pattern} *:LAckWindow* + + Just like |:AckWindow| but instead of the |quickfix| list, matches are + placed in the current |location-list|. + +Files containing the search term will be listed in the split window, along +with the line number of the occurrence, once for each occurrence. on +a line in this window will open the file, and place the cursor on the matching +line. + +Note that if you are using Dispatch.vim with |g:ack_use_dispatch|, location +lists are not supported, because Dispatch does not support them at this time. +`:LAck` versions of commands above will give a warning and proceed to use the +quickfix list instead. + +See http://beyondgrep.com/ for more information on searching with ack. + + +============================================================================== +CONFIGURATION *ack-configuration* + + *g:ackprg* +g:ackprg +Default for ubuntu: "ack-grep" +Default for other systems: "ack" + +Use this option to specify the search command and its default arguments. + +Example: +> + let g:ackprg = "ag --vimgrep" +< + *g:ack_default_options* +g:ack_default_options +Default: " -s -H --nocolor --nogroup --column" + +Use this option to specify the default arguments given to `ack`. This is only +used if |g:ackprg| has not been customized from the default--if you are using +a custom search program instead of Ack, set your preferred options in +|g:ackprg|. + +NOTE: This option may be deprecated in the future. ~ + +Example: +> + let g:ack_default_options = + \ " -s -H --nocolor --nogroup --column --smart-case --follow" +< + *g:ack_apply_qmappings* +g:ack_apply_qmappings +Default: 1 + +This option enables mappings on the |quickfix| window. + + *g:ack_apply_lmappings* +g:ack_apply_lmappings +Default: 1 + +This option enables mappings on |location-list| windows. + + *g:ack_mappings* +g:ack_mappings +Default: { + \ "t": "T", + \ "T": "TgTj", + \ "o": "", + \ "O": ":ccl", + \ "go": "j", + \ "h": "K", + \ "H": "Kb", + \ "v": "HbJt", + \ "gv": "HbJ" } + +This option list all maps create on quickfix/Location list window. + +Example, if you want to open the result in the middle of the screen: +> + let g:ack_mappings = { "o": "zz" } +< + *g:ack_qhandler* +g:ack_qhandler +Default: "botright copen" + +Command to open the quickview window. + +If you want to open a quickview window with 30 lines you can do: +> + let g:ack_qhandler = "botright copen 30" +< + *g:ack_lhandler* +g:ack_lhandler +Default: "botright lopen" + +Command to open the Location list window. + +If you want to open a Location list window with 30 lines you can do: +> + let g:ack_lhandler = "botright lopen 30" +< + *g:ackhighlight* +g:ackhighlight +Default: 0 + +Use this option to highlight the searched term. + +Example: +> + let g:ackhighlight = 1 +< + *g:ack_autoclose* +g:ack_autoclose +Default: 0 + +Use this option to specify whether to close the quickfix window after +using any of the shortcuts. + +Example: +> + let g:ack_autoclose = 1 +< + *g:ack_autofold_results* +g:ack_autofold_results +Default: 0 + +Use this option to fold the results in quickfix by file name. Only the current +fold will be open by default and while you press 'j' and 'k' to move between the +results if you hit other fold the last one will be closed and the current will +be open. + +Example: +> + let g:ack_autofold_results = 1 +< + *g:ackpreview* +g:ackpreview +Default: 0 + +Use this option to automagically open the file with 'j' or 'k'. + +Example: +> + let g:ackpreview = 1 +< + *g:ack_use_dispatch* +g:ack_use_dispatch +Default: 0 + +Use this option to use vim-dispatch to run searches in the background, with a +variety of execution backends for different systems. + +Due to limitations in Dispatch at this time, location lists are unsupported +and result windows will appear before results are ready. Still, these may be +acceptable tradeoffs for very large projects where searches are slow. + +Example: +> + let g:ack_use_dispatch = 1 +< + *g:ack_use_cword_for_empty_search* +g:ack_use_cword_for_empty_search +Default: 1 + +Use this option to enable blank searches to run against the word under the +cursor. When this option is not set, blank searches will only output an error +message. + +Example: +> + let g:ack_use_cword_for_empty_search = 0 +< +============================================================================== +MAPPINGS *ack-mappings* + +The following keyboard shortcuts are available in the |quickfix| and +|location-list| windows: + +? display a quick summary of these mappings. + +o open file (same as Enter). + +O open file and close the quickfix window. + +go preview file (open but maintain focus on ack.vim results). + +t open in a new tab. + +T open in new tab without moving to it. + +h open in horizontal split. + +H open in horizontal split, keeping focus on the results. + +v open in vertical split. + +gv open in vertical split, keeping focus on the results. + +q close the quickfix window. + +To adjust these, see |g:ack_mappings|. + +============================================================================== +Ignoring files *ack-ignore* + +If you're using this plugin with ag, The Silver Searcher, bear in mind that: + + - It ignores file patterns from your .gitignore and .hgignore. + + - If there are other files in your source repository you don't wish to + search, you can add their patterns to an .agignore file. + +============================================================================== +ISSUES AND FAQ *ack-issues-and-faq* + +I don't want to jump to the first result automatically.~ + + Use `:Ack!`, with bang. If you want this behavior most of the time, you + might like an abbreviation or mapping in your personal config, something + like these: +> + cnoreabbrev Ack Ack! + nnoremap a :Ack! +< + Most of the `:[L]Ack*` commands support this. Note that this behavior + follows the convention of Vim's built-in |:grep| and |:make| commands. + +I use NERDTree and opening ack.vim results in a vertical split displacing it.~ + + You are probably using NERDTree with its default alignment at the left + side of the window. Set these custom mappings in your vimrc to work around + this: +> + let g:ack_mappings = { + \ 'v': 'LpJp', + \ 'gv': 'LpJ' } +< + This solution will be improved in the future. + +Results show a mix of relative and absolute paths, making them hard to read.~ + + This is a quirk of Vim that can happen with plain |:vimgrep| too. You can + try this in your vimrc to work around it: +> + autocmd BufAdd * exe "cd" fnameescape(getcwd()) +< + but for some users this may be disruptive to their Vim workflow. For more + details, see: + + http://vi.stackexchange.com/a/4816/7174 + https://github.com/mileszs/ack.vim/issues/143 + +vim:set et sw=4 ts=4 tw=78: diff --git a/sources_non_forked/ack.vim/doc/ack_quick_help.txt b/sources_non_forked/ack.vim/doc/ack_quick_help.txt new file mode 100644 index 00000000..94306a0e --- /dev/null +++ b/sources_non_forked/ack.vim/doc/ack_quick_help.txt @@ -0,0 +1,15 @@ +==== ack.vim quick help =============== + + *?:* a quick summary of these keys, repeat to close + *o:* to open (same as Enter) + *O:* to open and close the quickfix window + *go:* to preview file, open but maintain focus on ack.vim results + *t:* to open in new tab + *T:* to open in new tab without moving to it + *h:* to open in horizontal split + *H:* to open in horizontal split, keeping focus on the results + *v:* to open in vertical split + *gv:* to open in vertical split, keeping focus on the results + *q:* to close the quickfix window + +======================================== diff --git a/sources_non_forked/ack.vim/ftplugin/qf.vim b/sources_non_forked/ack.vim/ftplugin/qf.vim new file mode 100644 index 00000000..27564fa7 --- /dev/null +++ b/sources_non_forked/ack.vim/ftplugin/qf.vim @@ -0,0 +1,9 @@ +if exists("g:ack_autofold_results") && g:ack_autofold_results + setlocal foldlevel=0 + setlocal foldmethod=expr + setlocal foldexpr=matchstr(getline(v:lnum),'^[^\|]\\+')==#matchstr(getline(v:lnum+1),'^[^\|]\\+')?1:'<1' + setlocal foldenable + setlocal foldclose=all + setlocal foldopen=all + nnoremap j jzz +endif diff --git a/sources_non_forked/ack.vim/plugin/ack.vim b/sources_non_forked/ack.vim/plugin/ack.vim new file mode 100644 index 00000000..202ae2ea --- /dev/null +++ b/sources_non_forked/ack.vim/plugin/ack.vim @@ -0,0 +1,83 @@ +if exists('g:loaded_ack') || &cp + finish +endif + +if !exists("g:ack_default_options") + let g:ack_default_options = " -s -H --nopager --nocolor --nogroup --column" +endif + +" Location of the ack utility +if !exists("g:ackprg") + if executable('ack-grep') + let g:ackprg = "ack-grep" + elseif executable('ack') + let g:ackprg = "ack" + else + finish + endif + let g:ackprg .= g:ack_default_options +endif + +if !exists("g:ack_apply_qmappings") + let g:ack_apply_qmappings = !exists("g:ack_qhandler") +endif + +if !exists("g:ack_apply_lmappings") + let g:ack_apply_lmappings = !exists("g:ack_lhandler") +endif + +let s:ack_mappings = { + \ "t": "T", + \ "T": "TgTj", + \ "o": "", + \ "O": "pc", + \ "go": "p", + \ "h": "K", + \ "H": "Kb", + \ "v": "HbJt", + \ "gv": "HbJ" } + +if exists("g:ack_mappings") + let g:ack_mappings = extend(s:ack_mappings, g:ack_mappings) +else + let g:ack_mappings = s:ack_mappings +endif + +if !exists("g:ack_qhandler") + let g:ack_qhandler = "botright copen" +endif + +if !exists("g:ack_lhandler") + let g:ack_lhandler = "botright lopen" +endif + +if !exists("g:ackhighlight") + let g:ackhighlight = 0 +endif + +if !exists("g:ack_autoclose") + let g:ack_autoclose = 0 +endif + +if !exists("g:ack_autofold_results") + let g:ack_autofold_results = 0 +endif + +if !exists("g:ack_use_cword_for_empty_search") + let g:ack_use_cword_for_empty_search = 1 +endif + +command! -bang -nargs=* -complete=file Ack call ack#Ack('grep', ) +command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd', ) +command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep', ) +command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep', ) +command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd', ) +command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep -g', ) +command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep', ) +command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep', ) +command! -bang -nargs=* AckWindow call ack#AckWindow('grep', ) +command! -bang -nargs=* LAckWindow call ack#AckWindow('lgrep', ) + +let g:loaded_ack = 1 + +" vim:set et sw=2 ts=2 tw=78 fdm=marker diff --git a/sources_non_forked/ale/LICENSE b/sources_non_forked/ale/LICENSE new file mode 100644 index 00000000..471776e4 --- /dev/null +++ b/sources_non_forked/ale/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2016-2020, w0rp +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sources_non_forked/ale/ale_linters/ada/adals.vim b/sources_non_forked/ale/ale_linters/ada/adals.vim new file mode 100644 index 00000000..9a41e1df --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/adals.vim @@ -0,0 +1,26 @@ +" Author: Bartek Jasicki http://github.com/thindil +" Description: Support for Ada Language Server + +call ale#Set('ada_adals_executable', 'ada_language_server') +call ale#Set('ada_adals_project', 'default.gpr') +call ale#Set('ada_adals_encoding', 'utf-8') + +function! ale_linters#ada#adals#GetAdaLSConfig(buffer) abort + return { + \ 'ada.projectFile': ale#Var(a:buffer, 'ada_adals_project'), + \ 'ada.defaultCharset': ale#Var(a:buffer, 'ada_adals_encoding') + \} +endfunction + +function! ale_linters#ada#adals#GetRootDirectory(buffer) abort + return fnamemodify(bufname(a:buffer), ':p:h') +endfunction + +call ale#linter#Define('ada', { +\ 'name': 'adals', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'ada_adals_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#ada#adals#GetRootDirectory'), +\ 'lsp_config': function('ale_linters#ada#adals#GetAdaLSConfig') +\}) diff --git a/sources_non_forked/ale/ale_linters/ada/cspell.vim b/sources_non_forked/ale/ale_linters/ada/cspell.vim new file mode 100644 index 00000000..7342d2b6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Ada files. + +call ale#handlers#cspell#DefineLinter('ada') diff --git a/sources_non_forked/ale/ale_linters/ada/gcc.vim b/sources_non_forked/ale/ale_linters/ada/gcc.vim new file mode 100644 index 00000000..5afc9ae3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ada/gcc.vim @@ -0,0 +1,54 @@ +" Author: Martino Pilia +" Description: Lint Ada files with GCC + +call ale#Set('ada_gcc_executable', 'gcc') + +" -gnatwa: activate most optional warnings +" -gnatq: try semantic analysis even if syntax errors have been found +call ale#Set('ada_gcc_options', '-gnatwa -gnatq') + +function! ale_linters#ada#gcc#GetCommand(buffer) abort + " Build a suitable output file name. The output file is specified because + " the .ali file may be created even if no code generation is attempted. + " The output file name must match the source file name (except for the + " extension), so here we cannot use the null file as output. + let l:tmp_dir = fnamemodify(ale#command#CreateDirectory(a:buffer), ':p') + let l:out_file = l:tmp_dir . fnamemodify(bufname(a:buffer), ':t:r') . '.o' + + " -gnatc: Check syntax and semantics only (no code generation attempted) + return '%e -x ada -c -gnatc' + \ . ' -o ' . ale#Escape(l:out_file) + \ . ' -I %s:h' + \ . ale#Pad(ale#Var(a:buffer, 'ada_gcc_options')) + \ . ' %t' +endfunction + +" For the message format please refer to: +" https://gcc.gnu.org/onlinedocs/gnat_ugn/Output-and-Error-Message-Control.html +" https://gcc.gnu.org/onlinedocs/gnat_ugn/Warning-Message-Control.html +function! ale_linters#ada#gcc#Handle(buffer, lines) abort + " Error format: ::: + " Warning format: ::: warning: + let l:re = '\v(.+):([0-9]+):([0-9]+):\s+(warning:)?\s*(.+)\s*' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:re) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'type': l:match[4] is# 'warning:' ? 'W' : 'E', + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ada', { +\ 'name': 'gcc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'ada_gcc_executable')}, +\ 'command': function('ale_linters#ada#gcc#GetCommand'), +\ 'callback': 'ale_linters#ada#gcc#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim new file mode 100644 index 00000000..d5d98bc4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ansible/ansible_lint.vim @@ -0,0 +1,128 @@ +" Authors: Bjorn Neergaard , Vytautas Macionis +" Description: ansible-lint for ansible-yaml files + +call ale#Set('ansible_ansible_lint_executable', 'ansible-lint') + +function! ale_linters#ansible#ansible_lint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'ansible_ansible_lint_executable') +endfunction + +function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort + for l:line in a:lines[:10] + if match(l:line, '^Traceback') >= 0 + return [{ + \ 'lnum': 1, + \ 'text': 'An exception was thrown. See :ALEDetail', + \ 'detail': join(a:lines, "\n"), + \}] + endif + endfor + + let l:version_group = ale#semver#GTE(a:version, [6, 0, 0]) ? '>=6.0.0' : + \ ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : + \ '<5.0.0' + let l:output = [] + + if '>=6.0.0' is# l:version_group + let l:error_codes = { 'blocker': 'E', 'critical': 'E', 'major': 'W', 'minor': 'W', 'info': 'I' } + let l:linter_issues = json_decode(join(a:lines, '')) + + for l:issue in l:linter_issues + if ale#path#IsBufferPath(a:buffer, l:issue.location.path) + call add(l:output, { + \ 'lnum': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.line : + \ l:issue.location.lines.begin, + \ 'col': exists('l:issue.location.lines.begin.column') ? l:issue.location.lines.begin.column : 0, + \ 'text': l:issue.check_name, + \ 'detail': l:issue.description, + \ 'code': l:issue.severity, + \ 'type': l:error_codes[l:issue.severity], + \}) + endif + endfor + endif + + if '>=5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play + " roles/test/tasks/test.yml:8: [package-latest] [VERY_LOW] Package installs should not use latest + " D:\test\tasks\test.yml:8: [package-latest] [VERY_LOW] package installs should not use latest + let l:pattern = '\v^(%([a-zA-Z]:)?[^:]+):(\d+):%((\d+):)? %(\[([-[:alnum:]]+)\]) %(\[([_[:alnum:]]+)\]) (.*)$' + let l:error_codes = { 'VERY_HIGH': 'E', 'HIGH': 'E', 'MEDIUM': 'W', 'LOW': 'W', 'VERY_LOW': 'W', 'INFO': 'I' } + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[6], + \ 'code': l:match[4], + \ 'type': l:error_codes[l:match[5]], + \}) + endif + endfor + endif + + if '<5.0.0' is# l:version_group + " Matches patterns line the following: + " test.yml:35: [EANSIBLE0002] Trailing whitespace + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[4] + + if l:code is# 'EANSIBLE0002' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'code': l:code, + \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', + \}) + endif + endfor + endif + + return l:output +endfunction + +function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort + let l:commands = { + \ '>=6.0.0': '%e --nocolor -f json -x yaml %s', + \ '>=5.0.0': '%e --nocolor --parseable-severity -x yaml %s', + \ '<5.0.0': '%e --nocolor -p %t' + \} + let l:command = ale#semver#GTE(a:version, [6, 0]) ? l:commands['>=6.0.0'] : + \ ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : + \ l:commands['<5.0.0'] + + return l:command +endfunction + +call ale#linter#Define('ansible', { +\ 'name': 'ansible_lint', +\ 'aliases': ['ansible', 'ansible-lint'], +\ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#ansible#ansible_lint#GetCommand'), +\ )}, +\ 'lint_file': 1, +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#ansible#ansible_lint#GetExecutable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#ansible#ansible_lint#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, +\}) diff --git a/sources_non_forked/ale/ale_linters/apiblueprint/drafter.vim b/sources_non_forked/ale/ale_linters/apiblueprint/drafter.vim new file mode 100644 index 00000000..5d40c53a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apiblueprint/drafter.vim @@ -0,0 +1,38 @@ +" Author: nametake https://nametake.github.io +" Description: apiblueprint parser + +function! ale_linters#apiblueprint#drafter#HandleErrors(buffer, lines) abort + " Matches patterns line the following: + " + " warning: (3) unable to parse response signature, expected 'response [] [()]'; line 4, column 3k - line 4, column 22 + " warning: (10) message-body asset is expected to be a pre-formatted code block, separate it by a newline and indent every of its line by 12 spaces or 3 tabs; line 30, column 5 - line 30, column 9; line 31, column 9 - line 31, column 14; line 32, column 9 - line 32, column 14 + let l:pattern = '\(^.*\): (\d\+) \(.\{-\}\); line \(\d\+\), column \(\d\+\) - line \d\+, column \d\+\(.*; line \d\+, column \d\+ - line \(\d\+\), column \(\d\+\)\)\{-\}$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines[2:], l:pattern) + let l:item = { + \ 'type': l:match[1] is# 'warning' ? 'W' : 'E', + \ 'text': l:match[2], + \ 'lnum': l:match[3] + 0, + \ 'col': l:match[4] + 0, + \} + + if l:match[5] isnot# '' + let l:item.end_lnum = l:match[6] + 0 + let l:item.end_col = l:match[7] + 0 + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + + +call ale#linter#Define('apiblueprint', { +\ 'name': 'drafter', +\ 'output_stream': 'stderr', +\ 'executable': 'drafter', +\ 'command': 'drafter --use-line-num --validate', +\ 'callback': 'ale_linters#apiblueprint#drafter#HandleErrors', +\}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim new file mode 100644 index 00000000..285f5534 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/apkbuild_lint.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: apkbuild-lint from atools linter for APKBUILDs + +call ale#Set('apkbuild_apkbuild_lint_executable', 'apkbuild-lint') + +call ale#linter#Define('apkbuild', { +\ 'name': 'apkbuild_lint', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_apkbuild_lint_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim new file mode 100644 index 00000000..c65267fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/apkbuild/secfixes_check.vim @@ -0,0 +1,12 @@ +" Author: Leo +" Description: secfixes-check from atools linter for APKBUILDs + +call ale#Set('apkbuild_secfixes_check_executable', 'secfixes-check') + +call ale#linter#Define('apkbuild', { +\ 'name': 'secfixes_check', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'apkbuild_secfixes_check_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale#handlers#atools#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/alex.vim b/sources_non_forked/ale/ale_linters/asciidoc/alex.vim new file mode 100644 index 00000000..97976b2c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for asciidoc files + +call ale#handlers#alex#DefineLinter('asciidoc', '--text') diff --git a/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim b/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim new file mode 100644 index 00000000..b228b2e8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for ASCIIDoc files. + +call ale#handlers#cspell#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim new file mode 100644 index 00000000..8e8de7f3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/languagetool.vim @@ -0,0 +1,5 @@ +" Author: Horacio Sanson (hsanson [ät] gmail.com) +" Description: languagetool for asciidoc files, copied from markdown. + + +call ale#handlers#languagetool#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asciidoc/proselint.vim b/sources_non_forked/ale/ale_linters/asciidoc/proselint.vim new file mode 100644 index 00000000..b636c067 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for AsciiDoc files + +call ale#linter#Define('asciidoc', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/redpen.vim b/sources_non_forked/ale/ale_linters/asciidoc/redpen.vim new file mode 100644 index 00000000..819e385f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('asciidoc', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f asciidoc -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/textlint.vim b/sources_non_forked/ale/ale_linters/asciidoc/textlint.vim new file mode 100644 index 00000000..308a3a29 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/textlint.vim @@ -0,0 +1,9 @@ +" Author: TANIGUCHI Masaya +" Description: textlint for AsciiDoc files + +call ale#linter#Define('asciidoc', { +\ 'name': 'textlint', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/vale.vim b/sources_non_forked/ale/ale_linters/asciidoc/vale.vim new file mode 100644 index 00000000..b3cf4547 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/vale.vim @@ -0,0 +1,9 @@ +" Author: Jeff Kreeftmeijer https://github.com/jeffkreeftmeijer +" Description: vale for AsciiDoc files + +call ale#linter#Define('asciidoc', { +\ 'name': 'vale', +\ 'executable': 'vale', +\ 'command': 'vale --output=line %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/asciidoc/writegood.vim b/sources_non_forked/ale/ale_linters/asciidoc/writegood.vim new file mode 100644 index 00000000..a29b7e9c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asciidoc/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for AsciiDoc files + +call ale#handlers#writegood#DefineLinter('asciidoc') diff --git a/sources_non_forked/ale/ale_linters/asm/gcc.vim b/sources_non_forked/ale/ale_linters/asm/gcc.vim new file mode 100644 index 00000000..cda38923 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/asm/gcc.vim @@ -0,0 +1,37 @@ +" Author: Lucas Kolstad +" Description: gcc linter for asm files + +call ale#Set('asm_gcc_executable', 'gcc') +call ale#Set('asm_gcc_options', '-Wall') + +function! ale_linters#asm#gcc#GetCommand(buffer) abort + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -x assembler' + \ . ' -o ' . g:ale#util#nul_file + \ . '-iquote %s:h' + \ . ' ' . ale#Var(a:buffer, 'asm_gcc_options') . ' -' +endfunction + +function! ale_linters#asm#gcc#Handle(buffer, lines) abort + let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('asm', { +\ 'name': 'gcc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'asm_gcc_executable')}, +\ 'command': function('ale_linters#asm#gcc#GetCommand'), +\ 'callback': 'ale_linters#asm#gcc#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/avra/avra.vim b/sources_non_forked/ale/ale_linters/avra/avra.vim new file mode 100644 index 00000000..edf15c09 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/avra/avra.vim @@ -0,0 +1,36 @@ +" Author: Utkarsh Verma +" Description: AVRA linter for avra syntax. + +call ale#Set('avra_avra_executable', 'avra') +call ale#Set('avra_avra_options', '') + +function! ale_linters#avra#avra#GetCommand(buffer) abort + return '%e' + \ . ' %t' + \ . ale#Pad(ale#Var(a:buffer, 'avra_avra_options')) + \ . ' -o ' . g:ale#util#nul_file +endfunction + +function! ale_linters#avra#avra#Handle(buffer, lines) abort + " Note that we treat 'fatal' as errors. + let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] =~? 'Error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('avra', { +\ 'name': 'avra', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'avra_avra_executable')}, +\ 'command': function('ale_linters#avra#avra#GetCommand'), +\ 'callback': 'ale_linters#avra#avra#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/awk/gawk.vim b/sources_non_forked/ale/ale_linters/awk/gawk.vim new file mode 100644 index 00000000..0c3212fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/awk/gawk.vim @@ -0,0 +1,23 @@ +" Author: kmarc +" Description: This file adds support for using GNU awk with scripts. + +call ale#Set('awk_gawk_executable', 'gawk') +call ale#Set('awk_gawk_options', '') + +function! ale_linters#awk#gawk#GetCommand(buffer) abort + " note the --source 'BEGIN ...' is to prevent + " gawk from attempting to execute the body of the script + " it is linting. + return '%e --source ' . ale#Escape('BEGIN { exit } END { exit 1 }') + \ . ' --lint' + \ . ale#Pad(ale#Var(a:buffer, 'awk_gawk_options')) + \ . ' -f %t /dev/null' +endfunction + +call ale#linter#Define('awk', { +\ 'name': 'gawk', +\ 'executable': {b -> ale#Var(b, 'awk_gawk_executable')}, +\ 'command': function('ale_linters#awk#gawk#GetCommand'), +\ 'callback': 'ale#handlers#gawk#HandleGawkFormat', +\ 'output_stream': 'both' +\}) diff --git a/sources_non_forked/ale/ale_linters/bats/shellcheck.vim b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim new file mode 100644 index 00000000..5c2a0ea9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bats/shellcheck.vim @@ -0,0 +1,4 @@ +" Author: Ian2020 +" Description: shellcheck linter for bats scripts. + +call ale#handlers#shellcheck#DefineLinter('bats') diff --git a/sources_non_forked/ale/ale_linters/bib/bibclean.vim b/sources_non_forked/ale/ale_linters/bib/bibclean.vim new file mode 100644 index 00000000..f1610e00 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bib/bibclean.vim @@ -0,0 +1,80 @@ +" Author: Horacio Sanson - https://github.com/hsanson +" Description: Support for bibclean linter for BibTeX files. + +call ale#Set('bib_bibclean_executable', 'bibclean') + +function! ale_linters#bib#bibclean#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'bib_bibclean_executable') + + return ale#Escape(l:executable) . ' -file-position ' +endfunction + +function! ale_linters#bib#bibclean#get_type(str) abort + if a:str is# '??' + return 'E' + else + return 'W' + endif +endfunction + +function! ale_linters#bib#bibclean#match_msg(line) abort + " Legacy message pattern works for bibclean <= v2.11.4. If empty, try + " the new message pattern for bibtex > v2.11.4 + let l:matches_legacy = matchlist(a:line, '^\(.*\) "stdin", line \(\d\+\): \(.*\)$') + + return ! empty(l:matches_legacy) ? l:matches_legacy + \ : matchlist(a:line, '^\(.*\) stdin:\(\d\+\):\(.*\)$') +endfunction + +function! ale_linters#bib#bibclean#match_entry(line) abort + return matchlist(a:line, 'Entry input byte=.* line=\(.*\) column=\(.*\) output .*$') +endfunction + +function! ale_linters#bib#bibclean#match_value(line) abort + return matchlist(a:line, 'Value input byte=.* line=\(.*\) column=\(.*\) output .*$') +endfunction + +function! ale_linters#bib#bibclean#Handle(buffer, lines) abort + let l:output = [] + + let l:type = 'E' + let l:msg = '' + + for l:line in a:lines + if empty(l:msg) + let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) + + if !empty(l:mlist) + let l:msg = l:mlist[3] + let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) + endif + else + if l:type is# 'E' + let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) + else + let l:mlist = ale_linters#bib#bibclean#match_value(l:line) + endif + + if !empty(l:mlist) + call add(l:output, { + \ 'lnum': l:mlist[1], + \ 'col': l:mlist[2], + \ 'text': l:msg, + \ 'type': l:type + \}) + + let l:msg = '' + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('bib', { +\ 'name': 'bibclean', +\ 'executable': {b -> ale#Var(b, 'bib_bibclean_executable')}, +\ 'command': function('ale_linters#bib#bibclean#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#bib#bibclean#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/bicep/bicep.vim b/sources_non_forked/ale/ale_linters/bicep/bicep.vim new file mode 100644 index 00000000..91cc1986 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bicep/bicep.vim @@ -0,0 +1,64 @@ +" Author: Carl Smedstad +" Description: bicep for bicep files + +let g:ale_bicep_bicep_executable = +\ get(g:, 'ale_bicep_bicep_executable', 'bicep') + +let g:ale_bicep_bicep_options = +\ get(g:, 'ale_bicep_bicep_options', '') + +function! ale_linters#bicep#bicep#Executable(buffer) abort + return ale#Var(a:buffer, 'bicep_bicep_executable') +endfunction + +function! ale_linters#bicep#bicep#Command(buffer) abort + let l:executable = ale_linters#bicep#bicep#Executable(a:buffer) + let l:options = ale#Var(a:buffer, 'bicep_bicep_options') + + if has('win32') + let l:nullfile = 'NUL' + else + let l:nullfile = '/dev/null' + endif + + return ale#Escape(l:executable) + \ . ' build --outfile ' + \ . l:nullfile + \ . ' ' + \ . l:options + \ . ' %s' +endfunction + +function! ale_linters#bicep#bicep#Handle(buffer, lines) abort + let l:pattern = '\v^.*\((\d+),(\d+)\)\s:\s([a-zA-Z]*)\s([-a-zA-Z0-9]*):\s(.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'Error' + let l:type = 'E' + elseif l:match[3] is# 'Warning' + let l:type = 'W' + else + let l:type = 'I' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('bicep', { +\ 'name': 'bicep', +\ 'executable': function('ale_linters#bicep#bicep#Executable'), +\ 'command': function('ale_linters#bicep#bicep#Command'), +\ 'callback': 'ale_linters#bicep#bicep#Handle', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim b/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim new file mode 100644 index 00000000..fb85a9b9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/bitbake/oelint_adv.vim @@ -0,0 +1,47 @@ +" Author: offa +" Description: oelint-adv for BitBake files + +call ale#Set('bitbake_oelint_adv_executable', 'oelint-adv') +call ale#Set('bitbake_oelint_adv_options', '') +call ale#Set('bitbake_oelint_adv_config', '.oelint.cfg') + +function! ale_linters#bitbake#oelint_adv#Command(buffer) abort + let l:config_file = ale#path#FindNearestFile(a:buffer, + \ ale#Var(a:buffer, 'bitbake_oelint_adv_config')) + + return ((!empty(l:config_file)) + \ ? 'OELINT_CONFIG=' . ale#Escape(l:config_file) . ' ' + \ : '') + \ . '%e --quiet ' + \ . ale#Pad(ale#Var(a:buffer, 'bitbake_oelint_adv_options')) . '%s' +endfunction + +function! ale_linters#bitbake#oelint_adv#Handle(buffer, lines) abort + let l:pattern = '\v^(.+):(.+):(.+):(.+):(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[3] is# 'error' + \ ? 'E' : (l:match[3] is# 'warning' ? 'W' : 'I'), + \ 'text': StripAnsiCodes(l:match[5]), + \ 'code': l:match[4] + \ }) + endfor + + return l:output +endfunction + +function! StripAnsiCodes(line) abort + return substitute(a:line, '\e\[[0-9;]\+[mK]', '', 'g') +endfunction + +call ale#linter#Define('bitbake', { +\ 'name': 'oelint_adv', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'bitbake_oelint_adv_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#bitbake#oelint_adv#Command'), +\ 'callback': 'ale_linters#bitbake#oelint_adv#Handle', +\ }) diff --git a/sources_non_forked/ale/ale_linters/c/cc.vim b/sources_non_forked/ale/ale_linters/c/cc.vim new file mode 100644 index 00000000..35125f2f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cc.vim @@ -0,0 +1,67 @@ +" Author: w0rp +" Description: A C compiler linter for C files with gcc/clang, etc. + +call ale#Set('c_cc_executable', '') +call ale#Set('c_cc_options', '-std=c11 -Wall') +call ale#Set('c_cc_use_header_lang_flag', -1) +call ale#Set('c_cc_header_exts', ['h']) + +function! ale_linters#c#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'c_cc_executable') + + " Default to either clang or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang') + let l:executable = 'clang' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#c#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'c_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)[0-9]\{2\}', + \ '', + \ 'g') + endif + + " Select the correct language flag depending on the executable, options + " and file extension + let l:executable = ale_linters#c#cc#GetExecutable(a:buffer) + let l:use_header_lang_flag = ale#Var(a:buffer, 'c_cc_use_header_lang_flag') + let l:header_exts = ale#Var(a:buffer, 'c_cc_header_exts') + let l:lang_flag = ale#c#GetLanguageFlag( + \ a:buffer, + \ l:executable, + \ l:use_header_lang_flag, + \ l:header_exts, + \ 'c') + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x ' . l:lang_flag + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#c#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/c/ccls.vim b/sources_non_forked/ale/ale_linters/c/ccls.vim new file mode 100644 index 00000000..9f105712 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/ccls.vim @@ -0,0 +1,15 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for C + +call ale#Set('c_ccls_executable', 'ccls') +call ale#Set('c_ccls_init_options', {}) +call ale#Set('c_build_dir', '') + +call ale#linter#Define('c', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'c_ccls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'c_ccls_init_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/c/clangd.vim b/sources_non_forked/ale/ale_linters/c/clangd.vim new file mode 100644 index 00000000..c42d4497 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/clangd.vim @@ -0,0 +1,22 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('c_clangd_executable', 'clangd') +call ale#Set('c_clangd_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#c#clangd#GetCommand(buffer) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'c_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('c', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'c_clangd_executable')}, +\ 'command': function('ale_linters#c#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/c/clangtidy.vim b/sources_non_forked/ale/ale_linters/c/clangtidy.vim new file mode 100644 index 00000000..553cc23b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/clangtidy.vim @@ -0,0 +1,52 @@ +" Author: vdeurzen , w0rp , +" gagbo , Andrej Radovic +" Description: clang-tidy linter for c files + +call ale#Set('c_clangtidy_executable', 'clang-tidy') +" Set this option to check the checks clang-tidy will apply. +" The number of checks that can be applied to C files is limited in contrast to +" C++ +" +" Consult the check list in clang-tidy's documentation: +" http://clang.llvm.org/extra/clang-tidy/checks/list.html + +call ale#Set('c_clangtidy_checks', []) +" Set this option to manually set some options for clang-tidy to use as compile +" flags. +" This will disable compile_commands.json detection. +call ale#Set('c_clangtidy_options', '') +" Set this option to manually set options for clang-tidy directly. +call ale#Set('c_clangtidy_extra_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#c#clangtidy#GetCommand(buffer, output) abort + let l:checks = join(ale#Var(a:buffer, 'c_clangtidy_checks'), ',') + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' + + " Get the extra options if we couldn't find a build directory. + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'c_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + endif + + " Get the options to pass directly to clang-tidy + let l:extra_options = ale#Var(a:buffer, 'c_clangtidy_extra_options') + + return '%e' + \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') + \ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '') + \ . ' %s' + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') + \ . (!empty(l:options) ? ' -- ' . l:options : '') +endfunction + +call ale#linter#Define('c', { +\ 'name': 'clangtidy', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'c_clangtidy_executable')}, +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#clangtidy#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cppcheck.vim b/sources_non_forked/ale/ale_linters/c/cppcheck.vim new file mode 100644 index 00000000..28c2861f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cppcheck.vim @@ -0,0 +1,29 @@ +" Author: Bart Libert +" Description: cppcheck linter for c files + +call ale#Set('c_cppcheck_executable', 'cppcheck') +call ale#Set('c_cppcheck_options', '--enable=style') + +function! ale_linters#c#cppcheck#GetCommand(buffer) abort + let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) + let l:buffer_path_include = empty(l:compile_commands_option) + \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) + \ : '' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') + + return '%e -q --language=c' + \ . l:template + \ . ale#Pad(l:compile_commands_option) + \ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options')) + \ . l:buffer_path_include + \ . ' %t' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cppcheck', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), +\ 'command': function('ale_linters#c#cppcheck#GetCommand'), +\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cpplint.vim b/sources_non_forked/ale/ale_linters/c/cpplint.vim new file mode 100644 index 00000000..4b997941 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cpplint.vim @@ -0,0 +1,20 @@ +" Author: Justin Huang +" Description: cpplint for c files + +call ale#Set('c_cpplint_executable', 'cpplint') +call ale#Set('c_cpplint_options', '') + +function! ale_linters#c#cpplint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'c_cpplint_options') + + return '%e' . ale#Pad(l:options) . ' %s' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cpplint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'c_cpplint_executable')}, +\ 'command': function('ale_linters#c#cpplint#GetCommand'), +\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cquery.vim b/sources_non_forked/ale/ale_linters/c/cquery.vim new file mode 100644 index 00000000..ff0f34af --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cquery.vim @@ -0,0 +1,30 @@ +" Author: Ben Falconer , jtalowell +" Description: A language server for C + +call ale#Set('c_cquery_executable', 'cquery') +call ale#Set('c_cquery_cache_directory', expand('~/.cache/cquery')) + +function! ale_linters#c#cquery#GetProjectRoot(buffer) abort + " Try to find cquery configuration files first. + let l:config = ale#path#FindNearestFile(a:buffer, '.cquery') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + " Fall back on default project root detection. + return ale#c#FindProjectRoot(a:buffer) +endfunction + +function! ale_linters#c#cquery#GetInitializationOptions(buffer) abort + return {'cacheDirectory': ale#Var(a:buffer, 'c_cquery_cache_directory')} +endfunction + +call ale#linter#Define('c', { +\ 'name': 'cquery', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'c_cquery_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#c#cquery#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#c#cquery#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/c/cspell.vim b/sources_non_forked/ale/ale_linters/c/cspell.vim new file mode 100644 index 00000000..5f016548 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C files. + +call ale#handlers#cspell#DefineLinter('c') diff --git a/sources_non_forked/ale/ale_linters/c/flawfinder.vim b/sources_non_forked/ale/ale_linters/c/flawfinder.vim new file mode 100644 index 00000000..53c36716 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/c/flawfinder.vim @@ -0,0 +1,25 @@ +" Author: Christian Gibbons +" Description: flawfinder linter for c files + +call ale#Set('c_flawfinder_executable', 'flawfinder') +call ale#Set('c_flawfinder_options', '') +call ale#Set('c_flawfinder_minlevel', 1) +call ale#Set('c_flawfinder_error_severity', 6) + +function! ale_linters#c#flawfinder#GetCommand(buffer) abort + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'c_flawfinder_minlevel') + + return '%e -CDQS' + \ . ale#Pad(ale#Var(a:buffer, 'c_flawfinder_options')) + \ . l:minlevel + \ . ' %t' +endfunction + +call ale#linter#Define('c', { +\ 'name': 'flawfinder', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'c_flawfinder_executable')}, +\ 'command': function('ale_linters#c#flawfinder#GetCommand'), +\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/cairo/starknet.vim b/sources_non_forked/ale/ale_linters/cairo/starknet.vim new file mode 100644 index 00000000..990bda6d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cairo/starknet.vim @@ -0,0 +1,37 @@ +" Author: 0xHyoga <0xHyoga@gmx.com> +" Description: Report starknet-compile errors in cairo code + +call ale#Set('cairo_starknet_executable', 'starknet-compile') +call ale#Set('cairo_starknet_options', '') + +function! ale_linters#cairo#starknet#Handle(buffer, lines) abort + " Error always on the first line + " e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths: + let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': 'E', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#cairo#starknet#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s' +endfunction + +call ale#linter#Define('cairo', { +\ 'name': 'starknet', +\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')}, +\ 'command': function('ale_linters#cairo#starknet#GetCommand'), +\ 'callback': 'ale_linters#cairo#starknet#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/chef/cookstyle.vim b/sources_non_forked/ale/ale_linters/chef/cookstyle.vim new file mode 100644 index 00000000..50bae2aa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/chef/cookstyle.vim @@ -0,0 +1,54 @@ +" Author: Raphael Hoegger - https://github.com/pfuender +" Description: Cookstyle (RuboCop based), a code style analyzer for Ruby files + +call ale#Set('chef_cookstyle_executable', 'cookstyle') +call ale#Set('chef_cookstyle_options', '') + +function! ale_linters#chef#cookstyle#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'chef_cookstyle_options') + + return '%e' . ale#Pad(escape(l:options, '~')) . ' --force-exclusion --format json --stdin ' . ' %s' +endfunction + +function! ale_linters#chef#cookstyle#Handle(buffer, lines) abort + if len(a:lines) == 0 + return [] + endif + + let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {}) + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['offense_count'] == 0 + \|| empty(l:errors['files']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['files'][0]['offenses'] + let l:start_col = str2nr(l:error['location']['start_column']) + let l:end_col = str2nr(l:error['location']['last_column']) + + if !l:end_col + let l:end_col = l:start_col + 1 + endif + + call add(l:output, { + \ 'lnum': str2nr(l:error['location']['line']), + \ 'col': l:start_col, + \ 'end_col': l:end_col, + \ 'code': l:error['cop_name'], + \ 'text': l:error['message'], + \ 'type': l:error['severity'] is? 'convention' ? 'W' : 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('chef', { +\ 'name': 'cookstyle', +\ 'executable': {b -> ale#Var(b, 'chef_cookstyle_executable')}, +\ 'command': function('ale_linters#chef#cookstyle#GetCommand'), +\ 'callback': 'ale_linters#chef#cookstyle#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/chef/foodcritic.vim b/sources_non_forked/ale/ale_linters/chef/foodcritic.vim new file mode 100644 index 00000000..48beba75 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/chef/foodcritic.vim @@ -0,0 +1,41 @@ +" Author: Edward Larkey +" Author: Jose Junior +" Author: w0rp +" Description: This file adds the foodcritic linter for Chef files. + +call ale#Set('chef_foodcritic_executable', 'foodcritic') +call ale#Set('chef_foodcritic_options', '') + +function! ale_linters#chef#foodcritic#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'chef_foodcritic_options') + + return '%e' . ale#Pad(escape(l:options, '~')) . ' %s' +endfunction + +function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " FC002: Avoid string interpolation where not required: httpd.rb:13 + let l:pattern = '\v([^:]+): (.+): ([a-zA-Z]?:?[^:]+):(\d+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'code': l:match[1], + \ 'text': l:match[2], + \ 'filename': l:match[3], + \ 'lnum': l:match[4] + 0, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('chef', { +\ 'name': 'foodcritic', +\ 'executable': {b -> ale#Var(b, 'chef_foodcritic_executable')}, +\ 'command': function('ale_linters#chef#foodcritic#GetCommand'), +\ 'callback': 'ale_linters#chef#foodcritic#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim new file mode 100644 index 00000000..b470cf0c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/clojure/clj_kondo.vim @@ -0,0 +1,47 @@ +" Author: Masashi Iizuka +" Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo + +call ale#Set('clojure_clj_kondo_options', '--cache') + +function! ale_linters#clojure#clj_kondo#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'clojure_clj_kondo_options') + + let l:command = 'clj-kondo' + \ . ale#Pad(l:options) + \ . ' --lint -' + \ . ' --filename %s' + + return l:command +endfunction + +function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort + " output format + " ::: : + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+)?:(\d+)?:? ((Exception|error|warning): ?(.+))$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = 'E' + + if l:match[4] is? 'warning' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('clojure', { +\ 'name': 'clj-kondo', +\ 'output_stream': 'stdout', +\ 'executable': 'clj-kondo', +\ 'command': function('ale_linters#clojure#clj_kondo#GetCommand'), +\ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/clojure/joker.vim b/sources_non_forked/ale/ale_linters/clojure/joker.vim new file mode 100644 index 00000000..1f17cd31 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/clojure/joker.vim @@ -0,0 +1,34 @@ +" Author: Nic West +" Description: linter for clojure using joker https://github.com/candid82/joker + +function! ale_linters#clojure#joker#HandleJokerFormat(buffer, lines) abort + " output format + " ::: : + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Read error|Parse error|Parse warning|Exception): ?(.+))$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = 'E' + + if l:match[4] is? 'Parse warning' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('clojure', { +\ 'name': 'joker', +\ 'output_stream': 'stderr', +\ 'executable': 'joker', +\ 'command': 'joker --working-dir %s --lint %t', +\ 'callback': 'ale_linters#clojure#joker#HandleJokerFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim new file mode 100644 index 00000000..16841431 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cloudformation/cfn_python_lint.vim @@ -0,0 +1,36 @@ +" Author: Yasuhiro Kiyota +" Description: Support cfn-python-lint for AWS Cloudformation template file + +function! ale_linters#cloudformation#cfn_python_lint#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " sample.template.yaml:96:7:96:15:E3012:Property Resources/Sample/Properties/FromPort should be of type Integer + let l:pattern = '\v^(.*):(\d+):(\d+):(\d+):(\d+):([[:alnum:]]+):(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[6] + + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': l:match[2], + \ 'col': l:match[3], + \ 'end_lnum': l:match[4], + \ 'end_col': l:match[5], + \ 'code': l:code, + \ 'type': l:code[:0] is# 'E' ? 'E' : 'W', + \ 'text': l:match[7] + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('cloudformation', { +\ 'name': 'cloudformation', +\ 'aliases': ['cfn-lint'], +\ 'executable': 'cfn-lint', +\ 'command': 'cfn-lint --template %t --format parseable', +\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim new file mode 100644 index 00000000..3c44c92f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cmake/cmake_lint.vim @@ -0,0 +1,43 @@ +" Author: Carl Smedstad +" Description: cmake-lint for cmake files + +let g:ale_cmake_cmake_lint_executable = +\ get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint') + +let g:ale_cmake_cmake_lint_options = +\ get(g:, 'ale_cmake_cmake_lint_options', '') + +function! ale_linters#cmake#cmake_lint#Executable(buffer) abort + return ale#Var(a:buffer, 'cmake_cmake_lint_executable') +endfunction + +function! ale_linters#cmake#cmake_lint#Command(buffer) abort + let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer) + let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options') + + return ale#Escape(l:executable) . ' ' . l:options . ' %t' +endfunction + +function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort + let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': 'W', + \ 'code': l:match[3], + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('cmake', { +\ 'name': 'cmake_lint', +\ 'executable': function('ale_linters#cmake#cmake_lint#Executable'), +\ 'command': function('ale_linters#cmake#cmake_lint#Command'), +\ 'callback': 'ale_linters#cmake#cmake_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim b/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim new file mode 100644 index 00000000..d955a265 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cmake/cmakelint.vim @@ -0,0 +1,24 @@ +" Author: Kenneth Benzie +" Description: cmakelint for cmake files + +let g:ale_cmake_cmakelint_executable = +\ get(g:, 'ale_cmake_cmakelint_executable', 'cmakelint') + +let g:ale_cmake_cmakelint_options = +\ get(g:, 'ale_cmake_cmakelint_options', '') + +function! ale_linters#cmake#cmakelint#Executable(buffer) abort + return ale#Var(a:buffer, 'cmake_cmakelint_executable') +endfunction + +function! ale_linters#cmake#cmakelint#Command(buffer) abort + return ale_linters#cmake#cmakelint#Executable(a:buffer) + \ . ' ' . ale#Var(a:buffer, 'cmake_cmakelint_options') . ' %t' +endfunction + +call ale#linter#Define('cmake', { +\ 'name': 'cmakelint', +\ 'executable': function('ale_linters#cmake#cmakelint#Executable'), +\ 'command': function('ale_linters#cmake#cmakelint#Command'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/coffee/coffee.vim b/sources_non_forked/ale/ale_linters/coffee/coffee.vim new file mode 100644 index 00000000..8e891639 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/coffee/coffee.vim @@ -0,0 +1,23 @@ +" Author: KabbAmine - https://github.com/KabbAmine +" Description: Coffee for checking coffee files + +function! ale_linters#coffee#coffee#GetExecutable(buffer) abort + return ale#path#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/coffee', + \ 'coffee' + \) +endfunction + +function! ale_linters#coffee#coffee#GetCommand(buffer) abort + return ale_linters#coffee#coffee#GetExecutable(a:buffer) + \ . ' -cp -s' +endfunction + +call ale#linter#Define('coffee', { +\ 'name': 'coffee', +\ 'executable': function('ale_linters#coffee#coffee#GetExecutable'), +\ 'command': function('ale_linters#coffee#coffee#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim b/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim new file mode 100644 index 00000000..b7c85fa7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/coffee/coffeelint.vim @@ -0,0 +1,43 @@ +" Author: Prashanth Chandra https://github.com/prashcr +" Description: coffeelint linter for coffeescript files + +function! ale_linters#coffee#coffeelint#GetExecutable(buffer) abort + return ale#path#ResolveLocalPath( + \ a:buffer, + \ 'node_modules/.bin/coffeelint', + \ 'coffeelint' + \) +endfunction + +function! ale_linters#coffee#coffeelint#GetCommand(buffer) abort + return ale_linters#coffee#coffeelint#GetExecutable(a:buffer) + \ . ' --stdin --reporter csv' +endfunction + +function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " path,lineNumber,lineNumberEnd,level,message + " stdin,14,,error,Throwing strings is forbidden + " + " Note that we currently ignore lineNumberEnd for multiline errors + let l:pattern = 'stdin,\(\d\+\),\(\d*\),\(.\{-1,}\),\(.\+\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('coffee', { +\ 'name': 'coffeelint', +\ 'executable': function('ale_linters#coffee#coffeelint#GetExecutable'), +\ 'command': function('ale_linters#coffee#coffeelint#GetCommand'), +\ 'callback': 'ale_linters#coffee#coffeelint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cc.vim b/sources_non_forked/ale/ale_linters/cpp/cc.vim new file mode 100644 index 00000000..1d35bb67 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cc.vim @@ -0,0 +1,67 @@ +" Author: w0rp +" Description: A C++ compiler linter for C++ files with gcc/clang, etc. + +call ale#Set('cpp_cc_executable', '') +call ale#Set('cpp_cc_options', '-std=c++14 -Wall') +call ale#Set('cpp_cc_use_header_lang_flag', -1) +call ale#Set('cpp_cc_header_exts', ['h', 'hpp']) + +function! ale_linters#cpp#cc#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'cpp_cc_executable') + + " Default to either clang++ or gcc. + if l:executable is# '' + if ale#engine#IsExecutable(a:buffer, 'clang++') + let l:executable = 'clang++' + else + let l:executable = 'gcc' + endif + endif + + return l:executable +endfunction + +function! ale_linters#cpp#cc#GetCommand(buffer, output) abort + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:ale_flags = ale#Var(a:buffer, 'cpp_cc_options') + + if l:cflags =~# '-std=' + let l:ale_flags = substitute( + \ l:ale_flags, + \ '-std=\(c\|gnu\)++[0-9]\{2\}', + \ '', + \ 'g') + endif + + " Select the correct language flag depending on the executable, options + " and file extension + let l:executable = ale_linters#cpp#cc#GetExecutable(a:buffer) + let l:use_header_lang_flag = ale#Var(a:buffer, 'cpp_cc_use_header_lang_flag') + let l:header_exts = ale#Var(a:buffer, 'cpp_cc_header_exts') + let l:lang_flag = ale#c#GetLanguageFlag( + \ a:buffer, + \ l:executable, + \ l:use_header_lang_flag, + \ l:header_exts, + \ 'c++') + + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + " + " `-o /dev/null` or `-o null` is needed to catch all errors, + " -fsyntax-only doesn't catch everything. + return '%e -S -x ' . l:lang_flag + \ . ' -o ' . g:ale#util#nul_file + \ . ' -iquote %s:h' + \ . ale#Pad(l:cflags) + \ . ale#Pad(l:ale_flags) . ' -' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cc', +\ 'aliases': ['gcc', 'clang', 'g++', 'clang++'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#cpp#cc#GetExecutable'), +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#cc#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/ccls.vim b/sources_non_forked/ale/ale_linters/cpp/ccls.vim new file mode 100644 index 00000000..38f8df9c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/ccls.vim @@ -0,0 +1,15 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for C++ + +call ale#Set('cpp_ccls_executable', 'ccls') +call ale#Set('cpp_ccls_init_options', {}) +call ale#Set('c_build_dir', '') + +call ale#linter#Define('cpp', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cpp_ccls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'cpp_ccls_init_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim new file mode 100644 index 00000000..4cb04864 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clangcheck.vim @@ -0,0 +1,35 @@ +" Author: gagbo +" Description: clang-check linter for cpp files + +call ale#Set('cpp_clangcheck_executable', 'clang-check') +call ale#Set('cpp_clangcheck_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort + let l:user_options = ale#Var(a:buffer, 'cpp_clangcheck_options') + + " Try to find compilation database to link automatically + let l:build_dir = ale#Var(a:buffer, 'c_build_dir') + + if empty(l:build_dir) + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + let l:build_dir = ale#path#Dirname(l:json_file) + endif + + " The extra arguments in the command are used to prevent .plist files from + " being generated. These are only added if no build directory can be + " detected. + return '%e -analyze %s' + \ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '') + \ . ale#Pad(l:user_options) + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clangcheck', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'cpp_clangcheck_executable')}, +\ 'command': function('ale_linters#cpp#clangcheck#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangd.vim b/sources_non_forked/ale/ale_linters/cpp/clangd.vim new file mode 100644 index 00000000..14f3fe55 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clangd.vim @@ -0,0 +1,22 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('cpp_clangd_executable', 'clangd') +call ale#Set('cpp_clangd_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cpp#clangd#GetCommand(buffer) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cpp_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cpp_clangd_executable')}, +\ 'command': function('ale_linters#cpp#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim new file mode 100644 index 00000000..fa9f8e31 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clangtidy.vim @@ -0,0 +1,53 @@ +" Author: vdeurzen , w0rp , +" gagbo +" Description: clang-tidy linter for cpp files + +call ale#Set('cpp_clangtidy_executable', 'clang-tidy') +" Set this option to check the checks clang-tidy will apply. +call ale#Set('cpp_clangtidy_checks', []) +" Set this option to manually set some options for clang-tidy to use as compile +" flags. +" This will disable compile_commands.json detection. +call ale#Set('cpp_clangtidy_options', '') +" Set this option to manually set options for clang-tidy directly. +call ale#Set('cpp_clangtidy_extra_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort + let l:checks = join(ale#Var(a:buffer, 'cpp_clangtidy_checks'), ',') + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = '' + + " Get the extra options if we couldn't find a build directory. + if empty(l:build_dir) + let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options') + let l:cflags = ale#c#GetCFlags(a:buffer, a:output) + let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags + + " Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file + " only when compile-commands.json file is not there. Adding these + " flags makes clang-tidy completely ignore compile commands. + if expand('#' . a:buffer) =~# '\.h$' + let l:options .= !empty(l:options) ? ' -x c++' : '-x c++' + endif + endif + + " Get the options to pass directly to clang-tidy + let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options') + + return '%e' + \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') + \ . (!empty(l:extra_options) ? ' ' . ale#Escape(l:extra_options) : '') + \ . ' %s' + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') + \ . (!empty(l:options) ? ' -- ' . l:options : '') +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clangtidy', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'cpp_clangtidy_executable')}, +\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#cpp#clangtidy#GetCommand'))}, +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/clazy.vim b/sources_non_forked/ale/ale_linters/cpp/clazy.vim new file mode 100644 index 00000000..9b29ac9a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/clazy.vim @@ -0,0 +1,32 @@ +" Description: clazy linter for cpp files (clang-based and Qt-oriented) + +call ale#Set('cpp_clazy_executable', 'clazy-standalone') +" Set this option to check the checks clazy will apply. +call ale#Set('cpp_clazy_checks', ['level1']) +" Set this option to manually set some options for clazy. +" This will disable compile_commands.json detection. +call ale#Set('cpp_clazy_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cpp#clazy#GetCommand(buffer) abort + let l:checks = join(ale#Var(a:buffer, 'cpp_clazy_checks'), ',') + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + " Get the extra options if we couldn't find a build directory. + let l:options = ale#Var(a:buffer, 'cpp_clazy_options') + + return '%e' + \ . (!empty(l:checks) ? ' -checks=' . ale#Escape(l:checks) : '') + \ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'clazy', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'cpp_clazy_executable')}, +\ 'command': function('ale_linters#cpp#clazy#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim new file mode 100644 index 00000000..eb86adf4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cppcheck.vim @@ -0,0 +1,29 @@ +" Author: Bart Libert +" Description: cppcheck linter for cpp files + +call ale#Set('cpp_cppcheck_executable', 'cppcheck') +call ale#Set('cpp_cppcheck_options', '--enable=style') + +function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort + let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer) + let l:buffer_path_include = empty(l:compile_commands_option) + \ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) + \ : '' + let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}') + + return '%e -q --language=c++' + \ . l:template + \ . ale#Pad(l:compile_commands_option) + \ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options')) + \ . l:buffer_path_include + \ . ' %t' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cppcheck', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')}, +\ 'cwd': function('ale#handlers#cppcheck#GetCwd'), +\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'), +\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cpplint.vim b/sources_non_forked/ale/ale_linters/cpp/cpplint.vim new file mode 100644 index 00000000..f1f6ce7f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cpplint.vim @@ -0,0 +1,20 @@ +" Author: Dawid Kurek https://github.com/dawikur +" Description: cpplint for cpp files + +call ale#Set('cpp_cpplint_executable', 'cpplint') +call ale#Set('cpp_cpplint_options', '') + +function! ale_linters#cpp#cpplint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'cpp_cpplint_options') + + return '%e' . ale#Pad(l:options) . ' %s' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cpplint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'cpp_cpplint_executable')}, +\ 'command': function('ale_linters#cpp#cpplint#GetCommand'), +\ 'callback': 'ale#handlers#cpplint#HandleCppLintFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cquery.vim b/sources_non_forked/ale/ale_linters/cpp/cquery.vim new file mode 100644 index 00000000..2971cdcb --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cquery.vim @@ -0,0 +1,30 @@ +" Author: Ben Falconer +" Description: A language server for C++ + +call ale#Set('cpp_cquery_executable', 'cquery') +call ale#Set('cpp_cquery_cache_directory', expand('~/.cache/cquery')) + +function! ale_linters#cpp#cquery#GetProjectRoot(buffer) abort + " Try to find cquery configuration files first. + let l:config = ale#path#FindNearestFile(a:buffer, '.cquery') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + " Fall back on default project root detection. + return ale#c#FindProjectRoot(a:buffer) +endfunction + +function! ale_linters#cpp#cquery#GetInitializationOptions(buffer) abort + return {'cacheDirectory': ale#Var(a:buffer, 'cpp_cquery_cache_directory')} +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'cquery', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cpp_cquery_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#cpp#cquery#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#cpp#cquery#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cpp/cspell.vim b/sources_non_forked/ale/ale_linters/cpp/cspell.vim new file mode 100644 index 00000000..ace4c3b2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C++ files. + +call ale#handlers#cspell#DefineLinter('cpp') diff --git a/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim new file mode 100644 index 00000000..5bfdea22 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cpp/flawfinder.vim @@ -0,0 +1,25 @@ +" Author: Christian Gibbons +" Description: flawfinder linter for c++ files + +call ale#Set('cpp_flawfinder_executable', 'flawfinder') +call ale#Set('cpp_flawfinder_options', '') +call ale#Set('cpp_flawfinder_minlevel', 1) +call ale#Set('c_flawfinder_error_severity', 6) + +function! ale_linters#cpp#flawfinder#GetCommand(buffer) abort + " Set the minimum vulnerability level for flawfinder to bother with + let l:minlevel = ' --minlevel=' . ale#Var(a:buffer, 'cpp_flawfinder_minlevel') + + return '%e -CDQS' + \ . ale#Var(a:buffer, 'cpp_flawfinder_options') + \ . l:minlevel + \ . ' %t' +endfunction + +call ale#linter#Define('cpp', { +\ 'name': 'flawfinder', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'cpp_flawfinder_executable')}, +\ 'command': function('ale_linters#cpp#flawfinder#GetCommand'), +\ 'callback': 'ale#handlers#flawfinder#HandleFlawfinderFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/crystal/ameba.vim b/sources_non_forked/ale/ale_linters/crystal/ameba.vim new file mode 100644 index 00000000..5dfc7f45 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/crystal/ameba.vim @@ -0,0 +1,57 @@ +" Author: Harrison Bachrach - https://github.com/HarrisonB +" Description: Ameba, a linter for crystal files + +call ale#Set('crystal_ameba_executable', 'bin/ameba') + +function! ale_linters#crystal#ameba#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'crystal_ameba_executable') + + return ale#Escape(l:executable) + \ . ' --format json ' + \ . ale#Escape(expand('#' . a:buffer . ':p')) +endfunction + +" Handle output from ameba +function! ale_linters#crystal#ameba#HandleAmebaOutput(buffer, lines) abort + if len(a:lines) == 0 + return [] + endif + + let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], {}) + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['issues_count'] == 0 + \|| empty(l:errors['sources']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['sources'][0]['issues'] + let l:start_col = str2nr(l:error['location']['column']) + let l:end_col = str2nr(l:error['end_location']['column']) + + if !l:end_col + let l:end_col = l:start_col + 1 + endif + + call add(l:output, { + \ 'lnum': str2nr(l:error['location']['line']), + \ 'col': l:start_col, + \ 'end_col': l:end_col, + \ 'code': l:error['rule_name'], + \ 'text': l:error['message'], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('crystal', { +\ 'name': 'ameba', +\ 'executable': {b -> ale#Var(b, 'crystal_ameba_executable')}, +\ 'command': function('ale_linters#crystal#ameba#GetCommand'), +\ 'callback': 'ale_linters#crystal#ameba#HandleAmebaOutput', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/crystal/crystal.vim b/sources_non_forked/ale/ale_linters/crystal/crystal.vim new file mode 100644 index 00000000..8a905b12 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/crystal/crystal.vim @@ -0,0 +1,35 @@ +" Author: Jordan Andree , David Alexander +" Description: This file adds support for checking Crystal with crystal build + +function! ale_linters#crystal#crystal#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if !has_key(l:error, 'file') + continue + endif + + call add(l:output, { + \ 'lnum': l:error.line + 0, + \ 'col': l:error.column + 0, + \ 'text': l:error.message, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#crystal#crystal#GetCommand(buffer) abort + return 'crystal build -f json --no-codegen --no-color -o ' + \ . ale#Escape(g:ale#util#nul_file) + \ . ' %s' +endfunction + +call ale#linter#Define('crystal', { +\ 'name': 'crystal', +\ 'executable': 'crystal', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\ 'command': function('ale_linters#crystal#crystal#GetCommand'), +\ 'callback': 'ale_linters#crystal#crystal#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cs/csc.vim b/sources_non_forked/ale/ale_linters/cs/csc.vim new file mode 100644 index 00000000..5ee3de29 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cs/csc.vim @@ -0,0 +1,90 @@ +call ale#Set('cs_csc_options', '') +call ale#Set('cs_csc_source', '') +call ale#Set('cs_csc_assembly_path', []) +call ale#Set('cs_csc_assemblies', []) + +function! ale_linters#cs#csc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_csc_source') + + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') +endfunction + +function! ale_linters#cs#csc#GetCommand(buffer) abort + " Pass assembly paths via the -lib: parameter. + let l:path_list = ale#Var(a:buffer, 'cs_csc_assembly_path') + + let l:lib_option = !empty(l:path_list) + \ ? '/lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',') + \ : '' + + " Pass paths to DLL files via the -r: parameter. + let l:assembly_list = ale#Var(a:buffer, 'cs_csc_assemblies') + + let l:r_option = !empty(l:assembly_list) + \ ? '/r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',') + \ : '' + + " register temporary module target file with ale + " register temporary module target file with ALE. + let l:out = ale#command#CreateFile(a:buffer) + + " The code is compiled as a module and the output is redirected to a + " temporary file. + return 'csc /unsafe' + \ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options')) + \ . ale#Pad(l:lib_option) + \ . ale#Pad(l:r_option) + \ . ' /out:' . l:out + \ . ' /t:module' + \ . ' /recurse:' . ale#Escape('*.cs') +endfunction + +function! ale_linters#cs#csc#Handle(buffer, lines) abort + " Look for lines like the following. + " + " Tests.cs(12,29): error CSXXXX: ; expected + " + " NOTE: pattern also captures file name as linter compiles all + " files within the source tree rooted at the specified source + " path and not just the file loaded in the buffer + let l:patterns = [ + \ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$', + \ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$', + \] + let l:output = [] + let l:dir = ale_linters#cs#csc#GetCwd(a:buffer) + + for l:match in ale#util#GetMatches(a:lines, l:patterns) + if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'code': l:match[5], + \ 'text': l:match[6] , + \}) + elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS' + call add(l:output, { + \ 'filename':'', + \ 'lnum': -1, + \ 'col': -1, + \ 'type': l:match[1] is# 'error' ? 'E' : 'W', + \ 'code': l:match[2], + \ 'text': l:match[3], + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('cs',{ +\ 'name': 'csc', +\ 'output_stream': 'stdout', +\ 'executable': 'csc', +\ 'cwd': function('ale_linters#cs#csc#GetCwd'), +\ 'command': function('ale_linters#cs#csc#GetCommand'), +\ 'callback': 'ale_linters#cs#csc#Handle', +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/cs/cspell.vim b/sources_non_forked/ale/ale_linters/cs/cspell.vim new file mode 100644 index 00000000..c62dd11b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cs/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for C# files. + +call ale#handlers#cspell#DefineLinter('cs') diff --git a/sources_non_forked/ale/ale_linters/cs/mcs.vim b/sources_non_forked/ale/ale_linters/cs/mcs.vim new file mode 100644 index 00000000..1b373e73 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cs/mcs.vim @@ -0,0 +1,37 @@ +let g:ale_cs_mcs_options = get(g:, 'ale_cs_mcs_options', '') + +function! ale_linters#cs#mcs#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'cs_mcs_options') + + return 'mcs -unsafe --parse' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale_linters#cs#mcs#Handle(buffer, lines) abort + " Look for lines like the following. + " + " Tests.cs(12,29): error CSXXXX: ; expected + let l:pattern = '^\v(.+\.cs)\((\d+),(\d+)\)\: ([^ ]+) ([^ ]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'code': l:match[5], + \ 'text': l:match[6], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('cs',{ +\ 'name': 'mcs', +\ 'output_stream': 'stderr', +\ 'executable': 'mcs', +\ 'command': function('ale_linters#cs#mcs#GetCommand'), +\ 'callback': 'ale_linters#cs#mcs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/cs/mcsc.vim b/sources_non_forked/ale/ale_linters/cs/mcsc.vim new file mode 100644 index 00000000..2dd46661 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cs/mcsc.vim @@ -0,0 +1,91 @@ +call ale#Set('cs_mcsc_options', '') +call ale#Set('cs_mcsc_source', '') +call ale#Set('cs_mcsc_assembly_path', []) +call ale#Set('cs_mcsc_assemblies', []) + +function! ale_linters#cs#mcsc#GetCwd(buffer) abort + let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source') + + return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h') +endfunction + +function! ale_linters#cs#mcsc#GetCommand(buffer) abort + " Pass assembly paths via the -lib: parameter. + let l:path_list = ale#Var(a:buffer, 'cs_mcsc_assembly_path') + + let l:lib_option = !empty(l:path_list) + \ ? '-lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',') + \ : '' + + " Pass paths to DLL files via the -r: parameter. + let l:assembly_list = ale#Var(a:buffer, 'cs_mcsc_assemblies') + + let l:r_option = !empty(l:assembly_list) + \ ? '-r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',') + \ : '' + + " register temporary module target file with ale + " register temporary module target file with ALE. + let l:out = ale#command#CreateFile(a:buffer) + + " The code is compiled as a module and the output is redirected to a + " temporary file. + return 'mcs -unsafe' + \ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options')) + \ . ale#Pad(l:lib_option) + \ . ale#Pad(l:r_option) + \ . ' -out:' . l:out + \ . ' -t:module' + \ . ' -recurse:' . ale#Escape('*.cs') +endfunction + +function! ale_linters#cs#mcsc#Handle(buffer, lines) abort + " Look for lines like the following. + " + " Tests.cs(12,29): error CSXXXX: ; expected + " + " NOTE: pattern also captures file name as linter compiles all + " files within the source tree rooted at the specified source + " path and not just the file loaded in the buffer + let l:patterns = [ + \ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$', + \ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$', + \] + let l:output = [] + + let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer) + + for l:match in ale#util#GetMatches(a:lines, l:patterns) + if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS' + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'code': l:match[5], + \ 'text': l:match[6] , + \}) + elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS' + call add(l:output, { + \ 'filename':'', + \ 'lnum': -1, + \ 'col': -1, + \ 'type': l:match[1] is# 'error' ? 'E' : 'W', + \ 'code': l:match[2], + \ 'text': l:match[3], + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('cs',{ +\ 'name': 'mcsc', +\ 'output_stream': 'stderr', +\ 'executable': 'mcs', +\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'), +\ 'command': function('ale_linters#cs#mcsc#GetCommand'), +\ 'callback': 'ale_linters#cs#mcsc#Handle', +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/css/cspell.vim b/sources_non_forked/ale/ale_linters/css/cspell.vim new file mode 100644 index 00000000..d42375b4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for CSS files. + +call ale#handlers#cspell#DefineLinter('css') diff --git a/sources_non_forked/ale/ale_linters/css/csslint.vim b/sources_non_forked/ale/ale_linters/css/csslint.vim new file mode 100644 index 00000000..50c21ce2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/csslint.vim @@ -0,0 +1,18 @@ +" Author: w0rp +" Description: This file adds support for checking CSS code with csslint. + +function! ale_linters#css#csslint#GetCommand(buffer) abort + let l:csslintrc = ale#path#FindNearestFile(a:buffer, '.csslintrc') + let l:config_option = !empty(l:csslintrc) + \ ? '--config=' . ale#Escape(l:csslintrc) + \ : '' + + return 'csslint --format=compact ' . l:config_option . ' %t' +endfunction + +call ale#linter#Define('css', { +\ 'name': 'csslint', +\ 'executable': 'csslint', +\ 'command': function('ale_linters#css#csslint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/css/fecs.vim b/sources_non_forked/ale/ale_linters/css/fecs.vim new file mode 100644 index 00000000..511847c6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/fecs.vim @@ -0,0 +1,9 @@ +" Author: harttle +" Description: fecs for CSS files + +call ale#linter#Define('css', { +\ 'name': 'fecs', +\ 'executable': function('ale#handlers#fecs#GetExecutable'), +\ 'command': function('ale#handlers#fecs#GetCommand'), +\ 'callback': 'ale#handlers#fecs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/css/stylelint.vim b/sources_non_forked/ale/ale_linters/css/stylelint.vim new file mode 100644 index 00000000..e508f392 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/stylelint.vim @@ -0,0 +1,19 @@ +" Author: diartyz + +call ale#Set('css_stylelint_executable', 'stylelint') +call ale#Set('css_stylelint_options', '') +call ale#Set('css_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#css#stylelint#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'css_stylelint_options')) + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('css', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'css_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': function('ale_linters#css#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/css/vscodecss.vim b/sources_non_forked/ale/ale_linters/css/vscodecss.vim new file mode 100644 index 00000000..2d59adf0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/css/vscodecss.vim @@ -0,0 +1,16 @@ +" Author: Dalius Dobravolskas +" Description: VSCode css language server + +function! ale_linters#css#vscodecss#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('css', { +\ 'name': 'vscodecss', +\ 'lsp': 'stdio', +\ 'executable': 'vscode-css-language-server', +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#css#vscodecss#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim new file mode 100644 index 00000000..0cfd815e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cucumber/cucumber.vim @@ -0,0 +1,46 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Cucumber, a BDD test tool + +function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort + let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features') + + if !empty(l:features_dir) + let l:features_arg = '-r ' . ale#Escape(l:features_dir) + else + let l:features_arg = '' + endif + + return 'cucumber --dry-run --quiet --strict --format=json ' + \ . l:features_arg . ' %t' +endfunction + +function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort + try + let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0] + catch + return [] + endtry + + let l:output = [] + + for l:element in get(l:json, 'elements', []) + for l:step in l:element['steps'] + if l:step['result']['status'] is# 'undefined' + call add(l:output, { + \ 'lnum': l:step['line'], + \ 'code': 'E', + \ 'text': 'Undefined step' + \}) + endif + endfor + endfor + + return l:output +endfunction + +call ale#linter#Define('cucumber', { +\ 'name': 'cucumber', +\ 'executable': 'cucumber', +\ 'command': function('ale_linters#cucumber#cucumber#GetCommand'), +\ 'callback': 'ale_linters#cucumber#cucumber#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/cuda/clangd.vim b/sources_non_forked/ale/ale_linters/cuda/clangd.vim new file mode 100644 index 00000000..bfda821b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cuda/clangd.vim @@ -0,0 +1,23 @@ +" Author: Tommy Chiang +" Description: Clangd language server for CUDA (modified from Andrey +" Melentyev's implementation for C++) + +call ale#Set('cuda_clangd_executable', 'clangd') +call ale#Set('cuda_clangd_options', '') +call ale#Set('c_build_dir', '') + +function! ale_linters#cuda#clangd#GetCommand(buffer) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'cuda_clangd_options')) + \ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '') +endfunction + +call ale#linter#Define('cuda', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'cuda_clangd_executable')}, +\ 'command': function('ale_linters#cuda#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/cuda/nvcc.vim b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim new file mode 100644 index 00000000..2734f6ec --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cuda/nvcc.vim @@ -0,0 +1,46 @@ +" Author: blahgeek +" Description: NVCC linter for cuda files + +call ale#Set('cuda_nvcc_executable', 'nvcc') +call ale#Set('cuda_nvcc_options', '-std=c++11') + +function! ale_linters#cuda#nvcc#GetCommand(buffer) abort + return '%e -cuda' + \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) + \ . ale#Pad(ale#Var(a:buffer, 'cuda_nvcc_options')) + \ . ' %s -o ' . g:ale#util#nul_file +endfunction + +function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort + " Look for lines like the following. + " + " test.cu(8): error: argument of type "void *" is incompatible with parameter of type "int *" + let l:pattern = '\v^([^:\(\)]+):?\(?(\d+)\)?:(\d+)?:?\s*\w*\s*(error|warning): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[4] =~# 'error' ? 'E' : 'W', + \ 'text': l:match[5], + \ 'filename': fnamemodify(l:match[1], ':p'), + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('cuda', { +\ 'name': 'nvcc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'cuda_nvcc_executable')}, +\ 'command': function('ale_linters#cuda#nvcc#GetCommand'), +\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/cypher/cypher_lint.vim b/sources_non_forked/ale/ale_linters/cypher/cypher_lint.vim new file mode 100644 index 00000000..408ddd6e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/cypher/cypher_lint.vim @@ -0,0 +1,26 @@ +" Author: Francisco Lopes +" Description: Linting for Neo4j's Cypher + +function! ale_linters#cypher#cypher_lint#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+): (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('cypher', { +\ 'name': 'cypher_lint', +\ 'executable': 'cypher-lint', +\ 'command': 'cypher-lint', +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#cypher#cypher_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/d/dls.vim b/sources_non_forked/ale/ale_linters/d/dls.vim new file mode 100644 index 00000000..78d1c152 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/d/dls.vim @@ -0,0 +1,22 @@ +" Author: aurieh +" Description: A Language Server implementation for D + +call ale#Set('d_dls_executable', 'dls') + +function! ale_linters#d#dls#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'd_dls_executable') +endfunction + +function! ale_linters#d#dls#FindProjectRoot(buffer) abort + " Note: this will return . if dub config is empty + " dls can run outside DUB projects just fine + return fnamemodify(ale#d#FindDUBConfig(a:buffer), ':h') +endfunction + +call ale#linter#Define('d', { +\ 'name': 'dls', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#d#dls#GetExecutable'), +\ 'command': function('ale_linters#d#dls#GetExecutable'), +\ 'project_root': function('ale_linters#d#dls#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/d/dmd.vim b/sources_non_forked/ale/ale_linters/d/dmd.vim new file mode 100644 index 00000000..f38e812c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/d/dmd.vim @@ -0,0 +1,116 @@ +" Author: w0rp +" Description: "dmd for D files" + +function! s:GetDUBCommand(buffer) abort + " If we can't run dub, then skip this command. + if executable('dub') + " Returning an empty string skips to the DMD command. + let l:config = ale#d#FindDUBConfig(a:buffer) + + " To support older dub versions, we just change the directory to the + " directory where we found the dub config, and then run `dub describe` + " from that directory. + if !empty(l:config) + return [fnamemodify(l:config, ':h'), 'dub describe --data-list + \ --data=import-paths + \ --data=string-import-paths + \ --data=versions + \ --data=debug-versions + \'] + endif + endif + + return ['', ''] +endfunction + +function! ale_linters#d#dmd#RunDUBCommand(buffer) abort + let [l:cwd, l:command] = s:GetDUBCommand(a:buffer) + + if empty(l:command) + " If we can't run DUB, just run DMD. + return ale_linters#d#dmd#DMDCommand(a:buffer, [], {}) + endif + + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#d#dmd#DMDCommand'), + \ {'cwd': l:cwd}, + \) +endfunction + +function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort + let l:import_list = [] + let l:str_import_list = [] + let l:versions_list = [] + let l:deb_versions_list = [] + let l:list_ind = 1 + let l:seen_line = 0 + + " Build a list of options generated from DUB, if available. + " DUB output each path or version on a single line. + " Each list is separated by a blank line. + " Empty list are represented by a blank line (followed and/or + " preceded by a separation blank line) + for l:line in a:dub_output + " line still has end of line char on windows + let l:line = substitute(l:line, '[\r\n]*$', '', '') + + if !empty(l:line) + if l:list_ind == 1 + call add(l:import_list, '-I' . ale#Escape(l:line)) + elseif l:list_ind == 2 + call add(l:str_import_list, '-J' . ale#Escape(l:line)) + elseif l:list_ind == 3 + call add(l:versions_list, '-version=' . ale#Escape(l:line)) + elseif l:list_ind == 4 + call add(l:deb_versions_list, '-debug=' . ale#Escape(l:line)) + endif + + let l:seen_line = 1 + elseif !l:seen_line + " if list is empty must skip one empty line + let l:seen_line = 1 + else + let l:seen_line = 0 + let l:list_ind += 1 + endif + endfor + + return 'dmd ' . join(l:import_list) . ' ' . + \ join(l:str_import_list) . ' ' . + \ join(l:versions_list) . ' ' . + \ join(l:deb_versions_list) . ' -o- -wi -vcolumns -c %t' +endfunction + +function! ale_linters#d#dmd#Handle(buffer, lines) abort + " Matches patterns lines like the following: + " /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this') + " /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read + let l:pattern = '\v^(\f+)\((\d+)(,(\d+))?\): (\w+): (.+)$' + let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " If dmd was invoked with relative path, match[1] is relative, otherwise it is absolute. + " As we invoke dmd with the buffer path (in /tmp), this will generally be absolute already + let l:fname = ale#path#GetAbsPath(l:dir, l:match[1]) + call add(l:output, { + \ 'filename': l:fname, + \ 'lnum': l:match[2], + \ 'col': l:match[4], + \ 'type': l:match[5] is# 'Warning' || l:match[5] is# 'Deprecation' ? 'W' : 'E', + \ 'text': l:match[6], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('d', { +\ 'name': 'dmd', +\ 'executable': 'dmd', +\ 'command': function('ale_linters#d#dmd#RunDUBCommand'), +\ 'callback': 'ale_linters#d#dmd#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/dafny/dafny.vim b/sources_non_forked/ale/ale_linters/dafny/dafny.vim new file mode 100644 index 00000000..2a9f761a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dafny/dafny.vim @@ -0,0 +1,41 @@ +" Author: Taylor Blau + +function! ale_linters#dafny#dafny#Handle(buffer, lines) abort + let l:pattern = '\v(.*)\((\d+),(\d+)\): (.*): (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': l:match[1], + \ 'col': l:match[3] + 0, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[5], + \ 'type': l:match[4] =~# '^Error' ? 'E' : 'W' + \ }) + endfor + + for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)') + call add(l:output, { + \ 'filename': l:match[1], + \ 'col': l:match[3] + 0, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ }) + endfor + + return l:output +endfunction + +function! ale_linters#dafny#dafny#GetCommand(buffer) abort + return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit')) +endfunction + +call ale#Set('dafny_dafny_timelimit', 10) +call ale#linter#Define('dafny', { +\ 'name': 'dafny', +\ 'executable': 'dafny', +\ 'command': function('ale_linters#dafny#dafny#GetCommand'), +\ 'callback': 'ale_linters#dafny#dafny#Handle', +\ 'lint_file': 1, +\ }) diff --git a/sources_non_forked/ale/ale_linters/dart/analysis_server.vim b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim new file mode 100644 index 00000000..a6870da9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/analysis_server.vim @@ -0,0 +1,29 @@ +" Author: Nelson Yeung +" Description: Check Dart files with dart analysis server LSP + +call ale#Set('dart_analysis_server_executable', 'dart') + +function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort + " Note: pub only looks for pubspec.yaml, there's no point in adding + " support for pubspec.yml + let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') + + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.' +endfunction + +function! ale_linters#dart#analysis_server#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable') + let l:dart = resolve(exepath(l:executable)) + + return '%e ' + \ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot' + \ . ' --lsp' +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'analysis_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')}, +\ 'command': function('ale_linters#dart#analysis_server#GetCommand'), +\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim new file mode 100644 index 00000000..7d67c31c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/dart_analyze.vim @@ -0,0 +1,29 @@ +" Author: ghsang +" Description: Check Dart files with dart analyze + +call ale#Set('dart_analyze_executable', 'dart') + +function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort + let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6] + call add(l:output, { + \ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W', + \ 'text': l:code . ': ' . l:message, + \ 'lnum': str2nr(l:lnum), + \ 'col': str2nr(l:col), + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'dart_analyze', +\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')}, +\ 'command': '%e analyze --fatal-infos %s', +\ 'callback': 'ale_linters#dart#dart_analyze#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/dart/language_server.vim b/sources_non_forked/ale/ale_linters/dart/language_server.vim new file mode 100644 index 00000000..d0e639c8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dart/language_server.vim @@ -0,0 +1,20 @@ +" Author: aurieh +" Description: A language server for dart + +call ale#Set('dart_language_server_executable', 'dart_language_server') + +function! ale_linters#dart#language_server#GetProjectRoot(buffer) abort + " Note: pub only looks for pubspec.yaml, there's no point in adding + " support for pubspec.yml + let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml') + + return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '' +endfunction + +call ale#linter#Define('dart', { +\ 'name': 'language_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'dart_language_server_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#dart#language_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim new file mode 100644 index 00000000..5a97d315 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/desktop/desktop_file_validate.vim @@ -0,0 +1,31 @@ +call ale#Set('desktop_desktop_file_validate_options', '') + +" Example matches for pattern: +" +" foo.desktop: warning: key "TerminalOptions" in group ... +" foo.desktop: error: action "new-private-window" is defined, ... +let s:pattern = '\v^(.+): ([a-z]+): (.+)$' + +function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort + " The error format doesn't specify lines, so we can just put all of the + " errors on line 1. + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'lnum': 1, + \ 'col': 1, + \ 'type': match[2] is? 'error' ? 'E' : 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('desktop', { +\ 'name': 'desktop_file_validate', +\ 'aliases': ['desktop-file-validate'], +\ 'executable': 'desktop-file-validate', +\ 'command': {b -> +\ '%e' +\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options')) +\ . ' %t' +\ }, +\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim new file mode 100644 index 00000000..0c0ad533 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dockerfile/dockerfile_lint.vim @@ -0,0 +1,76 @@ +" Author: Alexander Olofsson + +call ale#Set('dockerfile_dockerfile_lint_executable', 'dockerfile_lint') +call ale#Set('dockerfile_dockerfile_lint_options', '') + +function! ale_linters#dockerfile#dockerfile_lint#GetType(type) abort + if a:type is? 'error' + return 'E' + elseif a:type is? 'warn' + return 'W' + endif + + return 'I' +endfunction + +function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort + try + let l:data = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:data) + " Should never happen, but it's better to be on the safe side + return [] + endif + + let l:messages = [] + + for l:type in ['error', 'warn', 'info'] + for l:object in l:data[l:type]['data'] + let l:line = get(l:object, 'line', -1) + let l:message = l:object['message'] + + let l:link = get(l:object, 'reference_url', '') + + if type(l:link) == v:t_list + " Somehow, reference_url is returned as two-part list. + " Anchor markers in that list are sometimes duplicated. + " See https://github.com/projectatomic/dockerfile_lint/issues/134 + let l:link = join(l:link, '') + let l:link = substitute(l:link, '##', '#', '') + endif + + let l:detail = l:message + + if get(l:object, 'description', 'None') isnot# 'None' + let l:detail .= "\n\n" . l:object['description'] + endif + + let l:detail .= "\n\n" . l:link + + call add(l:messages, { + \ 'lnum': l:line, + \ 'text': l:message, + \ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type), + \ 'detail': l:detail, + \}) + endfor + endfor + + return l:messages +endfunction + +function! ale_linters#dockerfile#dockerfile_lint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'dockerfile_dockerfile_lint_options')) + \ . ' -p -j -f' + \ . ' %t' +endfunction + +call ale#linter#Define('dockerfile', { +\ 'name': 'dockerfile_lint', +\ 'executable': {b -> ale#Var(b, 'dockerfile_dockerfile_lint_executable')}, +\ 'command': function('ale_linters#dockerfile#dockerfile_lint#GetCommand'), +\ 'callback': 'ale_linters#dockerfile#dockerfile_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim new file mode 100644 index 00000000..9a6a6258 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/dockerfile/hadolint.vim @@ -0,0 +1,123 @@ +" Author: hauleth - https://github.com/hauleth + +" always, yes, never +call ale#Set('dockerfile_hadolint_use_docker', 'never') +call ale#Set('dockerfile_hadolint_docker_image', 'hadolint/hadolint') +call ale#Set('dockerfile_hadolint_options', '') + +function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " -:19 DL3001 warning: Pipe chain should start with a raw value. + " /dev/stdin:19:3 unexpected thing + let l:pattern = '\v^%(/dev/stdin|-):(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:lnum = 0 + let l:colnum = 0 + + if l:match[1] isnot# '' + let l:lnum = l:match[1] + 0 + endif + + if l:match[2] isnot# '' + let l:colnum = l:match[2] + 0 + endif + + " Shellcheck knows a 'style' severity - pin it to info level as well. + if l:match[7] is# 'style' + let l:type = 'I' + elseif l:match[7] is# 'info' + let l:type = 'I' + elseif l:match[7] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:text = l:match[8] + let l:detail = l:match[8] + let l:domain = 'https://github.com/hadolint/hadolint/wiki/' + let l:code = '' + let l:link = '' + + if l:match[4] is# 'SC' + let l:domain = 'https://github.com/koalaman/shellcheck/wiki/' + endif + + if l:match[5] isnot# '' + let l:code = l:match[4] . l:match[5] + let l:link = ' ( ' . l:domain . l:code . ' )' + let l:text = l:code . ': ' . l:detail + let l:detail = l:code . l:link . "\n\n" . l:detail + else + let l:type = 'E' + let l:detail = 'hadolint could not parse the file because of a syntax error.' + endif + + let l:line_output = { + \ 'lnum': l:lnum, + \ 'col': l:colnum, + \ 'type': l:type, + \ 'text': l:text, + \ 'detail': l:detail + \} + + if l:code isnot# '' + let l:line_output['code'] = l:code + endif + + call add(l:output, l:line_output) + endfor + + return l:output +endfunction + +" This is a little different than the typical 'executable' callback. We want +" to afford the user the chance to say always use docker, never use docker, +" and use docker if the hadolint executable is not present on the system. +" +" In the case of neither docker nor hadolint executables being present, it +" really doesn't matter which we return -- either will have the effect of +" 'nope, can't use this linter!'. + +function! ale_linters#dockerfile#hadolint#GetExecutable(buffer) abort + let l:use_docker = ale#Var(a:buffer, 'dockerfile_hadolint_use_docker') + + " check for mandatory directives + if l:use_docker is# 'never' + return 'hadolint' + elseif l:use_docker is# 'always' + return 'docker' + endif + + " if we reach here, we want to use 'hadolint' if present... + if executable('hadolint') + return 'hadolint' + endif + + "... and 'docker' as a fallback. + return 'docker' +endfunction + +function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort + let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer) + let l:opts = ale#Var(a:buffer, 'dockerfile_hadolint_options') . ' --no-color -' + + if l:command is# 'docker' + return printf('docker run --rm -i %s hadolint %s', + \ ale#Var(a:buffer, 'dockerfile_hadolint_docker_image'), + \ l:opts) + endif + + return 'hadolint ' . l:opts +endfunction + + +call ale#linter#Define('dockerfile', { +\ 'name': 'hadolint', +\ 'executable': function('ale_linters#dockerfile#hadolint#GetExecutable'), +\ 'command': function('ale_linters#dockerfile#hadolint#GetCommand'), +\ 'callback': 'ale_linters#dockerfile#hadolint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/credo.vim b/sources_non_forked/ale/ale_linters/elixir/credo.vim new file mode 100644 index 00000000..d6a861f4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/credo.vim @@ -0,0 +1,71 @@ +" Author: hauleth - https://github.com/hauleth + +function! ale_linters#elixir#credo#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " lib/filename.ex:19:7: F: Pipe chain should start with a raw value. + let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = l:match[3] + let l:text = l:match[4] + + " Refactoring opportunities + if l:type is# 'F' + let l:type = 'W' + " Consistency + elseif l:type is# 'C' + let l:type = 'W' + " Software Design + elseif l:type is# 'D' + let l:type = 'I' + " Code Readability + elseif l:type is# 'R' + let l:type = 'I' + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#elixir#credo#GetMode() abort + if get(g:, 'ale_elixir_credo_strict', 0) + return '--strict' + else + return 'suggest' + endif +endfunction + +function! ale_linters#elixir#credo#GetConfigFile() abort + let l:config_file = get(g:, 'ale_elixir_credo_config_file', '') + + if empty(l:config_file) + return '' + endif + + return ' --config-file ' . l:config_file +endfunction + +function! ale_linters#elixir#credo#GetCommand(buffer) abort + return 'mix help credo && ' + \ . 'mix credo ' . ale_linters#elixir#credo#GetMode() + \ . ale_linters#elixir#credo#GetConfigFile() + \ . ' --format=flycheck --read-from-stdin %s' +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'credo', +\ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixUmbrellaRoot'), +\ 'command': function('ale_linters#elixir#credo#GetCommand'), +\ 'callback': 'ale_linters#elixir#credo#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/cspell.vim b/sources_non_forked/ale/ale_linters/elixir/cspell.vim new file mode 100644 index 00000000..12dc271f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Elixir files. + +call ale#handlers#cspell#DefineLinter('elixir') diff --git a/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim new file mode 100644 index 00000000..9b8a5cda --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/dialyxir.vim @@ -0,0 +1,34 @@ +" Author: Fran C. - https://github.com/franciscoj +" Description: Add dialyzer support for elixir through dialyxir +" https://github.com/jeremyjh/dialyxir + +function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " lib/filename.ex:19: Function fname/1 has no local return + let l:pattern = '\v(.+):(\d+): (.+)$' + let l:output = [] + let l:type = 'W' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if bufname(a:buffer) == l:match[1] + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[2] + 0, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:match[3], + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'dialyxir', +\ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dialyzer && mix dialyzer', +\ 'callback': 'ale_linters#elixir#dialyxir#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/dogma.vim b/sources_non_forked/ale/ale_linters/elixir/dogma.vim new file mode 100644 index 00000000..28e7f420 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/dogma.vim @@ -0,0 +1,39 @@ +" Author: archseer - https://github.com/archSeer + +function! ale_linters#elixir#dogma#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " lib/filename.ex:19:7: F: Pipe chain should start with a raw value. + let l:pattern = '\v:(\d+):?(\d+)?: (.): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = l:match[3] + let l:text = l:match[4] + + if l:type is# 'C' + let l:type = 'E' + elseif l:type is# 'R' + let l:type = 'W' + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'dogma', +\ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': 'mix help dogma && mix dogma %s --format=flycheck', +\ 'lint_file': 1, +\ 'callback': 'ale_linters#elixir#dogma#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim new file mode 100644 index 00000000..d5517de5 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/elixir_ls.vim @@ -0,0 +1,21 @@ +" Author: Jon Parise +" Description: ElixirLS integration (https://github.com/JakeBecker/elixir-ls) + +call ale#Set('elixir_elixir_ls_release', 'elixir-ls') +call ale#Set('elixir_elixir_ls_config', {}) + +function! ale_linters#elixir#elixir_ls#GetExecutable(buffer) abort + let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_elixir_ls_release')) + let l:cmd = has('win32') ? '\language_server.bat' : '/language_server.sh' + + return l:dir . l:cmd +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'elixir-ls', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#elixir#elixir_ls#GetExecutable'), +\ 'command': function('ale_linters#elixir#elixir_ls#GetExecutable'), +\ 'project_root': function('ale#handlers#elixir#FindMixUmbrellaRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'elixir_elixir_ls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/elixir/mix.vim b/sources_non_forked/ale/ale_linters/elixir/mix.vim new file mode 100644 index 00000000..948c6d36 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elixir/mix.vim @@ -0,0 +1,45 @@ +" Author: evnu - https://github.com/evnu +" Author: colbydehart - https://github.com/colbydehart +" Description: Mix compile checking for Elixir files + +function! ale_linters#elixir#mix#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " Error format + " ** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4 + " + " TODO: Warning format + " warning: variable "foobar" does not exist and is being expanded to "foobar()", please use parentheses to remove the ambiguity or change the variable name + let l:pattern = '\v\(([^\)]+Error)\) ([^:]+):([^:]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = 'E' + let l:text = l:match[4] + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[3] + 0, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#elixir#mix#GetCommand(buffer) abort + let l:temp_dir = ale#command#CreateDirectory(a:buffer) + + return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s' +endfunction + +call ale#linter#Define('elixir', { +\ 'name': 'mix', +\ 'executable': 'mix', +\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'), +\ 'command': function('ale_linters#elixir#mix#GetCommand'), +\ 'callback': 'ale_linters#elixir#mix#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/elm/elm_ls.vim b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim new file mode 100644 index 00000000..a02dbf42 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elm/elm_ls.vim @@ -0,0 +1,40 @@ +" Author: antew - https://github.com/antew +" Description: elm-language-server integration for elm (diagnostics, formatting, and more) + +call ale#Set('elm_ls_executable', 'elm-language-server') +call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1)) + +" elm-language-server will search for local and global binaries, if empty +call ale#Set('elm_ls_elm_path', '') +call ale#Set('elm_ls_elm_format_path', '') +call ale#Set('elm_ls_elm_test_path', '') +call ale#Set('elm_ls_elm_analyse_trigger', 'change') + +function! elm_ls#GetRootDir(buffer) abort + let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') + + return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : '' +endfunction + +function! elm_ls#GetOptions(buffer) abort + return { + \ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), + \ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), + \ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'), + \ 'elmAnalyseTrigger': ale#Var(a:buffer, 'elm_ls_elm_analyse_trigger'), + \} +endfunction + +call ale#linter#Define('elm', { +\ 'name': 'elm_ls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'elm_ls', [ +\ 'node_modules/.bin/elm-language-server', +\ 'node_modules/.bin/elm-lsp', +\ 'elm-lsp' +\ ])}, +\ 'command': '%e --stdio', +\ 'project_root': function('elm_ls#GetRootDir'), +\ 'language': 'elm', +\ 'initialization_options': function('elm_ls#GetOptions') +\}) diff --git a/sources_non_forked/ale/ale_linters/elm/make.vim b/sources_non_forked/ale/ale_linters/elm/make.vim new file mode 100644 index 00000000..a7f9ea7b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/elm/make.vim @@ -0,0 +1,242 @@ +" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod, hecrj - https://github.com/hecrj +" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim. + +call ale#Set('elm_make_executable', 'elm') +call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#elm#make#Handle(buffer, lines) abort + let l:output = [] + let l:unparsed_lines = [] + + for l:line in a:lines + if l:line[0] is# '{' + " Elm 0.19 + call ale_linters#elm#make#HandleElm019Line(l:line, l:output) + elseif l:line[0] is# '[' + " Elm 0.18 + call ale_linters#elm#make#HandleElm018Line(l:line, l:output) + elseif l:line isnot# 'Successfully generated /dev/null' + call add(l:unparsed_lines, l:line) + endif + endfor + + if len(l:unparsed_lines) > 0 + call add(l:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:unparsed_lines[0], + \ 'detail': join(l:unparsed_lines, "\n") + \}) + endif + + return l:output +endfunction + +function! ale_linters#elm#make#HandleElm019Line(line, output) abort + let l:report = json_decode(a:line) + + if l:report.type is? 'error' + " General problem + let l:details = ale_linters#elm#make#ParseMessage(l:report.message) + + if empty(l:report.path) + let l:report.path = 'Elm' + endif + + if ale_linters#elm#make#FileIsBuffer(l:report.path) + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:details, + \}) + else + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:report.path .' - '. l:details, + \ 'detail': l:report.path ." ----------\n\n". l:details, + \}) + endif + else + " Compilation errors + for l:error in l:report.errors + let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.path) + + for l:problem in l:error.problems + let l:details = ale_linters#elm#make#ParseMessage(l:problem.message) + + if l:file_is_buffer + " Buffer module has problems + call add(a:output, { + \ 'lnum': l:problem.region.start.line, + \ 'col': l:problem.region.start.column, + \ 'end_lnum': l:problem.region.end.line, + \ 'end_col': l:problem.region.end.column, + \ 'type': 'E', + \ 'text': l:details, + \}) + else + " Imported module has problems + let l:location = l:error.path .':'. l:problem.region.start.line + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:location .' - '. l:details, + \ 'detail': l:location ." ----------\n\n". l:details, + \}) + endif + endfor + endfor + endif +endfunction + +function! ale_linters#elm#make#HandleElm018Line(line, output) abort + let l:errors = json_decode(a:line) + + for l:error in l:errors + let l:file_is_buffer = ale_linters#elm#make#FileIsBuffer(l:error.file) + + if l:file_is_buffer + " Current buffer has problems + call add(a:output, { + \ 'lnum': l:error.region.start.line, + \ 'col': l:error.region.start.column, + \ 'end_lnum': l:error.region.end.line, + \ 'end_col': l:error.region.end.column, + \ 'type': (l:error.type is? 'error') ? 'E' : 'W', + \ 'text': l:error.overview, + \ 'detail': l:error.overview . "\n\n" . l:error.details + \}) + elseif l:error.type is? 'error' + " Imported module has errors + let l:location = l:error.file .':'. l:error.region.start.line + + call add(a:output, { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': l:location .' - '. l:error.overview, + \ 'detail': l:location ." ----------\n\n". l:error.overview . "\n\n" . l:error.details + \}) + endif + endfor +endfunction + +function! ale_linters#elm#make#FileIsBuffer(path) abort + return ale#path#IsTempName(a:path) +endfunction + +function! ale_linters#elm#make#ParseMessage(message) abort + return join(map(copy(a:message), 'ale_linters#elm#make#ParseMessageItem(v:val)'), '') +endfunction + +function! ale_linters#elm#make#ParseMessageItem(item) abort + if type(a:item) is v:t_string + return a:item + else + return a:item.string + endif +endfunction + +function! ale_linters#elm#make#GetPackageFile(buffer) abort + let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') + + if empty(l:elm_json) + " Fallback to Elm 0.18 + let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm-package.json') + endif + + return l:elm_json +endfunction + +function! ale_linters#elm#make#IsVersionGte19(buffer) abort + let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer) + + if l:elm_json =~# '-package' + return 0 + else + return 1 + endif +endfunction + +function! ale_linters#elm#make#GetRootDir(buffer) abort + let l:elm_json = ale_linters#elm#make#GetPackageFile(a:buffer) + + if empty(l:elm_json) + return '' + else + return fnamemodify(l:elm_json, ':p:h') + endif +endfunction + +function! ale_linters#elm#make#IsTest(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + if empty(l:root_dir) + return 0 + endif + + let l:tests_dir = join([l:root_dir, 'tests', ''], has('win32') ? '\' : '/') + + let l:buffer_path = fnamemodify(bufname(a:buffer), ':p') + + if stridx(l:buffer_path, l:tests_dir) == 0 + return 1 + else + return 0 + endif +endfunction + +function! ale_linters#elm#make#GetCwd(buffer) abort + let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer) + + return !empty(l:root_dir) ? l:root_dir : '' +endfunction + +" Return the command to execute the linter in the projects directory. +" If it doesn't, then this will fail when imports are needed. +function! ale_linters#elm#make#GetCommand(buffer) abort + let l:executable = ale_linters#elm#make#GetExecutable(a:buffer) + let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) + let l:is_using_elm_test = l:executable =~# 'elm-test$' + + " elm-test needs to know the path of elm-make if elm isn't installed globally. + " https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler + if l:is_v19 && l:is_using_elm_test + let l:elm_make_executable = ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + let l:elm_test_compiler_flag = ' --compiler ' . l:elm_make_executable . ' ' + else + let l:elm_test_compiler_flag = ' ' + endif + + " The elm compiler, at the time of this writing, uses '/dev/null' as + " a sort of flag to tell the compiler not to generate an output file, + " which is why this is hard coded here. + " Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253 + return '%e make --report=json --output=/dev/null' + \ . l:elm_test_compiler_flag + \ . '%t' +endfunction + +function! ale_linters#elm#make#GetExecutable(buffer) abort + let l:is_test = ale_linters#elm#make#IsTest(a:buffer) + let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer) + + if l:is_test && l:is_v19 + return ale#path#FindExecutable( + \ a:buffer, + \ 'elm_make', + \ ['node_modules/.bin/elm-test', 'node_modules/.bin/elm'] + \) + else + return ale#path#FindExecutable(a:buffer, 'elm_make', ['node_modules/.bin/elm']) + endif +endfunction + +call ale#linter#Define('elm', { +\ 'name': 'make', +\ 'executable': function('ale_linters#elm#make#GetExecutable'), +\ 'output_stream': 'both', +\ 'cwd': function('ale_linters#elm#make#GetCwd'), +\ 'command': function('ale_linters#elm#make#GetCommand'), +\ 'callback': 'ale_linters#elm#make#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim new file mode 100644 index 00000000..a97c9520 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/dialyzer.vim @@ -0,0 +1,97 @@ +" Author: Autoine Gagne - https://github.com/AntoineGagne +" Description: Define a checker that runs dialyzer on Erlang files. + +let g:ale_erlang_dialyzer_executable = +\ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') +let g:ale_erlang_dialyzer_options = +\ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns' +\ . ' -Werror_handling' +\ . ' -Wrace_conditions' +\ . ' -Wunderspecs') +let g:ale_erlang_dialyzer_plt_file = +\ get(g:, 'ale_erlang_dialyzer_plt_file', '') +let g:ale_erlang_dialyzer_rebar3_profile = +\ get(g:, 'ale_erlang_dialyzer_rebar3_profile', 'default') + +function! ale_linters#erlang#dialyzer#GetRebar3Profile(buffer) abort + return ale#Var(a:buffer, 'erlang_dialyzer_rebar3_profile') +endfunction + +function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort + let l:plt_file = '' + let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer) + let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build/' . l:rebar3_profile) + + if !empty(l:plt_file_directory) + let l:plt_file = globpath(l:plt_file_directory, '*_plt', 0, 1) + endif + + if !empty(l:plt_file) + return l:plt_file[0] + endif + + if !empty($REBAR_PLT_DIR) + return expand('$REBAR_PLT_DIR/dialyzer/plt') + endif + + return expand('$HOME/.dialyzer_plt') +endfunction + +function! ale_linters#erlang#dialyzer#GetPlt(buffer) abort + let l:plt_file = ale#Var(a:buffer, 'erlang_dialyzer_plt_file') + + if !empty(l:plt_file) + return l:plt_file + endif + + return ale_linters#erlang#dialyzer#FindPlt(a:buffer) +endfunction + +function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'erlang_dialyzer_executable') +endfunction + +function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options') + + let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer)) + \ . ' -n' + \ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer)) + \ . ' ' . l:options + \ . ' %s' + + return l:command +endfunction + +function! ale_linters#erlang#dialyzer#Handle(buffer, lines) abort + " Match patterns like the following: + " + " erl_tidy_prv_fmt.erl:3: Callback info about the provider behaviour is not available + let l:pattern = '^\S\+:\(\d\+\): \(.\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) != 0 + let l:code = l:match[2] + + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'lcol': 0, + \ 'text': l:code, + \ 'type': 'W' + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'dialyzer', +\ 'executable': function('ale_linters#erlang#dialyzer#GetExecutable'), +\ 'command': function('ale_linters#erlang#dialyzer#GetCommand'), +\ 'callback': function('ale_linters#erlang#dialyzer#Handle'), +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/elvis.vim b/sources_non_forked/ale/ale_linters/erlang/elvis.vim new file mode 100644 index 00000000..0fb85c07 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/elvis.vim @@ -0,0 +1,40 @@ +" Author: Dmitri Vereshchagin +" Description: Elvis linter for Erlang files + +call ale#Set('erlang_elvis_executable', 'elvis') + +function! ale_linters#erlang#elvis#Handle(buffer, lines) abort + let l:pattern = '\v:(\d+):[^:]+:(.+)' + let l:loclist = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:loclist, { + \ 'lnum': str2nr(l:match[1]), + \ 'text': s:AbbreviateMessage(l:match[2]), + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + endfor + + return l:loclist +endfunction + +function! s:AbbreviateMessage(text) abort + let l:pattern = '\v\c^(line \d+ is too long):.*$' + + return substitute(a:text, l:pattern, '\1.', '') +endfunction + +function! s:GetCommand(buffer) abort + let l:file = ale#Escape(expand('#' . a:buffer . ':.')) + + return '%e rock --output-format=parsable ' . l:file +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'elvis', +\ 'callback': 'ale_linters#erlang#elvis#Handle', +\ 'executable': {b -> ale#Var(b, 'erlang_elvis_executable')}, +\ 'command': function('s:GetCommand'), +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim b/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim new file mode 100644 index 00000000..b747e454 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/erlang_ls.vim @@ -0,0 +1,49 @@ +" Author: Dmitri Vereshchagin +" Description: LSP linter for Erlang files + +call ale#Set('erlang_erlang_ls_executable', 'erlang_ls') +call ale#Set('erlang_erlang_ls_log_dir', '') +call ale#Set('erlang_erlang_ls_log_level', 'info') + +function! s:GetCommand(buffer) abort + let l:log_dir = ale#Var(a:buffer, 'erlang_erlang_ls_log_dir') + let l:log_level = ale#Var(a:buffer, 'erlang_erlang_ls_log_level') + + let l:command = '%e' + + if !empty(l:log_dir) + let l:command .= ' --log-dir=' . ale#Escape(l:log_dir) + endif + + let l:command .= ' --log-level=' . ale#Escape(l:log_level) + + return l:command +endfunction + +function! s:FindProjectRoot(buffer) abort + let l:markers = ['_build/', 'erlang_ls.config', 'rebar.lock'] + + " This is a way to find Erlang/OTP root (the one that is managed + " by kerl or asdf). Useful if :ALEGoToDefinition takes us there. + let l:markers += ['.kerl_config'] + + for l:marker in l:markers + let l:path = l:marker[-1:] is# '/' + \ ? ale#path#FindNearestDirectory(a:buffer, l:marker) + \ : ale#path#FindNearestFile(a:buffer, l:marker) + + if !empty(l:path) + return ale#path#Dirname(l:path) + endif + endfor + + return '' +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'erlang_ls', +\ 'executable': {b -> ale#Var(b, 'erlang_erlang_ls_executable')}, +\ 'command': function('s:GetCommand'), +\ 'lsp': 'stdio', +\ 'project_root': function('s:FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/erlc.vim b/sources_non_forked/ale/ale_linters/erlang/erlc.vim new file mode 100644 index 00000000..0c67a73f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/erlc.vim @@ -0,0 +1,104 @@ +" Author: Magnus Ottenklinger - https://github.com/evnu + +let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc') +let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '') + +function! ale_linters#erlang#erlc#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'erlang_erlc_executable') +endfunction + +function! ale_linters#erlang#erlc#GetCommand(buffer) abort + let l:output_file = ale#util#Tempname() + call ale#command#ManageFile(a:buffer, l:output_file) + + let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer)) + \ . ' -o ' . ale#Escape(l:output_file) + \ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options') + \ . ' %t' + + return l:command +endfunction + +function! ale_linters#erlang#erlc#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " error.erl:4: variable 'B' is unbound + " error.erl:3: Warning: function main/0 is unused + " error.erl:4: Warning: variable 'A' is unused + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+:)? (Warning: )?(.+)$' + + " parse_transforms are a special case. The error message does not indicate a location: + " error.erl: undefined parse transform 'some_parse_transform' + let l:pattern_parse_transform = '\v(undefined parse transform .*)$' + let l:output = [] + + let l:pattern_no_module_definition = '\v(no module definition)$' + let l:pattern_unused = '\v(.* is unused)$' + + let l:is_hrl = fnamemodify(bufname(a:buffer), ':e') is# 'hrl' + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + " Determine if the output indicates an error. We distinguish between two cases: + " + " 1) normal errors match l:pattern + " 2) parse_transform errors match l:pattern_parse_transform + " + " If none of the patterns above match, the line can be ignored + if len(l:match) == 0 " not a 'normal' warning or error + let l:match_parse_transform = matchlist(l:line, l:pattern_parse_transform) + + if len(l:match_parse_transform) == 0 " also not a parse_transform error + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': 0, + \ 'col': 0, + \ 'type': 'E', + \ 'text': l:match_parse_transform[0], + \}) + + continue + endif + + let l:line = l:match[2] + let l:warning_or_text = l:match[4] + let l:text = l:match[5] + + " If this file is a header .hrl, ignore the following expected messages: + " - 'no module definition' + " - 'X is unused' + if l:is_hrl && ( + \ match(l:text, l:pattern_no_module_definition) != -1 + \ || match(l:text, l:pattern_unused) != -1 + \) + continue + endif + + if !empty(l:warning_or_text) + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:line, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'erlc', +\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'), +\ 'command': function('ale_linters#erlang#erlc#GetCommand'), +\ 'callback': 'ale_linters#erlang#erlc#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim new file mode 100644 index 00000000..5d555a8d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/erlang/syntaxerl.vim @@ -0,0 +1,42 @@ +" Author: Dmitri Vereshchagin +" Description: SyntaxErl linter for Erlang files + +call ale#Set('erlang_syntaxerl_executable', 'syntaxerl') + +function! ale_linters#erlang#syntaxerl#RunHelpCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'erlang_syntaxerl_executable') + + return ale#command#Run( + \ a:buffer, + \ ale#Escape(l:executable) . ' -h', + \ function('ale_linters#erlang#syntaxerl#GetCommand'), + \) +endfunction + +function! ale_linters#erlang#syntaxerl#GetCommand(buffer, output, meta) abort + let l:use_b_option = match(a:output, '\C\V-b, --base\>') > -1 + + return '%e' . (l:use_b_option ? ' -b %s %t' : ' %t') +endfunction + +function! ale_linters#erlang#syntaxerl#Handle(buffer, lines) abort + let l:pattern = '\v\C:(\d+):( warning:)? (.+)' + let l:loclist = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:loclist, { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[3], + \ 'type': empty(l:match[2]) ? 'E' : 'W', + \}) + endfor + + return l:loclist +endfunction + +call ale#linter#Define('erlang', { +\ 'name': 'syntaxerl', +\ 'executable': {b -> ale#Var(b, 'erlang_syntaxerl_executable')}, +\ 'command': {b -> ale_linters#erlang#syntaxerl#RunHelpCommand(b)}, +\ 'callback': 'ale_linters#erlang#syntaxerl#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/erb.vim b/sources_non_forked/ale/ale_linters/eruby/erb.vim new file mode 100644 index 00000000..f3438320 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/erb.vim @@ -0,0 +1,25 @@ +" Author: Matthias Guenther - https://wikimatze.de, Eddie Lebow https://github.com/elebow +" Description: ERB from the Ruby standard library, for eruby/erb files + +function! ale_linters#eruby#erb#GetCommand(buffer) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if empty(l:rails_root) + return 'erb -P -T - -x %t | ruby -c' + endif + + " Rails-flavored eRuby does not comply with the standard as understood by + " ERB, so we'll have to do some substitution. This does not reduce the + " effectiveness of the linter—the translated code is still evaluated. + return 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c' +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'erb', +\ 'aliases': ['erubylint'], +\ 'executable': 'erb', +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#eruby#erb#GetCommand'), +\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', +\}) + diff --git a/sources_non_forked/ale/ale_linters/eruby/erblint.vim b/sources_non_forked/ale/ale_linters/eruby/erblint.vim new file mode 100644 index 00000000..19960185 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/erblint.vim @@ -0,0 +1,51 @@ +" Author: Roeland Moors - https://github.com/roelandmoors +" based on the ale ruumba and robocop linters +" Description: ERB Lint, support for https://github.com/Shopify/erb-lint + +call ale#Set('eruby_erblint_executable', 'erblint') +call ale#Set('eruby_erblint_options', '') + +function! ale_linters#eruby#erblint#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'erblint') + \ . ' --format json ' + \ . ale#Var(a:buffer, 'eruby_erblint_options') + \ . ' --stdin %s' +endfunction + +function! ale_linters#eruby#erblint#Handle(buffer, lines) abort + if empty(a:lines) + return [] + endif + + let l:errors = ale#util#FuzzyJSONDecode(a:lines[0], []) + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['offenses'] == 0 + \|| empty(l:errors['files']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['files'][0]['offenses'] + call add(l:output, { + \ 'lnum': l:error['location']['start_line'] + 0, + \ 'col': l:error['location']['start_column'] + 0, + \ 'end_col': l:error['location']['last_column'] + 0, + \ 'code': l:error['linter'], + \ 'text': l:error['message'], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'erblint', +\ 'executable': {b -> ale#Var(b, 'eruby_erblint_executable')}, +\ 'command': function('ale_linters#eruby#erblint#GetCommand'), +\ 'callback': 'ale_linters#eruby#erblint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/erubi.vim b/sources_non_forked/ale/ale_linters/eruby/erubi.vim new file mode 100644 index 00000000..ddca3f61 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/erubi.vim @@ -0,0 +1,32 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: eruby checker using `erubi` + +function! ale_linters#eruby#erubi#GetCommand(buffer, output, meta) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if !empty(a:output) + " The empty command in CheckErubi returns nothing if erubi runs and + " emits an error if erubi is not present + return '' + endif + + if empty(l:rails_root) + return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c' + endif + + " Rails-flavored eRuby does not comply with the standard as understood by + " Erubi, so we'll have to do some substitution. This does not reduce the + " effectiveness of the linter---the translated code is still evaluated. + return 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c' +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'erubi', +\ 'executable': 'ruby', +\ 'command': {buffer -> ale#command#Run( +\ buffer, +\ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'), +\ function('ale_linters#eruby#erubi#GetCommand'), +\ )}, +\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/erubis.vim b/sources_non_forked/ale/ale_linters/eruby/erubis.vim new file mode 100644 index 00000000..755c5803 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/erubis.vim @@ -0,0 +1,23 @@ +" Author: Jake Zimmerman , Eddie Lebow https://github.com/elebow +" Description: eruby checker using `erubis`, instead of `erb` + +function! ale_linters#eruby#erubis#GetCommand(buffer) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if empty(l:rails_root) + return 'erubis -x %t | ruby -c' + endif + + " Rails-flavored eRuby does not comply with the standard as understood by + " Erubis, so we'll have to do some substitution. This does not reduce the + " effectiveness of the linter - the translated code is still evaluated. + return 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c' +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'erubis', +\ 'executable': 'erubis', +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#eruby#erubis#GetCommand'), +\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', +\}) diff --git a/sources_non_forked/ale/ale_linters/eruby/ruumba.vim b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim new file mode 100644 index 00000000..f415f1ab --- /dev/null +++ b/sources_non_forked/ale/ale_linters/eruby/ruumba.vim @@ -0,0 +1,62 @@ +" Author: aclemons - https://github.com/aclemons +" based on the ale rubocop linter +" Description: Ruumba, RuboCop linting for ERB templates. + +call ale#Set('eruby_ruumba_executable', 'ruumba') +call ale#Set('eruby_ruumba_options', '') + +function! ale_linters#eruby#ruumba#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_ruumba_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'ruumba') + \ . ' --format json --force-exclusion ' + \ . ale#Var(a:buffer, 'eruby_ruumba_options') + \ . ' --stdin %s' +endfunction + +function! ale_linters#eruby#ruumba#Handle(buffer, lines) abort + try + let l:errors = json_decode(a:lines[0]) + catch + return [] + endtry + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['offense_count'] == 0 + \|| empty(l:errors['files']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['files'][0]['offenses'] + let l:start_col = l:error['location']['column'] + 0 + call add(l:output, { + \ 'lnum': l:error['location']['line'] + 0, + \ 'col': l:start_col, + \ 'end_col': l:start_col + l:error['location']['length'] - 1, + \ 'code': l:error['cop_name'], + \ 'text': l:error['message'], + \ 'type': ale_linters#eruby#ruumba#GetType(l:error['severity']), + \}) + endfor + + return l:output +endfunction + +function! ale_linters#eruby#ruumba#GetType(severity) abort + if a:severity is? 'convention' + \|| a:severity is? 'warning' + \|| a:severity is? 'refactor' + return 'W' + endif + + return 'E' +endfunction + +call ale#linter#Define('eruby', { +\ 'name': 'ruumba', +\ 'executable': {b -> ale#Var(b, 'eruby_ruumba_executable')}, +\ 'command': function('ale_linters#eruby#ruumba#GetCommand'), +\ 'callback': 'ale_linters#eruby#ruumba#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/fish/fish.vim b/sources_non_forked/ale/ale_linters/fish/fish.vim new file mode 100644 index 00000000..87ede29a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/fish/fish.vim @@ -0,0 +1,67 @@ +" Author: Niraj Thapaliya - https://github.com/nthapaliya +" Description: Lints fish files using fish -n + +function! ale_linters#fish#fish#Handle(buffer, lines) abort + " Matches patterns such as: + " + " home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition + " function foo + " ^ + " + " OR, patterns such as: + " + " Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'. + " /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY + " ^ + " + " fish -n can return errors in either format. + let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$' + let l:column_pattern = '^ *\^' + let l:output = [] + let l:column_offset = 0 + let l:last_line_with_message = '' + + for l:line in a:lines + " Look for error lines first. + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + if !empty(l:last_line_with_message) + let l:text = l:last_line_with_message + else + let l:text = l:match[3] + endif + + let l:column_offset = len(l:match[1]) + + let l:last_line_with_message = '' + call add(l:output, { + \ 'col': 0, + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:text, + \}) + else + " Look for column markers like ' ^' second. + " The column index will be set according to how long the line is. + let l:column_match = matchstr(l:line, l:column_pattern) + + if !empty(l:column_match) && !empty(l:output) + let l:output[-1].col = len(l:column_match) - l:column_offset + let l:last_line_with_message = '' + else + let l:last_line_with_message = l:line + let l:column_offset = 0 + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('fish', { +\ 'name': 'fish', +\ 'output_stream': 'stderr', +\ 'executable': 'fish', +\ 'command': 'fish -n %t', +\ 'callback': 'ale_linters#fish#fish#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/fortran/gcc.vim b/sources_non_forked/ale/ale_linters/fortran/gcc.vim new file mode 100644 index 00000000..6e97d6fd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/fortran/gcc.vim @@ -0,0 +1,72 @@ +" Author: w0rp +" Description: gcc for Fortran files + +" This option can be set to 0 to use -ffixed-form +call ale#Set('fortran_gcc_use_free_form', 1) +call ale#Set('fortran_gcc_executable', 'gcc') +" Set this option to change the GCC options for warnings for Fortran. +call ale#Set('fortran_gcc_options', '-Wall') + +function! ale_linters#fortran#gcc#Handle(buffer, lines) abort + " We have to match a starting line and a later ending line together, + " like so. + " + " :21.34: + " Error: Expected comma in I/O list at (1) + let l:line_marker_pattern = ':\(\d\+\)[.:]\=\(\d\+\)\=:\=$' + let l:message_pattern = '^\(Error\|Warning\): \(.\+\)$' + let l:looking_for_message = 0 + let l:last_loclist_obj = {} + + let l:output = [] + + for l:line in a:lines + if l:looking_for_message + let l:match = matchlist(l:line, l:message_pattern) + else + let l:match = matchlist(l:line, l:line_marker_pattern) + endif + + if len(l:match) == 0 + continue + endif + + if l:looking_for_message + let l:looking_for_message = 0 + + " Now we have the text, we can set it and add the error. + let l:last_loclist_obj.text = l:match[2] + let l:last_loclist_obj.type = l:match[1] is# 'Warning' ? 'W' : 'E' + call add(l:output, l:last_loclist_obj) + else + let l:last_loclist_obj = { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \} + + " Start looking for the message and error type. + let l:looking_for_message = 1 + endif + endfor + + return l:output +endfunction + +function! ale_linters#fortran#gcc#GetCommand(buffer) abort + let l:layout_option = ale#Var(a:buffer, 'fortran_gcc_use_free_form') + \ ? '-ffree-form' + \ : '-ffixed-form' + + return '%e -S -x f95 -fsyntax-only ' . l:layout_option + \ . ale#Pad(ale#Var(a:buffer, 'fortran_gcc_options')) + \ . ' -' +endfunction + +call ale#linter#Define('fortran', { +\ 'name': 'gcc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'fortran_gcc_executable')}, +\ 'command': function('ale_linters#fortran#gcc#GetCommand'), +\ 'callback': 'ale_linters#fortran#gcc#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/fortran/language_server.vim b/sources_non_forked/ale/ale_linters/fortran/language_server.vim new file mode 100644 index 00000000..00aa0577 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/fortran/language_server.vim @@ -0,0 +1,19 @@ +" Author: unpairedbracket ben.spiers22@gmail.com +" Description: A language server for fortran + +call ale#Set('fortran_language_server_executable', 'fortls') +call ale#Set('fortran_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#fortran#language_server#GetProjectRoot(buffer) abort + let l:fortls_file = ale#path#FindNearestFile(a:buffer, '.fortls') + + return !empty(l:fortls_file) ? fnamemodify(l:fortls_file, ':h') : '' +endfunction + +call ale#linter#Define('fortran', { +\ 'name': 'language_server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'fortran_language_server_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#fortran#language_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/fountain/proselint.vim b/sources_non_forked/ale/ale_linters/fountain/proselint.vim new file mode 100644 index 00000000..353a2e5f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/fountain/proselint.vim @@ -0,0 +1,9 @@ +" Author: Jansen Mitchell https://github.com/JansenMitchell +" Description: proselint for Fountain files + +call ale#linter#Define('fountain', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim b/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim new file mode 100644 index 00000000..ffb25d33 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/fuse/fusionlint.vim @@ -0,0 +1,33 @@ +" Author: RyanSquared +" Description: `fusion-lint` linter for FusionScript files + +call ale#Set('fuse_fusionlint_executable', 'fusion-lint') +call ale#Set('fuse_fusionlint_options', '') + +function! ale_linters#fuse#fusionlint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'fuse_fusionlint_options')) + \ . ' --filename %s -i' +endfunction + +function! ale_linters#fuse#fusionlint#Handle(buffer, lines) abort + let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\d\+) \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('fuse', { +\ 'name': 'fusionlint', +\ 'executable': {b -> ale#Var(b, 'fuse_fusionlint_executable')}, +\ 'command': function('ale_linters#fuse#fusionlint#GetCommand'), +\ 'callback': 'ale_linters#fuse#fusionlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim new file mode 100644 index 00000000..4b9cec63 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/gitcommit/gitlint.vim @@ -0,0 +1,51 @@ +" Author: Nick Yamane +" Description: gitlint for git commit message files + +call ale#Set('gitcommit_gitlint_executable', 'gitlint') +call ale#Set('gitcommit_gitlint_options', '') +call ale#Set('gitcommit_gitlint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#gitcommit#gitlint#GetExecutable(buffer) abort + return ale#python#FindExecutable(a:buffer, 'gitcommit_gitlint', ['gitlint']) +endfunction + +function! ale_linters#gitcommit#gitlint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'gitcommit_gitlint_options') + + return '%e' . ale#Pad(l:options) . ' lint' +endfunction + +function! ale_linters#gitcommit#gitlint#Handle(buffer, lines) abort + " Matches patterns line the following: + let l:pattern = '\v^(\d+): (\w+) (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[2] + + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + if l:code is# 'T2' || l:code is# 'B2' + continue + endif + endif + + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[3], + \ 'code': l:code, + \ 'type': 'E', + \} + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('gitcommit', { +\ 'name': 'gitlint', +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#gitcommit#gitlint#GetExecutable'), +\ 'command': function('ale_linters#gitcommit#gitlint#GetCommand'), +\ 'callback': 'ale_linters#gitcommit#gitlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/glsl/glslang.vim b/sources_non_forked/ale/ale_linters/glsl/glslang.vim new file mode 100644 index 00000000..bbddce90 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/glsl/glslang.vim @@ -0,0 +1,40 @@ +" Author: Sven-Hendrik Haase +" Description: glslang-based linter for glsl files +" +" TODO: Once https://github.com/KhronosGroup/glslang/pull/1047 is accepted, +" we can use stdin. + +call ale#Set('glsl_glslang_executable', 'glslangValidator') +call ale#Set('glsl_glslang_options', '') + +function! ale_linters#glsl#glslang#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'glsl_glslang_options')) + \ . ' -C %t' +endfunction + +function! ale_linters#glsl#glslang#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " ERROR: 0:5: 'foo' : undeclared identifier + let l:pattern = '^\(.\+\): \(\d\+\):\(\d\+\): \(.\+\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[3]), + \ 'col': str2nr(l:match[2]), + \ 'text': l:match[4], + \ 'type': l:match[1] is# 'ERROR' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('glsl', { +\ 'name': 'glslang', +\ 'executable': {b -> ale#Var(b, 'glsl_glslang_executable')}, +\ 'command': function('ale_linters#glsl#glslang#GetCommand'), +\ 'callback': 'ale_linters#glsl#glslang#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/glsl/glslls.vim b/sources_non_forked/ale/ale_linters/glsl/glslls.vim new file mode 100644 index 00000000..b62844c7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/glsl/glslls.vim @@ -0,0 +1,30 @@ +" Author: Sven-Hendrik Haase +" Description: A language server for glsl + +call ale#Set('glsl_glslls_executable', 'glslls') +call ale#Set('glsl_glslls_logfile', '') + +function! ale_linters#glsl#glslls#GetCommand(buffer) abort + let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile') + let l:logfile_args = '' + + if l:logfile isnot# '' + let l:logfile_args = ' --verbose -l ' . l:logfile + endif + + return '%e' . l:logfile_args . ' --stdin' +endfunction + +function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort + let l:project_root = ale#c#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h:h') : '' +endfunction + +call ale#linter#Define('glsl', { +\ 'name': 'glslls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'glsl_glslls_executable')}, +\ 'command': function('ale_linters#glsl#glslls#GetCommand'), +\ 'project_root': function('ale_linters#glsl#glslls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/go/bingo.vim b/sources_non_forked/ale/ale_linters/go/bingo.vim new file mode 100644 index 00000000..1e43f8e4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/bingo.vim @@ -0,0 +1,31 @@ +" Author: Jerko Steiner +" Description: https://github.com/saibing/bingo + +call ale#Set('go_bingo_executable', 'bingo') +call ale#Set('go_bingo_options', '--mode stdio') + +function! ale_linters#go#bingo#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) . '%e' . ale#Pad(ale#Var(a:buffer, 'go_bingo_options')) +endfunction + +function! ale_linters#go#bingo#FindProjectRoot(buffer) abort + let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off' + let l:project_root = l:go_modules_off ? + \ '' : ale#path#FindNearestFile(a:buffer, 'go.mod') + let l:mods = ':h' + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + let l:mods = ':h:h' + endif + + return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : '' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'bingo', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'go_bingo_executable')}, +\ 'command': function('ale_linters#go#bingo#GetCommand'), +\ 'project_root': function('ale_linters#go#bingo#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/go/cspell.vim b/sources_non_forked/ale/ale_linters/go/cspell.vim new file mode 100644 index 00000000..f986a31a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Go files. + +call ale#handlers#cspell#DefineLinter('go') diff --git a/sources_non_forked/ale/ale_linters/go/gobuild.vim b/sources_non_forked/ale/ale_linters/go/gobuild.vim new file mode 100644 index 00000000..5210c5a8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gobuild.vim @@ -0,0 +1,57 @@ +" Author: Joshua Rubin , Ben Reedy , +" Jeff Willette +" Description: go build for Go files +" inspired by work from dzhou121 + +call ale#Set('go_go_executable', 'go') +call ale#Set('go_gobuild_options', '') + +function! ale_linters#go#gobuild#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_gobuild_options') + + " Run go test in local directory with relative path + return ale#go#EnvString(a:buffer) + \ . ale#Var(a:buffer, 'go_go_executable') . ' test' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -c -o /dev/null ./' +endfunction + +function! ale_linters#go#gobuild#GetMatches(lines) abort + " Matches patterns like the following: + " + " file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args + " file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) + " file.go:5:2: expected declaration, found 'STRING' "log" + " go test returns relative paths so use tail of filename as part of pattern matcher + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? (.+)$' + + return ale#util#GetMatches(a:lines, l:pattern) +endfunction + +function! ale_linters#go#gobuild#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + for l:match in ale_linters#go#gobuild#GetMatches(a:lines) + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('go', { +\ 'name': 'gobuild', +\ 'aliases': ['go build'], +\ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#gobuild#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#go#gobuild#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/gofmt.vim b/sources_non_forked/ale/ale_linters/go/gofmt.vim new file mode 100644 index 00000000..b313f9ca --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gofmt.vim @@ -0,0 +1,15 @@ +" Author: neersighted +" Description: gofmt for Go files + +function! ale_linters#go#gofmt#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) + \ . '%e -e %t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'gofmt', +\ 'output_stream': 'stderr', +\ 'executable': 'gofmt', +\ 'command': function('ale_linters#go#gofmt#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) diff --git a/sources_non_forked/ale/ale_linters/go/golangci_lint.vim b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim new file mode 100644 index 00000000..80431b99 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/golangci_lint.vim @@ -0,0 +1,64 @@ +" Author: Sascha Grunert +" Description: Adds support of golangci-lint + +call ale#Set('go_golangci_lint_options', '--enable-all') +call ale#Set('go_golangci_lint_executable', 'golangci-lint') +call ale#Set('go_golangci_lint_package', 0) + +function! ale_linters#go#golangci_lint#GetCommand(buffer) abort + let l:filename = expand('#' . a:buffer . ':t') + let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') + let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package') + + + if l:lint_package + return ale#go#EnvString(a:buffer) + \ . '%e run ' + \ . l:options + endif + + return ale#go#EnvString(a:buffer) + \ . '%e run ' + \ . ale#Escape(l:filename) + \ . ' ' . l:options +endfunction + +function! ale_linters#go#golangci_lint#GetMatches(lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)\s+\((.+)\)$' + + return ale#util#GetMatches(a:lines, l:pattern) +endfunction + +function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + for l:match in ale_linters#go#golangci_lint#GetMatches(a:lines) + if l:match[5] is# 'typecheck' + let l:msg_type = 'E' + else + let l:msg_type = 'W' + endif + + " l:match[1] will already be an absolute path, output from + " golangci_lint + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:msg_type, + \ 'text': l:match[4] . ' (' . l:match[5] . ')', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('go', { +\ 'name': 'golangci-lint', +\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#golangci_lint#GetCommand'), +\ 'callback': 'ale_linters#go#golangci_lint#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/golint.vim b/sources_non_forked/ale/ale_linters/go/golint.vim new file mode 100644 index 00000000..79bfaeb5 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/golint.vim @@ -0,0 +1,21 @@ +" Author: neersighted +" Description: golint for Go files + +call ale#Set('go_golint_executable', 'golint') +call ale#Set('go_golint_options', '') + +function! ale_linters#go#golint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_golint_options') + + return ale#go#EnvString(a:buffer) . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'golint', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'go_golint_executable')}, +\ 'command': function('ale_linters#go#golint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/go/gometalinter.vim b/sources_non_forked/ale/ale_linters/go/gometalinter.vim new file mode 100644 index 00000000..ac33a9f3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gometalinter.vim @@ -0,0 +1,58 @@ +" Author: Ben Reedy , Jeff Willette +" Description: Adds support for the gometalinter suite for Go files + +call ale#Set('go_gometalinter_options', '') +call ale#Set('go_gometalinter_executable', 'gometalinter') +call ale#Set('go_gometalinter_lint_package', 0) + +function! ale_linters#go#gometalinter#GetCommand(buffer) abort + let l:filename = expand('#' . a:buffer . ':t') + let l:options = ale#Var(a:buffer, 'go_gometalinter_options') + let l:lint_package = ale#Var(a:buffer, 'go_gometalinter_lint_package') + + " BufferCdString is used so that we can be sure the paths output from gometalinter can + " be calculated to absolute paths in the Handler + if l:lint_package + return ale#go#EnvString(a:buffer) + \ . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' + endif + + return ale#go#EnvString(a:buffer) + \ . '%e' + \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename)) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' +endfunction + +function! ale_linters#go#gometalinter#GetMatches(lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?(warning|error):?\s\*?(.+)$' + + return ale#util#GetMatches(a:lines, l:pattern) +endfunction + +function! ale_linters#go#gometalinter#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + for l:match in ale_linters#go#gometalinter#GetMatches(a:lines) + " l:match[1] will already be an absolute path, output from gometalinter + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': tolower(l:match[4]) is# 'warning' ? 'W' : 'E', + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('go', { +\ 'name': 'gometalinter', +\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#gometalinter#GetCommand'), +\ 'callback': 'ale_linters#go#gometalinter#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/gopls.vim b/sources_non_forked/ale/ale_linters/go/gopls.vim new file mode 100644 index 00000000..80909830 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gopls.vim @@ -0,0 +1,39 @@ +" Author: w0rp +" Author: Jerko Steiner +" Description: https://github.com/saibing/gopls + +call ale#Set('go_gopls_executable', 'gopls') +call ale#Set('go_gopls_options', '--mode stdio') +call ale#Set('go_gopls_init_options', {}) +call ale#Set('go_gopls_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#go#gopls#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) + \ . '%e' + \ . ale#Pad(ale#Var(a:buffer, 'go_gopls_options')) +endfunction + +function! ale_linters#go#gopls#FindProjectRoot(buffer) abort + let l:go_modules_off = ale#Var(a:buffer, 'go_go111module') is# 'off' + let l:project_root = l:go_modules_off ? + \ '' : ale#path#FindNearestFile(a:buffer, 'go.mod') + let l:mods = ':h' + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + let l:mods = ':h:h' + endif + + return !empty(l:project_root) ? fnamemodify(l:project_root, l:mods) : '' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'gopls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_gopls', [ +\ ale#go#GetGoPathExecutable('bin/gopls'), +\ ])}, +\ 'command': function('ale_linters#go#gopls#GetCommand'), +\ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/gosimple.vim b/sources_non_forked/ale/ale_linters/go/gosimple.vim new file mode 100644 index 00000000..490d15a9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gosimple.vim @@ -0,0 +1,12 @@ +" Author: Ben Reedy +" Description: gosimple for Go files + +call ale#linter#Define('go', { +\ 'name': 'gosimple', +\ 'executable': 'gosimple', +\ 'cwd': '%s:h', +\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'}, +\ 'callback': 'ale#handlers#go#Handler', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/gotype.vim b/sources_non_forked/ale/ale_linters/go/gotype.vim new file mode 100644 index 00000000..8fd6df27 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/gotype.vim @@ -0,0 +1,24 @@ +" Author: Jelte Fennema +" Description: gotype for Go files + +function! ale_linters#go#gotype#GetExecutable(buffer) abort + if expand('#' . a:buffer . ':p') =~# '_test\.go$' + return '' + endif + + return 'gotype' +endfunction + +function! ale_linters#go#gotype#GetCommand(buffer) abort + return ale#go#EnvString(a:buffer) . 'gotype -e .' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'gotype', +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#go#gotype#GetExecutable'), +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#gotype#GetCommand'), +\ 'callback': 'ale#handlers#go#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/govet.vim b/sources_non_forked/ale/ale_linters/go/govet.vim new file mode 100644 index 00000000..5da8261c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/govet.vim @@ -0,0 +1,28 @@ +" Author: neersighted +" Description: go vet for Go files +" +" Author: John Eikenberry +" Description: updated to work with go1.10 + +call ale#Set('go_go_executable', 'go') +call ale#Set('go_govet_options', '') + +function! ale_linters#go#govet#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_govet_options') + + return ale#go#EnvString(a:buffer) + \ . ale#Var(a:buffer, 'go_go_executable') . ' vet ' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' .' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'govet', +\ 'aliases': ['go vet'], +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'go_go_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#govet#GetCommand'), +\ 'callback': 'ale#handlers#go#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/go/langserver.vim b/sources_non_forked/ale/ale_linters/go/langserver.vim new file mode 100644 index 00000000..7130db40 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/langserver.vim @@ -0,0 +1,29 @@ +" Author: Horacio Sanson +" Description: Support for go-langserver https://github.com/sourcegraph/go-langserver + +call ale#Set('go_langserver_executable', 'go-langserver') +call ale#Set('go_langserver_options', '') + +function! ale_linters#go#langserver#GetCommand(buffer) abort + let l:executable = [ale#Escape(ale#Var(a:buffer, 'go_langserver_executable'))] + let l:options = ale#Var(a:buffer, 'go_langserver_options') + let l:options = substitute(l:options, '-gocodecompletion', '', 'g') + let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1') + + if ale#Var(a:buffer, 'completion_enabled') + call add(l:options, '-gocodecompletion') + endif + + let l:options = uniq(sort(l:options)) + let l:env = ale#go#EnvString(a:buffer) + + return l:env . join(extend(l:executable, l:options), ' ') +endfunction + +call ale#linter#Define('go', { +\ 'name': 'golangserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'go_langserver_executable')}, +\ 'command': function('ale_linters#go#langserver#GetCommand'), +\ 'project_root': function('ale#go#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/go/revive.vim b/sources_non_forked/ale/ale_linters/go/revive.vim new file mode 100644 index 00000000..b14b5ab9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/revive.vim @@ -0,0 +1,21 @@ +" Author: Penghui Liao +" Description: Adds support for revive + +call ale#Set('go_revive_executable', 'revive') +call ale#Set('go_revive_options', '') + +function! ale_linters#go#revive#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_revive_options') + + return ale#go#EnvString(a:buffer) . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'revive', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'go_revive_executable')}, +\ 'command': function('ale_linters#go#revive#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/go/staticcheck.vim b/sources_non_forked/ale/ale_linters/go/staticcheck.vim new file mode 100644 index 00000000..36622440 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/go/staticcheck.vim @@ -0,0 +1,34 @@ +" Author: Ben Reedy +" Description: staticcheck for Go files + +call ale#Set('go_staticcheck_executable', 'staticcheck') +call ale#Set('go_staticcheck_options', '') +call ale#Set('go_staticcheck_lint_package', 1) +call ale#Set('go_staticcheck_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#go#staticcheck#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'go_staticcheck_options') + let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package') + let l:env = ale#go#EnvString(a:buffer) + + if l:lint_package + return l:env . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') . ' .' + endif + + return l:env . '%e' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s:t' +endfunction + +call ale#linter#Define('go', { +\ 'name': 'staticcheck', +\ 'executable': {b -> ale#path#FindExecutable(b, 'go_staticcheck', [ +\ ale#go#GetGoPathExecutable('bin/staticcheck'), +\ ])}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#go#staticcheck#GetCommand'), +\ 'callback': 'ale#handlers#go#Handler', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/graphql/eslint.vim b/sources_non_forked/ale/ale_linters/graphql/eslint.vim new file mode 100644 index 00000000..a98233e9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/graphql/eslint.vim @@ -0,0 +1,10 @@ +" Author: Benjie Gillam +" Description: eslint for GraphQL files + +call ale#linter#Define('graphql', { +\ 'name': 'eslint', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/graphql/gqlint.vim b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim new file mode 100644 index 00000000..6f1ca54a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/graphql/gqlint.vim @@ -0,0 +1,10 @@ +" Author: Michiel Westerbeek +" Description: Linter for GraphQL Schemas + +call ale#linter#Define('graphql', { +\ 'name': 'gqlint', +\ 'executable': 'gqlint', +\ 'cwd': '%s:h', +\ 'command': 'gqlint --reporter=simple %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/hack/hack.vim b/sources_non_forked/ale/ale_linters/hack/hack.vim new file mode 100644 index 00000000..822b5c87 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/hack/hack.vim @@ -0,0 +1,22 @@ +" Author: Fred Emmott +" Description: Hack support via `hack lsp` + +call ale#Set('hack_hack_executable', 'hh_client') + +function! ale_linters#hack#hack#GetProjectRoot(buffer) abort + let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') + + return !empty(l:hhconfig) ? fnamemodify(l:hhconfig, ':h') : '' +endfunction + +function! ale_linters#hack#hack#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'hack_hack_executable') +endfunction + +call ale#linter#Define('hack', { +\ 'name': 'hack', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#hack#hack#GetExecutable'), +\ 'command': '%e lsp --from vim-ale', +\ 'project_root': function('ale_linters#hack#hack#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/hack/hhast.vim b/sources_non_forked/ale/ale_linters/hack/hhast.vim new file mode 100644 index 00000000..5e6d4dec --- /dev/null +++ b/sources_non_forked/ale/ale_linters/hack/hhast.vim @@ -0,0 +1,40 @@ +" Author: Fred Emmott +" Description: Hack support via `hhast lsp` + +call ale#Set('hack_hhast_executable', 'vendor/bin/hhast-lint') + +function! ale_linters#hack#hhast#GetProjectRoot(buffer) abort + " Find the hack root, then figure out if it's also an HHAST root. + " Don't try to use lint configurations from vendor/foo/bar/hhast-lint.json + let l:hhconfig = ale#path#FindNearestFile(a:buffer, '.hhconfig') + + if empty(l:hhconfig) + return '' + endif + + let l:root = fnamemodify(l:hhconfig, ':h') + let l:hhast_config = findfile('hhast-lint.json', l:root) + + return !empty(l:hhast_config) ? l:root : '' +endfunction + +function! ale_linters#hack#hhast#GetExecutable(buffer) abort + let l:root = ale_linters#hack#hhast#GetProjectRoot(a:buffer) + let l:relative = ale#Var(a:buffer, 'hack_hhast_executable') + let l:absolute = findfile(l:relative, l:root) + + return !empty(l:absolute) ? l:absolute : '' +endfunction + +function! ale_linters#hack#hhast#GetInitializationOptions(buffer) abort + return {'lintMode': 'open-files'} +endfunction + +call ale#linter#Define('hack', { +\ 'name': 'hhast', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#hack#hhast#GetExecutable'), +\ 'command': '%e --mode lsp --from vim-ale', +\ 'project_root': function('ale_linters#hack#hhast#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#hack#hhast#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/haml/hamllint.vim b/sources_non_forked/ale/ale_linters/haml/hamllint.vim new file mode 100644 index 00000000..9fcd999f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haml/hamllint.vim @@ -0,0 +1,57 @@ +" Author: Patrick Lewis - https://github.com/patricklewis, thenoseman - https://github.com/thenoseman +" Description: haml-lint for Haml files + +call ale#Set('haml_hamllint_executable', 'haml-lint') + +function! ale_linters#haml#hamllint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'haml_hamllint_executable') +endfunction + +function! ale_linters#haml#hamllint#GetCommand(buffer) abort + let l:prefix = '' + + let l:rubocop_config_file_path = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') + let l:hamllint_config_file_path = ale#path#FindNearestFile(a:buffer, '.haml-lint.yml') + + " Set HAML_LINT_RUBOCOP_CONF variable as it is needed for haml-lint to + " pick up the rubocop config. + " + " See https://github.com/brigade/haml-lint/blob/master/lib/haml_lint/linter/rubocop.rb#L89 + " HamlLint::Linter::RuboCop#rubocop_flags + if !empty(l:rubocop_config_file_path) + if has('win32') + let l:prefix = 'set HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path) . ' &&' + else + let l:prefix = 'HAML_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config_file_path) + endif + endif + + return (!empty(l:prefix) ? l:prefix . ' ' : '') + \ . ale_linters#haml#hamllint#GetExecutable(a:buffer) + \ . (!empty(l:hamllint_config_file_path) ? ' --config ' . ale#Escape(l:hamllint_config_file_path) : '') + \ . ' %t' +endfunction + +function! ale_linters#haml#hamllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " :51 [W] RuboCop: Use the new Ruby 1.9 hash syntax. + let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2], + \ 'text': l:match[3] + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('haml', { +\ 'name': 'hamllint', +\ 'executable': function('ale_linters#haml#hamllint#GetExecutable'), +\ 'command': function('ale_linters#haml#hamllint#GetCommand'), +\ 'callback': 'ale_linters#haml#hamllint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim new file mode 100644 index 00000000..17c4d08e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/handlebars/embertemplatelint.vim @@ -0,0 +1,67 @@ +" Author: Adrian Zalewski +" Description: Ember-template-lint for checking Handlebars files + +call ale#Set('handlebars_embertemplatelint_executable', 'ember-template-lint') +call ale#Set('handlebars_embertemplatelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#handlebars#embertemplatelint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'handlebars_embertemplatelint', [ + \ 'node_modules/.bin/ember-template-lint', + \]) +endfunction + +function! ale_linters#handlebars#embertemplatelint#GetCommand(buffer, version) abort + if ale#semver#GTE(a:version, [4, 0, 0]) + " --json was removed in favor of --format=json in ember-template-lint@4.0.0 + return '%e --format=json --filename %s' + endif + + if ale#semver#GTE(a:version, [1, 6, 0]) + " Reading from stdin was introduced in ember-template-lint@1.6.0 + return '%e --json --filename %s' + endif + + return '%e --json %t' +endfunction + +function! ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck(buffer) abort + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ ale_linters#handlebars#embertemplatelint#GetExecutable(a:buffer), + \ '%e --version', + \ function('ale_linters#handlebars#embertemplatelint#GetCommand'), + \) +endfunction + +function! ale_linters#handlebars#embertemplatelint#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + for l:error in get(values(l:json), 0, []) + if has_key(l:error, 'fatal') + call add(l:output, { + \ 'lnum': get(l:error, 'line', 1), + \ 'col': get(l:error, 'column', 1), + \ 'text': l:error.message, + \ 'type': l:error.severity == 1 ? 'W' : 'E', + \}) + else + call add(l:output, { + \ 'lnum': l:error.line, + \ 'col': l:error.column, + \ 'text': l:error.rule . ': ' . l:error.message, + \ 'type': l:error.severity == 1 ? 'W' : 'E', + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('handlebars', { +\ 'name': 'embertemplatelint', +\ 'aliases': ['ember-template-lint'], +\ 'executable': function('ale_linters#handlebars#embertemplatelint#GetExecutable'), +\ 'command': function('ale_linters#handlebars#embertemplatelint#GetCommandWithVersionCheck'), +\ 'callback': 'ale_linters#handlebars#embertemplatelint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim new file mode 100644 index 00000000..1bb31ebb --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/cabal_ghc.vim @@ -0,0 +1,20 @@ +" Author: Eric Wolf +" Description: ghc for Haskell files called with cabal exec + +call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0') + +function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort + return 'cabal exec -- ghc ' + \ . ale#Var(a:buffer, 'haskell_cabal_ghc_options') + \ . ' %t' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'cabal_ghc', +\ 'aliases': ['cabal-ghc'], +\ 'output_stream': 'stderr', +\ 'executable': 'cabal', +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'), +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/cspell.vim b/sources_non_forked/ale/ale_linters/haskell/cspell.vim new file mode 100644 index 00000000..b0971a9e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Haskell files. + +call ale#handlers#cspell#DefineLinter('haskell') diff --git a/sources_non_forked/ale/ale_linters/haskell/ghc.vim b/sources_non_forked/ale/ale_linters/haskell/ghc.vim new file mode 100644 index 00000000..9c3906b2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/ghc.vim @@ -0,0 +1,18 @@ +" Author: w0rp +" Description: ghc for Haskell files + +call ale#Set('haskell_ghc_options', '-fno-code -v0') + +function! ale_linters#haskell#ghc#GetCommand(buffer) abort + return 'ghc ' + \ . ale#Var(a:buffer, 'haskell_ghc_options') + \ . ' %t' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'ghc', +\ 'output_stream': 'stderr', +\ 'executable': 'ghc', +\ 'command': function('ale_linters#haskell#ghc#GetCommand'), +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim b/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim new file mode 100644 index 00000000..30e96b40 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/ghc_mod.vim @@ -0,0 +1,19 @@ +" Author: wizzup +" Description: ghc-mod for Haskell files + +call ale#Set('haskell_ghc_mod_executable', 'ghc-mod') + +function! ale_linters#haskell#ghc_mod#GetCommand (buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_ghc_mod_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'ghc-mod') + \ . ' --map-file %s=%t check %s' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'ghc_mod', +\ 'aliases': ['ghc-mod'], +\ 'executable': {b -> ale#Var(b, 'haskell_ghc_mod_executable')}, +\ 'command': function('ale_linters#haskell#ghc_mod#GetCommand'), +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim new file mode 100644 index 00000000..3e55e4f0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hdevtools.vim @@ -0,0 +1,20 @@ +" Author: rob-b, Takano Akio +" Description: hdevtools for Haskell files + +call ale#Set('haskell_hdevtools_executable', 'hdevtools') +call ale#Set('haskell_hdevtools_options', get(g:, 'hdevtools_options', '-g -Wall')) + +function! ale_linters#haskell#hdevtools#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hdevtools_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hdevtools') + \ . ' check' . ale#Pad(ale#Var(a:buffer, 'haskell_hdevtools_options')) + \ . ' -p %s %t' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hdevtools', +\ 'executable': {b -> ale#Var(b, 'haskell_hdevtools_executable')}, +\ 'command': function('ale_linters#haskell#hdevtools#GetCommand'), +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hie.vim b/sources_non_forked/ale/ale_linters/haskell/hie.vim new file mode 100644 index 00000000..c4b5f1df --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hie.vim @@ -0,0 +1,41 @@ +" Author: Luxed +" Description: A language server for Haskell + +call ale#Set('haskell_hie_executable', 'hie') + +function! ale_linters#haskell#hie#GetProjectRoot(buffer) abort + " Search for the stack file first + let l:project_file = ale#path#FindNearestFile(a:buffer, 'stack.yaml') + + " If it's empty, search for the cabal file + if empty(l:project_file) + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) + let l:project_file = globpath(l:paths, '*.cabal') + endif + + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') + endif + + return fnamemodify(l:project_file, ':h') +endfunction + +function! ale_linters#haskell#hie#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hie_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hie') + \ . ' --lsp' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hie', +\ 'lsp': 'stdio', +\ 'command': function('ale_linters#haskell#hie#GetCommand'), +\ 'executable': {b -> ale#Var(b, 'haskell_hie_executable')}, +\ 'project_root': function('ale_linters#haskell#hie#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hlint.vim b/sources_non_forked/ale/ale_linters/haskell/hlint.vim new file mode 100644 index 00000000..1425251a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hlint.vim @@ -0,0 +1,46 @@ +" Author: jparoz +" Description: hlint for Haskell files + +call ale#Set('haskell_hlint_executable', 'hlint') +call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', '')) + +function! ale_linters#haskell#hlint#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if l:error.severity is# 'Error' + let l:type = 'E' + elseif l:error.severity is# 'Suggestion' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': str2nr(l:error.startLine), + \ 'col': str2nr(l:error.startColumn), + \ 'end_lnum': str2nr(l:error.endLine), + \ 'end_col': str2nr(l:error.endColumn), + \ 'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#haskell#hlint#GetCommand(buffer) abort + let l:hlintopts = '--color=never --json' + + return ale#handlers#hlint#GetExecutable(a:buffer) + \ . ' ' . ale#Var(a:buffer, 'haskell_hlint_options') + \ . ' ' . l:hlintopts + \ . ' -' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hlint', +\ 'executable': {b -> ale#Var(b, 'haskell_hlint_executable')}, +\ 'command': function('ale_linters#haskell#hlint#GetCommand') , +\ 'callback': 'ale_linters#haskell#hlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/hls.vim b/sources_non_forked/ale/ale_linters/haskell/hls.vim new file mode 100644 index 00000000..7f9efc38 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/hls.vim @@ -0,0 +1,65 @@ +" Author: Yen3 +" Description: A language server for haskell +" The file is based on hie.vim (author: Luxed +" ). It search more project root files. +" +call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper') +call ale#Set('haskell_hls_config', {}) + +function! ale_linters#haskell#hls#FindRootFile(buffer) abort + let l:serach_root_files = [ + \ 'stack.yaml', + \ 'cabal.project', + \ 'package.yaml', + \ 'hie.yaml' + \ ] + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:root_file in l:serach_root_files + if filereadable(l:path . l:root_file) + return l:path + endif + endfor + endfor + + return '' +endfunction + +function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort + " Search for the project file first + let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer) + + " If it's empty, search for the cabal file + if empty(l:project_file) + " Search all of the paths except for the root filesystem path. + let l:paths = join( + \ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2], + \ ',' + \) + let l:project_file = globpath(l:paths, '*.cabal') + endif + + " If we still can't find one, use the current file. + if empty(l:project_file) + let l:project_file = expand('#' . a:buffer . ':p') + endif + + return fnamemodify(l:project_file, ':h') +endfunction + +function! ale_linters#haskell#hls#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hls_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, + \ 'haskell-language-server-wrapper') + \ . ' --lsp' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'hls', +\ 'lsp': 'stdio', +\ 'command': function('ale_linters#haskell#hls#GetCommand'), +\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')}, +\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'haskell_hls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_build.vim b/sources_non_forked/ale/ale_linters/haskell/stack_build.vim new file mode 100644 index 00000000..8f2d9fd9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/stack_build.vim @@ -0,0 +1,23 @@ +" Author: Jake Zimmerman +" Description: Like stack-ghc, but for entire projects +" +" Note: Ideally, this would *only* typecheck. Right now, it also does codegen. +" See . + +call ale#Set('haskell_stack_build_options', '--fast') + +function! ale_linters#haskell#stack_build#GetCommand(buffer) abort + let l:flags = ale#Var(a:buffer, 'haskell_stack_build_options') + + return 'stack build ' . l:flags +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'stack_build', +\ 'aliases': ['stack-build'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'command': function('ale_linters#haskell#stack_build#GetCommand'), +\ 'lint_file': 1, +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim new file mode 100644 index 00000000..51ecc744 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/haskell/stack_ghc.vim @@ -0,0 +1,21 @@ +" Author: w0rp +" Description: ghc for Haskell files, using Stack + +call ale#Set('haskell_stack_ghc_options', '-fno-code -v0') + +function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort + return ale#handlers#haskell#GetStackExecutable(a:buffer) + \ . ' ghc -- ' + \ . ale#Var(a:buffer, 'haskell_stack_ghc_options') + \ . ' %t' +endfunction + +call ale#linter#Define('haskell', { +\ 'name': 'stack_ghc', +\ 'aliases': ['stack-ghc'], +\ 'output_stream': 'stderr', +\ 'executable': function('ale#handlers#haskell#GetStackExecutable'), +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'), +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/help/alex.vim b/sources_non_forked/ale/ale_linters/help/alex.vim new file mode 100644 index 00000000..9be00a82 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/help/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for help files + +call ale#handlers#alex#DefineLinter('help', '--text') diff --git a/sources_non_forked/ale/ale_linters/help/cspell.vim b/sources_non_forked/ale/ale_linters/help/cspell.vim new file mode 100644 index 00000000..92eb9501 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/help/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for help files. + +call ale#handlers#cspell#DefineLinter('help') diff --git a/sources_non_forked/ale/ale_linters/help/proselint.vim b/sources_non_forked/ale/ale_linters/help/proselint.vim new file mode 100644 index 00000000..62124502 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/help/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for Vim help files + +call ale#linter#Define('help', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/help/writegood.vim b/sources_non_forked/ale/ale_linters/help/writegood.vim new file mode 100644 index 00000000..eeb21a73 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/help/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for vim Help files + +call ale#handlers#writegood#DefineLinter('help') diff --git a/sources_non_forked/ale/ale_linters/html/alex.vim b/sources_non_forked/ale/ale_linters/html/alex.vim new file mode 100644 index 00000000..97756753 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for HTML files + +call ale#handlers#alex#DefineLinter('html', '--html') diff --git a/sources_non_forked/ale/ale_linters/html/angular.vim b/sources_non_forked/ale/ale_linters/html/angular.vim new file mode 100644 index 00000000..4f368fb4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/angular.vim @@ -0,0 +1,56 @@ +" Author: w0rp +" Description: tsserver integration for ALE + +call ale#Set('html_angular_executable', 'ngserver') +call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#html#angular#GetProjectRoot(buffer) abort + return ale#path#Dirname( + \ ale#path#FindNearestDirectory(a:buffer, 'node_modules') + \) +endfunction + +function! ale_linters#html#angular#GetExecutable(buffer) abort + return 'node' +endfunction + +function! ale_linters#html#angular#GetCommand(buffer) abort + let l:language_service_dir = ale#path#Simplify( + \ ale#path#FindNearestDirectory( + \ a:buffer, + \ 'node_modules/@angular/language-service' + \ ) + \) + + if empty(l:language_service_dir) + return '' + endif + + let l:language_service_dir = fnamemodify(l:language_service_dir, ':h') + let l:typescript_dir = ale#path#Simplify( + \ fnamemodify(l:language_service_dir, ':h:h') + \ . '/typescript' + \) + let l:script = ale#path#FindExecutable(a:buffer, 'html_angular', [ + \ 'node_modules/@angular/language-server/bin/ngserver', + \ 'node_modules/@angular/language-server/index.js', + \]) + + if !filereadable(l:script) + return '' + endif + + return ale#Escape('node') . ' ' . ale#Escape(l:script) + \ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir) + \ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir) + \ . ' --stdio' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'angular', +\ 'aliases': ['angular-language-server'], +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#html#angular#GetExecutable'), +\ 'command': function('ale_linters#html#angular#GetCommand'), +\ 'project_root': function('ale_linters#html#angular#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/html/cspell.vim b/sources_non_forked/ale/ale_linters/html/cspell.vim new file mode 100644 index 00000000..743350ea --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for HTML files. + +call ale#handlers#cspell#DefineLinter('html') diff --git a/sources_non_forked/ale/ale_linters/html/fecs.vim b/sources_non_forked/ale/ale_linters/html/fecs.vim new file mode 100644 index 00000000..15e00e12 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/fecs.vim @@ -0,0 +1,9 @@ +" Author: harttle +" Description: fecs for HTMl files + +call ale#linter#Define('html', { +\ 'name': 'fecs', +\ 'executable': function('ale#handlers#fecs#GetExecutable'), +\ 'command': function('ale#handlers#fecs#GetCommand'), +\ 'callback': 'ale#handlers#fecs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/htmlhint.vim b/sources_non_forked/ale/ale_linters/html/htmlhint.vim new file mode 100644 index 00000000..25bf5137 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/htmlhint.vim @@ -0,0 +1,32 @@ +" Author: KabbAmine , deathmaz <00maz1987@gmail.com>, diartyz +" Description: HTMLHint for checking html files + +call ale#Set('html_htmlhint_options', '') +call ale#Set('html_htmlhint_executable', 'htmlhint') +call ale#Set('html_htmlhint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#html#htmlhint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'html_htmlhint_options') + let l:config = l:options !~# '--config' + \ ? ale#path#FindNearestFile(a:buffer, '.htmlhintrc') + \ : '' + + if !empty(l:config) + let l:options .= ' --config ' . ale#Escape(l:config) + endif + + if !empty(l:options) + let l:options = substitute(l:options, '--format=unix', '', '') + endif + + return '%e' . ale#Pad(l:options) . ' --format=unix %t' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'htmlhint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'html_htmlhint', [ +\ 'node_modules/.bin/htmlhint', +\ ])}, +\ 'command': function('ale_linters#html#htmlhint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/proselint.vim b/sources_non_forked/ale/ale_linters/html/proselint.vim new file mode 100644 index 00000000..9fd7d671 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for HTML files + +call ale#linter#Define('html', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/stylelint.vim b/sources_non_forked/ale/ale_linters/html/stylelint.vim new file mode 100644 index 00000000..6b7aba40 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/stylelint.vim @@ -0,0 +1,27 @@ +" Author: Filipe Kiss http://github.com/filipekiss + +call ale#Set('html_stylelint_executable', 'stylelint') +call ale#Set('html_stylelint_options', '') +call ale#Set('html_stylelint_use_global', 0) + +function! ale_linters#html#stylelint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'html_stylelint', [ + \ 'node_modules/.bin/stylelint', + \]) +endfunction + +function! ale_linters#html#stylelint#GetCommand(buffer) abort + let l:executable = ale_linters#html#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'html_stylelint_options') + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'stylelint', +\ 'executable': function('ale_linters#html#stylelint#GetExecutable'), +\ 'command': function('ale_linters#html#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/html/tidy.vim b/sources_non_forked/ale/ale_linters/html/tidy.vim new file mode 100644 index 00000000..1e476d40 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/tidy.vim @@ -0,0 +1,70 @@ +" Author: KabbAmine +" Description: This file adds support for checking HTML code with tidy. + +let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy') +let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', '-q -e -language en') + +function! ale_linters#html#tidy#GetCommand(buffer) abort + " Specify file encoding in options + " (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim) + let l:file_encoding = get({ + \ 'ascii': '-ascii', + \ 'big5': '-big5', + \ 'cp1252': '-win1252', + \ 'cp850': '-ibm858', + \ 'cp932': '-shiftjis', + \ 'iso-2022-jp': '-iso-2022', + \ 'latin1': '-latin1', + \ 'macroman': '-mac', + \ 'sjis': '-shiftjis', + \ 'utf-16le': '-utf16le', + \ 'utf-16': '-utf16', + \ 'utf-8': '-utf8', + \ }, &fileencoding, '-utf8') + + " On macOS, old tidy (released on 31 Oct 2006) is installed. It does not + " consider HTML5 so we should avoid it. + let l:executable = ale#Var(a:buffer, 'html_tidy_executable') + + if has('mac') && l:executable is# 'tidy' && exists('*exepath') + \ && exepath(l:executable) is# '/usr/bin/tidy' + return '' + endif + + return printf('%s %s %s -', + \ l:executable, + \ ale#Var(a:buffer, 'html_tidy_options'), + \ l:file_encoding + \) +endfunction + +function! ale_linters#html#tidy#Handle(buffer, lines) abort + " Matches patterns lines like the following: + " line 7 column 5 - Warning: missing before + let l:pattern = '^line \(\d\+\) column \(\d\+\) - \(Warning\|Error\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:line = l:match[1] + 0 + let l:col = l:match[2] + 0 + let l:type = l:match[3] is# 'Error' ? 'E' : 'W' + let l:text = l:match[4] + + call add(l:output, { + \ 'lnum': l:line, + \ 'col': l:col, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('html', { +\ 'name': 'tidy', +\ 'executable': {b -> ale#Var(b, 'html_tidy_executable')}, +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#html#tidy#GetCommand'), +\ 'callback': 'ale_linters#html#tidy#Handle', +\ }) diff --git a/sources_non_forked/ale/ale_linters/html/vscodehtml.vim b/sources_non_forked/ale/ale_linters/html/vscodehtml.vim new file mode 100644 index 00000000..46814a0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/vscodehtml.vim @@ -0,0 +1,16 @@ +" Author: Dalius Dobravolskas +" Description: VSCode html language server + +function! ale_linters#html#vscodehtml#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('html', { +\ 'name': 'vscodehtml', +\ 'lsp': 'stdio', +\ 'executable': 'vscode-html-language-server', +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#html#vscodehtml#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/html/writegood.vim b/sources_non_forked/ale/ale_linters/html/writegood.vim new file mode 100644 index 00000000..6a2bd8e5 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/html/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for html files + +call ale#handlers#writegood#DefineLinter('html') diff --git a/sources_non_forked/ale/ale_linters/idris/idris.vim b/sources_non_forked/ale/ale_linters/idris/idris.vim new file mode 100644 index 00000000..879e92f2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/idris/idris.vim @@ -0,0 +1,81 @@ +" Author: Scott Bonds +" Description: default Idris compiler + +call ale#Set('idris_idris_executable', 'idris') +call ale#Set('idris_idris_options', '--total --warnpartial --warnreach --warnipkg') + +function! ale_linters#idris#idris#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'idris_idris_options') + + return '%e' . ale#Pad(l:options) . ' --check %s' +endfunction + +function! ale_linters#idris#idris#Handle(buffer, lines) abort + " This was copied almost verbatim from ale#handlers#haskell#HandleGHCFormat + " + " Look for lines like the following: + " foo.idr:2:6:When checking right hand side of main with expected type + " bar.idr:11:11-13: + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)(-\d+)?:(.*)?$' + let l:output = [] + + let l:corrected_lines = [] + + for l:line in a:lines + if len(matchlist(l:line, l:pattern)) > 0 + call add(l:corrected_lines, l:line) + elseif len(l:corrected_lines) > 0 + if l:line is# '' + let l:corrected_lines[-1] .= ' ' " turn a blank line into a space + else + let l:corrected_lines[-1] .= l:line + endif + + let l:corrected_lines[-1] = substitute(l:corrected_lines[-1], '\s\+', ' ', 'g') + endif + endfor + + for l:line in l:corrected_lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + if !ale#path#IsBufferPath(a:buffer, l:match[1]) + continue + endif + + let l:errors = matchlist(l:match[5], '\v([wW]arning|[eE]rror) - ?(.*)') + + if len(l:errors) > 0 + let l:ghc_type = l:errors[1] + let l:text = l:errors[2] + else + let l:ghc_type = '' + let l:text = l:match[5][:0] is# ' ' ? l:match[5][1:] : l:match[5] + endif + + if l:ghc_type is? 'Warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('idris', { +\ 'name': 'idris', +\ 'executable': {b -> ale#Var(b, 'idris_idris_executable')}, +\ 'command': function('ale_linters#idris#idris#GetCommand'), +\ 'callback': 'ale_linters#idris#idris#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ink/ls.vim b/sources_non_forked/ale/ale_linters/ink/ls.vim new file mode 100644 index 00000000..00b2f323 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ink/ls.vim @@ -0,0 +1,35 @@ +" Author: Andreww Hayworth +" Description: Integrate ALE with ink-language-server + +call ale#Set('ink_ls_executable', 'ink-language-server') +call ale#Set('ink_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('ink_ls_initialization_options', {}) + +function! ale_linters#ink#ls#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'ink_ls', [ + \ 'ink-language-server', + \ 'node_modules/.bin/ink-language-server', + \]) +endfunction + +function! ale_linters#ink#ls#GetCommand(buffer) abort + let l:executable = ale_linters#ink#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#ink#ls#FindProjectRoot(buffer) abort + let l:main_file = get(ale#Var(a:buffer, 'ink_ls_initialization_options'), 'mainStoryPath', 'main.ink') + let l:config = ale#path#ResolveLocalPath(a:buffer, l:main_file, expand('#' . a:buffer . ':p')) + + return ale#path#Dirname(l:config) +endfunction + +call ale#linter#Define('ink', { +\ 'name': 'ink-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#ink#ls#GetExecutable'), +\ 'command': function('ale_linters#ink#ls#GetCommand'), +\ 'project_root': function('ale_linters#ink#ls#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'ink_ls_initialization_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/inko/inko.vim b/sources_non_forked/ale/ale_linters/inko/inko.vim new file mode 100644 index 00000000..11558897 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/inko/inko.vim @@ -0,0 +1,33 @@ +" Author: Yorick Peterse +" Description: linting of Inko source code using the Inko compiler + +call ale#Set('inko_inko_executable', 'inko') + +function! ale_linters#inko#inko#GetCommand(buffer) abort + let l:include = '' + + " Include the tests source directory, but only for test files. + if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]' + let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests') + + if isdirectory(l:test_dir) + let l:include = '--include ' . ale#Escape(l:test_dir) + endif + endif + + " We use %s instead of %t so the compiler determines the correct module + " names for the file being edited. Not doing so may lead to errors in + " certain cases. + return '%e build --check --format=json' + \ . ale#Pad(l:include) + \ . ' %s' +endfunction + +call ale#linter#Define('inko', { +\ 'name': 'inko', +\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')}, +\ 'command': function('ale_linters#inko#inko#GetCommand'), +\ 'callback': 'ale#handlers#inko#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1 +\}) diff --git a/sources_non_forked/ale/ale_linters/ispc/ispc.vim b/sources_non_forked/ale/ale_linters/ispc/ispc.vim new file mode 100644 index 00000000..eb365117 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ispc/ispc.vim @@ -0,0 +1,45 @@ +" Author: Martino Pilia +" Description: Lint ispc files with the Intel(R) SPMD Program Compiler + +call ale#Set('ispc_ispc_executable', 'ispc') +call ale#Set('ispc_ispc_options', '') + +function! ale_linters#ispc#ispc#GetCommand(buffer) abort + " --nowrap: do not wrap message lines + return '%e --nowrap' + \ . ale#Pad(ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))) + \ . ale#Pad(ale#Var(a:buffer, 'ispc_ispc_options')) + \ . ' %s' +endfunction + +" Note that we ignore the two warnings in the beginning of the compiler output +" ('no output file specified' and 'no --target specified'), since they have +" nothing to do with linting. +function! ale_linters#ispc#ispc#Handle(buffer, lines) abort + " Message format: :: : + " As far as I know, can be any of: + " 'error', 'Error', 'fatal error', 'Warning', 'Performance Warning' + let l:re = '\v.+:([0-9]+):([0-9]+):\s+([^:]+):\s+(.+)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:re) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': l:match[3] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ispc', { +\ 'name': 'ispc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'ispc_ispc_executable')}, +\ 'command': function('ale_linters#ispc#ispc#GetCommand'), +\ 'callback': 'ale_linters#ispc#ispc#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/java/checkstyle.vim b/sources_non_forked/ale/ale_linters/java/checkstyle.vim new file mode 100644 index 00000000..1ccbc505 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/checkstyle.vim @@ -0,0 +1,73 @@ +" Author: Devon Meunier +" Description: checkstyle for Java files + +call ale#Set('java_checkstyle_executable', 'checkstyle') +call ale#Set('java_checkstyle_config', '/google_checks.xml') +call ale#Set('java_checkstyle_options', '') + +function! ale_linters#java#checkstyle#Handle(buffer, lines) abort + let l:output = [] + + " modern checkstyle versions + let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': l:match[1] is? 'WARN' ? 'W' : 'E', + \ 'sub_type': 'style', + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + if !empty(l:output) + return l:output + endif + + " old checkstyle versions + let l:pattern = '\v(.+):(\d+): ([^:]+): (.+)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': l:match[3] is? 'warning' ? 'W' : 'E', + \ 'sub_type': 'style', + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +function! s:GetConfig(buffer, config) abort + if ale#path#IsAbsolute(a:config) + return a:config + endif + + let s:file = ale#path#FindNearestFile(a:buffer, a:config) + + return !empty(s:file) ? s:file : a:config +endfunction + +function! ale_linters#java#checkstyle#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'java_checkstyle_options') + let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') + let l:config = l:options !~# '\v(^| )-c ' && !empty(l:config_option) + \ ? s:GetConfig(a:buffer, l:config_option) + \ : '' + + return '%e' + \ . ale#Pad(l:options) + \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') + \ . ' %s' +endfunction + +call ale#linter#Define('java', { +\ 'name': 'checkstyle', +\ 'executable': {b -> ale#Var(b, 'java_checkstyle_executable')}, +\ 'command': function('ale_linters#java#checkstyle#GetCommand'), +\ 'callback': 'ale_linters#java#checkstyle#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/java/cspell.vim b/sources_non_forked/ale/ale_linters/java/cspell.vim new file mode 100644 index 00000000..a6eecc0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Java files. + +call ale#handlers#cspell#DefineLinter('java') diff --git a/sources_non_forked/ale/ale_linters/java/eclipselsp.vim b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim new file mode 100644 index 00000000..ad7cbeb4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/eclipselsp.vim @@ -0,0 +1,200 @@ +" Author: Horacio Sanson +" Description: Support for the Eclipse language server https://github.com/eclipse/eclipse.jdt.ls + +let s:version_cache = {} + +call ale#Set('java_eclipselsp_path', ale#path#Simplify($HOME . '/eclipse.jdt.ls')) +call ale#Set('java_eclipselsp_config_path', '') +call ale#Set('java_eclipselsp_workspace_path', '') +call ale#Set('java_eclipselsp_executable', 'java') +call ale#Set('java_eclipselsp_javaagent', '') + +function! ale_linters#java#eclipselsp#Executable(buffer) abort + return ale#Var(a:buffer, 'java_eclipselsp_executable') +endfunction + +function! ale_linters#java#eclipselsp#TargetPath(buffer) abort + return ale#Var(a:buffer, 'java_eclipselsp_path') +endfunction + +function! ale_linters#java#eclipselsp#JarPath(buffer) abort + let l:path = ale_linters#java#eclipselsp#TargetPath(a:buffer) + + if has('win32') + let l:platform = 'win32' + elseif has('macunix') + let l:platform = 'macosx' + else + let l:platform = 'linux' + endif + + " Search jar file within repository path when manually built using mvn + let l:files = globpath(l:path, '**/'.l:platform.'/**/plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 + return l:files[0] + endif + + " Search jar file within VSCode extensions folder. + let l:files = globpath(l:path, '**/'.l:platform.'/plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 + return l:files[0] + endif + + " Search jar file within unzipped tar.gz file + let l:files = globpath(l:path, 'plugins/org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 + return l:files[0] + endif + + " Search jar file within system package path + let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_*\.jar', 1, 1) + + if len(l:files) >= 1 + return l:files[0] + endif + + return '' +endfunction + +function! ale_linters#java#eclipselsp#ConfigurationPath(buffer) abort + let l:path = fnamemodify(ale_linters#java#eclipselsp#JarPath(a:buffer), ':p:h:h') + let l:config_path = ale#Var(a:buffer, 'java_eclipselsp_config_path') + + if !empty(l:config_path) + return ale#path#Simplify(l:config_path) + endif + + if has('win32') + let l:path = l:path . '/config_win' + elseif has('macunix') + let l:path = l:path . '/config_mac' + else + let l:path = l:path . '/config_linux' + endif + + return ale#path#Simplify(l:path) +endfunction + +function! ale_linters#java#eclipselsp#VersionCheck(version_lines) abort + return s:GetVersion('', a:version_lines) +endfunction + +function! s:GetVersion(executable, version_lines) abort + let l:version = [] + + for l:line in a:version_lines + let l:match = matchlist(l:line, '\(\d\+\)\.\(\d\+\)\.\(\d\+\)') + + if !empty(l:match) + let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[3] + 0] + let s:version_cache[a:executable] = l:version + break + endif + endfor + + return l:version +endfunction + +function! ale_linters#java#eclipselsp#CommandWithVersion(buffer, version_lines, meta) abort + let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) + let l:version = s:GetVersion(l:executable, a:version_lines) + + return ale_linters#java#eclipselsp#Command(a:buffer, l:version) +endfunction + +function! ale_linters#java#eclipselsp#WorkspacePath(buffer) abort + let l:wspath = ale#Var(a:buffer, 'java_eclipselsp_workspace_path') + + if !empty(l:wspath) + return l:wspath + endif + + return ale#path#Dirname(ale#java#FindProjectRoot(a:buffer)) +endfunction + +function! ale_linters#java#eclipselsp#Javaagent(buffer) abort + let l:rets = [] + let l:raw = ale#Var(a:buffer, 'java_eclipselsp_javaagent') + + if empty(l:raw) + return '' + endif + + let l:jars = split(l:raw) + + for l:jar in l:jars + call add(l:rets, ale#Escape('-javaagent:' . l:jar)) + endfor + + return join(l:rets, ' ') +endfunction + +function! ale_linters#java#eclipselsp#Command(buffer, version) abort + let l:path = ale#Var(a:buffer, 'java_eclipselsp_path') + + let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) + + let l:cmd = [ ale#Escape(l:executable), + \ ale_linters#java#eclipselsp#Javaagent(a:buffer), + \ '-Declipse.application=org.eclipse.jdt.ls.core.id1', + \ '-Dosgi.bundles.defaultStartLevel=4', + \ '-Declipse.product=org.eclipse.jdt.ls.core.product', + \ '-Dlog.level=ALL', + \ '-noverify', + \ '-Xmx1G', + \ '-jar', + \ ale#Escape(ale_linters#java#eclipselsp#JarPath(a:buffer)), + \ '-configuration', + \ ale#Escape(ale_linters#java#eclipselsp#ConfigurationPath(a:buffer)), + \ '-data', + \ ale#Escape(ale_linters#java#eclipselsp#WorkspacePath(a:buffer)) + \ ] + + if ale#semver#GTE(a:version, [1, 9]) + call add(l:cmd, '--add-modules=ALL-SYSTEM') + call add(l:cmd, '--add-opens java.base/java.util=ALL-UNNAMED') + call add(l:cmd, '--add-opens java.base/java.lang=ALL-UNNAMED') + endif + + return join(l:cmd, ' ') +endfunction + +function! ale_linters#java#eclipselsp#RunWithVersionCheck(buffer) abort + let l:executable = ale_linters#java#eclipselsp#Executable(a:buffer) + + if empty(l:executable) + return '' + endif + + let l:cache = s:version_cache + + if has_key(s:version_cache, l:executable) + return ale_linters#java#eclipselsp#Command(a:buffer, s:version_cache[l:executable]) + endif + + let l:command = ale#Escape(l:executable) . ' -version' + + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#java#eclipselsp#CommandWithVersion'), + \ { 'output_stream': 'both' } + \) +endfunction + +call ale#linter#Define('java', { +\ 'name': 'eclipselsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#java#eclipselsp#Executable'), +\ 'command': function('ale_linters#java#eclipselsp#RunWithVersionCheck'), +\ 'language': 'java', +\ 'project_root': function('ale#java#FindProjectRoot'), +\ 'initialization_options': { +\ 'extendedClientCapabilities': { +\ 'classFileContentsSupport': v:true +\ } +\ } +\}) diff --git a/sources_non_forked/ale/ale_linters/java/javac.vim b/sources_non_forked/ale/ale_linters/java/javac.vim new file mode 100644 index 00000000..971e8de0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/javac.vim @@ -0,0 +1,163 @@ +" Author: farenjihn , w0rp +" Description: Lints java files using javac + +let s:classpath_sep = has('unix') ? ':' : ';' + +call ale#Set('java_javac_executable', 'javac') +call ale#Set('java_javac_options', '') +call ale#Set('java_javac_classpath', '') +call ale#Set('java_javac_sourcepath', '') + +function! ale_linters#java#javac#RunWithImportPaths(buffer) abort + let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) + + " Try to use Gradle if Maven isn't available. + if empty(l:command) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) + endif + + " Try to use Ant if Gradle and Maven aren't available + if empty(l:command) + let [l:cwd, l:command] = ale#ant#BuildClasspathCommand(a:buffer) + endif + + if empty(l:command) + return ale_linters#java#javac#GetCommand(a:buffer, [], {}) + endif + + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#java#javac#GetCommand'), + \ {'cwd': l:cwd}, + \) +endfunction + +function! s:BuildClassPathOption(buffer, import_paths) abort + " Filter out lines like [INFO], etc. + let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''') + let l:cls_path = ale#Var(a:buffer, 'java_javac_classpath') + + if !empty(l:cls_path) && type(l:cls_path) is v:t_string + call extend(l:class_paths, split(l:cls_path, s:classpath_sep)) + endif + + if !empty(l:cls_path) && type(l:cls_path) is v:t_list + call extend(l:class_paths, l:cls_path) + endif + + return !empty(l:class_paths) + \ ? '-cp ' . ale#Escape(join(l:class_paths, s:classpath_sep)) + \ : '' +endfunction + +function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort + let l:cp_option = s:BuildClassPathOption(a:buffer, a:import_paths) + let l:sp_option = '' + + " Find the src directory, for files in this project. + let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java') + let l:sp_dirs = [] + + if !empty(l:src_dir) + call add(l:sp_dirs, l:src_dir) + + " Automatically include the jaxb directory too, if it's there. + let l:jaxb_dir = fnamemodify(l:src_dir, ':h:h') + \ . (has('win32') ? '\jaxb\' : '/jaxb/') + + if isdirectory(l:jaxb_dir) + call add(l:sp_dirs, l:jaxb_dir) + endif + endif + + " Automatically include the test directory, but only for test code. + if expand('#' . a:buffer . ':p') =~? '\vsrc[/\\]test[/\\]java' + let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'src/test/java') + + if isdirectory(l:test_dir) + call add(l:sp_dirs, l:test_dir) + endif + endif + + let l:source_paths = [] + let l:source_path = ale#Var(a:buffer, 'java_javac_sourcepath') + + if !empty(l:source_path) && type(l:source_path) is v:t_string + let l:source_paths = split(l:source_path, s:classpath_sep) + endif + + if !empty(l:source_path) && type(l:source_path) is v:t_list + let l:source_paths = l:source_path + endif + + if !empty(l:source_paths) + for l:path in l:source_paths + let l:sp_path = ale#path#FindNearestDirectory(a:buffer, l:path) + + if !empty(l:sp_path) + call add(l:sp_dirs, l:sp_path) + endif + endfor + endif + + if !empty(l:sp_dirs) + let l:sp_option = '-sourcepath ' + \ . ale#Escape(join(l:sp_dirs, s:classpath_sep)) + endif + + " Create .class files in a temporary directory, which we will delete later. + let l:class_file_directory = ale#command#CreateDirectory(a:buffer) + + " Always run javac from the directory the file is in, so we can resolve + " relative paths correctly. + return '%e -Xlint' + \ . ale#Pad(l:cp_option) + \ . ale#Pad(l:sp_option) + \ . ' -d ' . ale#Escape(l:class_file_directory) + \ . ale#Pad(ale#Var(a:buffer, 'java_javac_options')) + \ . ' %t' +endfunction + +function! ale_linters#java#javac#Handle(buffer, lines) abort + " Look for lines like the following. + " + " Main.java:13: warning: [deprecation] donaught() in Testclass has been deprecated + " Main.java:16: error: ';' expected + let l:directory = expand('#' . a:buffer . ':p:h') + let l:pattern = '\v^(.*):(\d+): (.{-1,}):(.+)$' + let l:col_pattern = '\v^(\s*\^)$' + let l:symbol_pattern = '\v^ +symbol: *(class|method) +([^ ]+)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:col_pattern, l:symbol_pattern]) + if empty(l:match[2]) && empty(l:match[3]) + if !empty(l:match[1]) && !empty(l:output) + let l:output[-1].col = len(l:match[1]) + endif + elseif empty(l:match[3]) + " Add symbols to 'cannot find symbol' errors. + if l:output[-1].text is# 'error: cannot find symbol' + let l:output[-1].text .= ': ' . l:match[2] + endif + else + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:directory, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[3] . ':' . l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('java', { +\ 'name': 'javac', +\ 'executable': {b -> ale#Var(b, 'java_javac_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#java#javac#RunWithImportPaths'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#java#javac#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/java/javalsp.vim b/sources_non_forked/ale/ale_linters/java/javalsp.vim new file mode 100644 index 00000000..baf584c8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/javalsp.vim @@ -0,0 +1,55 @@ +" Author: Horacio Sanson +" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac + +call ale#Set('java_javalsp_executable', '') +call ale#Set('java_javalsp_config', {}) + +function! ale_linters#java#javalsp#Executable(buffer) abort + return ale#Var(a:buffer, 'java_javalsp_executable') +endfunction + +function! ale_linters#java#javalsp#Config(buffer) abort + let l:defaults = { 'java': { 'classPath': [], 'externalDependencies': [] } } + let l:config = ale#Var(a:buffer, 'java_javalsp_config') + + " Ensure the config dictionary contains both classPath and + " externalDependencies keys to avoid a NPE crash on Java Language Server. + call extend(l:config, l:defaults, 'keep') + call extend(l:config['java'], l:defaults['java'], 'keep') + + return l:config +endfunction + +function! ale_linters#java#javalsp#Command(buffer) abort + let l:executable = ale_linters#java#javalsp#Executable(a:buffer) + + if fnamemodify(l:executable, ':t') is# 'java' + " For backward compatibility. + let l:cmd = [ + \ ale#Escape(l:executable), + \ '--add-exports jdk.compiler/com.sun.tools.javac.api=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.code=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.comp=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.main=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.tree=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.model=javacs', + \ '--add-exports jdk.compiler/com.sun.tools.javac.util=javacs', + \ '--add-opens jdk.compiler/com.sun.tools.javac.api=javacs', + \ '-m javacs/org.javacs.Main', + \] + + return join(l:cmd, ' ') + else + return ale#Escape(l:executable) + endif +endfunction + +call ale#linter#Define('java', { +\ 'name': 'javalsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#java#javalsp#Executable'), +\ 'command': function('ale_linters#java#javalsp#Command'), +\ 'language': 'java', +\ 'project_root': function('ale#java#FindProjectRoot'), +\ 'lsp_config': function('ale_linters#java#javalsp#Config') +\}) diff --git a/sources_non_forked/ale/ale_linters/java/pmd.vim b/sources_non_forked/ale/ale_linters/java/pmd.vim new file mode 100644 index 00000000..a1f4c93c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/java/pmd.vim @@ -0,0 +1,36 @@ +" Author: Johannes Wienke +" Description: PMD for Java files + +function! ale_linters#java#pmd#Handle(buffer, lines) abort + let l:pattern = '"\(\d\+\)",".*","\(.\+\)","\(\d\+\)","\(\d\+\)","\(.\+\)","\(.\+\)","\(.\+\)"$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'type': 'W', + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[5], + \ 'code': l:match[6] . ' - ' . l:match[7], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#java#pmd#GetCommand(buffer) abort + return 'pmd ' + \ . ale#Var(a:buffer, 'java_pmd_options') + \ . ' -f csv' + \ . ' -d %t' +endfunction + +if !exists('g:ale_java_pmd_options') + let g:ale_java_pmd_options = '-R category/java/bestpractices.xml' +endif + +call ale#linter#Define('java', { +\ 'name': 'pmd', +\ 'executable': 'pmd', +\ 'command': function('ale_linters#java#pmd#GetCommand'), +\ 'callback': 'ale_linters#java#pmd#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/cspell.vim b/sources_non_forked/ale/ale_linters/javascript/cspell.vim new file mode 100644 index 00000000..5a496779 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for JavaScript files. + +call ale#handlers#cspell#DefineLinter('javascript') diff --git a/sources_non_forked/ale/ale_linters/javascript/deno.vim b/sources_non_forked/ale/ale_linters/javascript/deno.vim new file mode 100644 index 00000000..659eb855 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/deno.vim @@ -0,0 +1,11 @@ +" Author: Arnold Chand +" Description: Deno lsp linter for JavaScript files. + +call ale#linter#Define('javascript', { +\ 'name': 'deno', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#deno#GetExecutable'), +\ 'command': '%e lsp', +\ 'project_root': function('ale#handlers#deno#GetProjectRoot'), +\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/eslint.vim b/sources_non_forked/ale/ale_linters/javascript/eslint.vim new file mode 100644 index 00000000..cf4de6ec --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/eslint.vim @@ -0,0 +1,11 @@ +" Author: w0rp +" Description: eslint for JavaScript files + +call ale#linter#Define('javascript', { +\ 'name': 'eslint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/fecs.vim b/sources_non_forked/ale/ale_linters/javascript/fecs.vim new file mode 100644 index 00000000..e47c0a0b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/fecs.vim @@ -0,0 +1,10 @@ +" Author: harttle +" Description: fecs for JavaScript files + +call ale#linter#Define('javascript', { +\ 'name': 'fecs', +\ 'executable': function('ale#handlers#fecs#GetExecutable'), +\ 'command': function('ale#handlers#fecs#GetCommand'), +\ 'read_buffer': 0, +\ 'callback': 'ale#handlers#fecs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/flow.vim b/sources_non_forked/ale/ale_linters/javascript/flow.vim new file mode 100644 index 00000000..601bac33 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/flow.vim @@ -0,0 +1,160 @@ +" Author: Zach Perrault -- @zperrault +" Author: Florian Beeres +" Description: FlowType checking for JavaScript files + +call ale#Set('javascript_flow_executable', 'flow') +call ale#Set('javascript_flow_use_home_config', 0) +call ale#Set('javascript_flow_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_flow_use_respect_pragma', 1) + +function! ale_linters#javascript#flow#GetExecutable(buffer) abort + let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') + + if empty(l:flow_config) + " Don't run Flow if we can't find a .flowconfig file. + return '' + endif + + " Don't run Flow with a configuration file from the home directory by + " default, which can eat all of your RAM. + if fnamemodify(l:flow_config, ':h') is? $HOME + \&& !ale#Var(a:buffer, 'javascript_flow_use_home_config') + return '' + endif + + return ale#path#FindExecutable(a:buffer, 'javascript_flow', [ + \ 'node_modules/.bin/flow', + \]) +endfunction + +function! ale_linters#javascript#flow#GetCommand(buffer, version) abort + " If we can parse the version number, then only use --respect-pragma + " if the version is >= 0.36.0, which added the argument. + let l:use_respect_pragma = ale#Var(a:buffer, 'javascript_flow_use_respect_pragma') + \ && (empty(a:version) || ale#semver#GTE(a:version, [0, 36])) + + return '%e check-contents' + \ . (l:use_respect_pragma ? ' --respect-pragma': '') + \ . ' --json --from ale %s < %t' + \ . (!has('win32') ? '; echo' : '') +endfunction + +" Filter lines of flow output until we find the first line where the JSON +" output starts. +function! s:GetJSONLines(lines) abort + let l:start_index = 0 + + for l:line in a:lines + if l:line[:0] is# '{' + break + endif + + let l:start_index += 1 + endfor + + return a:lines[l:start_index :] +endfunction + +function! s:ExtraErrorMsg(current, new) abort + let l:newMsg = '' + + if a:current is# '' + " extra messages appear to already have a : + let l:newMsg = a:new + else + let l:newMsg = a:current . ' ' . a:new + endif + + return l:newMsg +endfunction + +function! s:GetDetails(error) abort + let l:detail = '' + + for l:extra_error in a:error.extra + if has_key(l:extra_error, 'message') + for l:extra_message in l:extra_error.message + let l:detail = s:ExtraErrorMsg(l:detail, l:extra_message.descr) + endfor + endif + + if has_key(l:extra_error, 'children') + for l:child in l:extra_error.children + for l:child_message in l:child.message + let l:detail = l:detail . ' ' . l:child_message.descr + endfor + endfor + endif + endfor + + return l:detail +endfunction + +function! ale_linters#javascript#flow#Handle(buffer, lines) abort + let l:str = join(s:GetJSONLines(a:lines), '') + + if empty(l:str) + return [] + endif + + let l:flow_output = json_decode(l:str) + let l:output = [] + + for l:error in get(l:flow_output, 'errors', []) + " Each error is broken up into parts + let l:text = '' + let l:line = 0 + let l:col = 0 + + for l:message in l:error.message + " Comments have no line of column information, so we skip them. + " In certain cases, `l:message.loc.source` points to a different path + " than the buffer one, thus we skip this loc information too. + if has_key(l:message, 'loc') + \&& l:line is# 0 + \&& ale#path#IsBufferPath(a:buffer, l:message.loc.source) + let l:line = l:message.loc.start.line + 0 + let l:col = l:message.loc.start.column + 0 + endif + + if l:text is# '' + let l:text = l:message.descr . ':' + else + let l:text = l:text . ' ' . l:message.descr + endif + endfor + + if has_key(l:error, 'operation') + let l:text = l:text . ' See also: ' . l:error.operation.descr + endif + + let l:errorToAdd = { + \ 'lnum': l:line, + \ 'col': l:col, + \ 'text': l:text, + \ 'type': has_key(l:error, 'level') && l:error.level is# 'error' ? 'E' : 'W', + \} + + if has_key(l:error, 'extra') + let l:errorToAdd.detail = l:errorToAdd.text + \ . "\n" . s:GetDetails(l:error) + endif + + call add(l:output, l:errorToAdd) + endfor + + return l:output +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'flow', +\ 'executable': function('ale_linters#javascript#flow#GetExecutable'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#javascript#flow#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#javascript#flow#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#javascript#flow#Handle', +\ 'read_buffer': 0, +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim new file mode 100644 index 00000000..fec34011 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/flow_ls.vim @@ -0,0 +1,28 @@ +" Author: t_t +" Description: Integrate ALE with flow-language-server. + +call ale#Set('javascript_flow_ls_executable', 'flow') +call ale#Set('javascript_flow_ls_use_global', +\ get(g:, 'ale_use_global_executables', 0) +\) + +function! ale_linters#javascript#flow_ls#FindProjectRoot(buffer) abort + let l:flow_config = ale#path#FindNearestFile(a:buffer, '.flowconfig') + + if !empty(l:flow_config) + return fnamemodify(l:flow_config, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'flow-language-server', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_flow_ls', [ +\ 'node_modules/.bin/flow', +\ ])}, +\ 'command': '%e lsp --from ale-lsp', +\ 'project_root': function('ale_linters#javascript#flow_ls#FindProjectRoot'), +\ 'language': 'javascript', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/jscs.vim b/sources_non_forked/ale/ale_linters/javascript/jscs.vim new file mode 100644 index 00000000..ae3be68c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/jscs.vim @@ -0,0 +1,61 @@ +" Author: Chris Kyrouac - https://github.com/fijshion +" Description: jscs for JavaScript files + +call ale#Set('javascript_jscs_executable', 'jscs') +call ale#Set('javascript_jscs_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#javascript#jscs#GetCommand(buffer) abort + " Search for a local JShint config locaation, and default to a global one. + let l:jscs_config = ale#path#ResolveLocalPath( + \ a:buffer, + \ '.jscsrc', + \ get(g:, 'ale_jscs_config_loc', '') + \) + + let l:command = '%e --reporter inline --no-colors' + + if !empty(l:jscs_config) + let l:command .= ' --config ' . ale#Escape(l:jscs_config) + endif + + let l:command .= ' -' + + return l:command +endfunction + +function! ale_linters#javascript#jscs#Handle(buffer, lines) abort + " Matches patterns looking like the following + " + " foobar.js: line 2, col 1, Expected indentation of 1 characters + " + let l:pattern = '\v^.*:\s+line (\d+),\s+col\s+(\d+),\s+(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3] + \} + + let l:code_match = matchlist(l:match[3], '\v([^ :]+): (.+)$') + + if !empty(l:code_match) + let l:obj.code = l:code_match[1] + let l:obj.text = l:code_match[2] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'jscs', +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jscs', [ +\ 'node_modules/.bin/jscs', +\ ])}, +\ 'command': function('ale_linters#javascript#jscs#GetCommand'), +\ 'callback': 'ale_linters#javascript#jscs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/jshint.vim b/sources_non_forked/ale/ale_linters/javascript/jshint.vim new file mode 100644 index 00000000..26d4fda2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/jshint.vim @@ -0,0 +1,33 @@ +" Author: Chris Kyrouac - https://github.com/fijshion +" Description: JSHint for Javascript files + +call ale#Set('javascript_jshint_executable', 'jshint') +call ale#Set('javascript_jshint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#javascript#jshint#GetCommand(buffer) abort + " Search for a local JShint config locaation, and default to a global one. + let l:jshint_config = ale#path#ResolveLocalPath( + \ a:buffer, + \ '.jshintrc', + \ get(g:, 'ale_jshint_config_loc', '') + \) + + let l:command = '%e --reporter unix --extract auto' + + if !empty(l:jshint_config) + let l:command .= ' --config ' . ale#Escape(l:jshint_config) + endif + + let l:command .= ' --filename %s -' + + return l:command +endfunction + +call ale#linter#Define('javascript', { +\ 'name': 'jshint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_jshint', [ +\ 'node_modules/.bin/jshint', +\ ])}, +\ 'command': function('ale_linters#javascript#jshint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/standard.vim b/sources_non_forked/ale/ale_linters/javascript/standard.vim new file mode 100644 index 00000000..addf41dd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/standard.vim @@ -0,0 +1,32 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for JavaScript files + +call ale#Set('javascript_standard_executable', 'standard') +call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_standard_options', '') + +function! ale_linters#javascript#standard#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/semistandard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#javascript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#javascript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'javascript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('javascript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#javascript#standard#GetExecutable'), +\ 'command': function('ale_linters#javascript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/tsserver.vim b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim new file mode 100644 index 00000000..caf6972b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/tsserver.vim @@ -0,0 +1,17 @@ +" Author: Chaucerbao, w0rp +" Description: tsserver integration for ALE + +call ale#Set('javascript_tsserver_executable', 'tsserver') +call ale#Set('javascript_tsserver_config_path', '') +call ale#Set('javascript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('javascript', { +\ 'name': 'tsserver', +\ 'lsp': 'tsserver', +\ 'executable': {b -> ale#path#FindExecutable(b, 'javascript_tsserver', [ +\ 'node_modules/.bin/tsserver', +\ ])}, +\ 'command': '%e', +\ 'project_root': function('ale#handlers#tsserver#GetProjectRoot'), +\ 'language': '', +\}) diff --git a/sources_non_forked/ale/ale_linters/javascript/xo.vim b/sources_non_forked/ale/ale_linters/javascript/xo.vim new file mode 100644 index 00000000..5e04ad5c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/javascript/xo.vim @@ -0,0 +1,9 @@ +" Author: Daniel Lupu +" Description: xo for JavaScript files + +call ale#linter#Define('javascript', { +\ 'name': 'xo', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/cspell.vim b/sources_non_forked/ale/ale_linters/json/cspell.vim new file mode 100644 index 00000000..0d7314a4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for JSON files. + +call ale#handlers#cspell#DefineLinter('json') diff --git a/sources_non_forked/ale/ale_linters/json/eslint.vim b/sources_non_forked/ale/ale_linters/json/eslint.vim new file mode 100644 index 00000000..bdabb9fa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSON files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('json', { +\ 'name': 'eslint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/jq.vim b/sources_non_forked/ale/ale_linters/json/jq.vim new file mode 100644 index 00000000..2f36a29e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/jq.vim @@ -0,0 +1,24 @@ +" Author: jD91mZM2 +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_options', '') +call ale#Set('json_jq_filters', '.') + +" Matches patterns like the following: +" parse error: Expected another key-value pair at line 4, column 3 +let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' + +function! ale_linters#json#jq#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'text': match[1], + \ 'lnum': match[2] + 0, + \ 'col': match[3] + 0, + \}}) +endfunction + +call ale#linter#Define('json', { +\ 'name': 'jq', +\ 'executable': {b -> ale#Var(b, 'json_jq_executable')}, +\ 'output_stream': 'stderr', +\ 'command': '%e', +\ 'callback': 'ale_linters#json#jq#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/jsonlint.vim b/sources_non_forked/ale/ale_linters/json/jsonlint.vim new file mode 100644 index 00000000..812540af --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/jsonlint.vim @@ -0,0 +1,43 @@ +" Author: KabbAmine , David Sierra + +call ale#Set('json_jsonlint_executable', 'jsonlint') +call ale#Set('json_jsonlint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#json#jsonlint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'json_jsonlint', [ + \ 'node_modules/.bin/jsonlint', + \ 'node_modules/jsonlint/lib/cli.js', + \]) +endfunction + +function! ale_linters#json#jsonlint#GetCommand(buffer) abort + let l:executable = ale_linters#json#jsonlint#GetExecutable(a:buffer) + + return ale#node#Executable(a:buffer, l:executable) + \ . ' --compact -' +endfunction + +function! ale_linters#json#jsonlint#Handle(buffer, lines) abort + " Matches patterns like the following: + " line 2, col 15, found: 'STRING' - expected: 'EOF', '}', ',', ']'. + let l:pattern = '^line \(\d\+\), col \(\d*\), \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('json', { +\ 'name': 'jsonlint', +\ 'executable': function('ale_linters#json#jsonlint#GetExecutable'), +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#json#jsonlint#GetCommand'), +\ 'callback': 'ale_linters#json#jsonlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/json/spectral.vim b/sources_non_forked/ale/ale_linters/json/spectral.vim new file mode 100644 index 00000000..14129c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('json_spectral_executable', 'spectral') +call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('json', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'json_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/json/vscodejson.vim b/sources_non_forked/ale/ale_linters/json/vscodejson.vim new file mode 100644 index 00000000..dcaee010 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json/vscodejson.vim @@ -0,0 +1,16 @@ +" Author: Dalius Dobravolskas +" Description: VSCode json language server + +function! ale_linters#json#vscodejson#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('json', { +\ 'name': 'vscodejson', +\ 'lsp': 'stdio', +\ 'executable': 'vscode-json-language-server', +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#json#vscodejson#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/json5/eslint.vim b/sources_non_forked/ale/ale_linters/json5/eslint.vim new file mode 100644 index 00000000..6207f2d7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/json5/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSON5 files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('json5', { +\ 'name': 'eslint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/jsonc/eslint.vim b/sources_non_forked/ale/ale_linters/jsonc/eslint.vim new file mode 100644 index 00000000..1a5cc528 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonc/eslint.vim @@ -0,0 +1,16 @@ +" Author: João Pesce +" Description: eslint for JSONC files. +" +" Requires eslint-plugin-jsonc or a similar plugin to work +" +" Uses the same funtcions as ale_linters/javascript/eslint.vim by w0rp +" + +call ale#linter#Define('jsonc', { +\ 'name': 'eslint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/jsonnet/jsonnet_lint.vim b/sources_non_forked/ale/ale_linters/jsonnet/jsonnet_lint.vim new file mode 100644 index 00000000..a5ebdc39 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonnet/jsonnet_lint.vim @@ -0,0 +1,59 @@ +" Author: Trevor Whitney +" Description: jsonnet-lint for jsonnet files + +call ale#Set('jsonnet_jsonnet_lint_executable', 'jsonnet-lint') +call ale#Set('jsonnet_jsonnet_lint_options', '') + +function! ale_linters#jsonnet#jsonnet_lint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnet_lint_options') + + return '%e' + \ . ale#Pad(l:options) + \ . ' %t' +endfunction + + +function! ale_linters#jsonnet#jsonnet_lint#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " ERROR: foo.jsonnet:22:3-12 expected token OPERATOR but got (IDENTIFIER, "bar") + " ERROR: hoge.jsonnet:20:3 unexpected: "}" while parsing terminal + " ERROR: main.jsonnet:212:1-14 Expected , or ; but got (IDENTIFIER, "older_cluster") + let l:pattern = '^ERROR: [^:]*:\(\d\+\):\(\d\+\)\(-\d\+\)* \(.*\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let line_number = l:match[1] + 0 + let column = l:match[2] + 0 + " l:match[3] has optional -14, when linter is showing a range + let text = l:match[4] + + + " vcol is Needed to indicate that the column is a character. + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': line_number, + \ 'vcol': 0, + \ 'col': column, + \ 'text': text, + \ 'type': 'E', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('jsonnet', { +\ 'name': 'jsonnet_lint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'jsonnet_jsonnet_lint_executable')}, +\ 'command': function('ale_linters#jsonnet#jsonnet_lint#GetCommand'), +\ 'callback': 'ale_linters#jsonnet#jsonnet_lint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim b/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim new file mode 100644 index 00000000..8904019e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/jsonnet/jsonnetfmt.vim @@ -0,0 +1,52 @@ +" Authors: Trevor Whitney and Takuya Kosugiyama +" Description: jsonnetfmt for jsonnet files + +call ale#Set('jsonnet_jsonnetfmt_executable', 'jsonnetfmt') +call ale#Set('jsonnet_jsonnetfmt_options', '') + +function! ale_linters#jsonnet#jsonnetfmt#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_options') + + return '%e' + \ . ale#Pad(l:options) + \ . ' %t' +endfunction + + +function! ale_linters#jsonnet#jsonnetfmt#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " STATIC ERROR: foo.jsonnet:22:3-12: expected token OPERATOR but got (IDENTIFIER, "bar") + " STATIC ERROR: hoge.jsonnet:20:3: unexpected: "}" while parsing terminal + let l:pattern = '^STATIC ERROR:[^:]*:\(\d\+\):\(\d\+\):*\(-\d\+\)* \(.*\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + " vcol is Needed to indicate that the column is a character. + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'vcol': 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \ 'nr': -1, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('jsonnet', { +\ 'name': 'jsonnetfmt', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'jsonnet_jsonnetfmt_executable')}, +\ 'command': function('ale_linters#jsonnet#jsonnetfmt#GetCommand'), +\ 'callback': 'ale_linters#jsonnet#jsonnetfmt#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/julia/languageserver.vim b/sources_non_forked/ale/ale_linters/julia/languageserver.vim new file mode 100644 index 00000000..999ad815 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/julia/languageserver.vim @@ -0,0 +1,21 @@ +" Author: Bartolomeo Stellato +" Description: A language server for Julia + +" Set julia executable variable +call ale#Set('julia_executable', 'julia') + +function! ale_linters#julia#languageserver#GetCommand(buffer) abort + let l:julia_executable = ale#Var(a:buffer, 'julia_executable') + let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, dirname(Pkg.Types.Context().env.project_file)); server.runlinter = true; run(server);' + + return ale#Escape(l:julia_executable) . ' --project=@. --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) +endfunction + +call ale#linter#Define('julia', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'julia_executable')}, +\ 'command': function('ale_linters#julia#languageserver#GetCommand'), +\ 'language': 'julia', +\ 'project_root': function('ale#julia#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim new file mode 100644 index 00000000..e8bc924d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/kotlin/kotlinc.vim @@ -0,0 +1,177 @@ +" Author: Francis Agyapong +" Description: A linter for the Kotlin programming language that uses kotlinc + +let g:ale_kotlin_kotlinc_options = get(g:, 'ale_kotlin_kotlinc_options', '') +let g:ale_kotlin_kotlinc_enable_config = get(g:, 'ale_kotlin_kotlinc_enable_config', 0) +let g:ale_kotlin_kotlinc_config_file = get(g:, 'ale_kotlin_kotlinc_config_file', '.ale_kotlinc_config') +let g:ale_kotlin_kotlinc_classpath = get(g:, 'ale_kotlin_kotlinc_classpath', '') +let g:ale_kotlin_kotlinc_sourcepath = get(g:, 'ale_kotlin_kotlinc_sourcepath', '') +let g:ale_kotlin_kotlinc_use_module_file = get(g:, 'ale_kotlin_kotlinc_use_module_file', 0) +let g:ale_kotlin_kotlinc_module_filename = get(g:, 'ale_kotlin_kotlinc_module_filename', 'module.xml') + +let s:classpath_sep = has('unix') ? ':' : ';' + +function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort + let l:command = '' + + " exec maven/gradle only if classpath is not set + if !empty(ale#Var(a:buffer, 'kotlin_kotlinc_classpath')) + return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {}) + endif + + let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer) + + " Try to use Gradle if Maven isn't available. + if empty(l:command) + let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer) + endif + + if empty(l:command) + return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {}) + endif + + return ale#command#Run( + \ a:buffer, + \ l:command, + \ function('ale_linters#kotlin#kotlinc#GetCommand'), + \ {'cwd': l:cwd}, + \) +endfunction + +function! s:BuildClassPathOption(buffer, import_paths) abort + " Filter out lines like [INFO], etc. + let l:class_paths = filter(a:import_paths[:], 'v:val !~# ''[''') + call extend( + \ l:class_paths, + \ split(ale#Var(a:buffer, 'kotlin_kotlinc_classpath'), s:classpath_sep), + \) + + return !empty(l:class_paths) + \ ? ' -cp ' . ale#Escape(join(l:class_paths, s:classpath_sep)) + \ : '' +endfunction + +function! ale_linters#kotlin#kotlinc#GetCommand(buffer, import_paths, meta) abort + let l:kotlinc_opts = ale#Var(a:buffer, 'kotlin_kotlinc_options') + let l:command = 'kotlinc ' + + " If the config file is enabled and readable, source it + if ale#Var(a:buffer, 'kotlin_kotlinc_enable_config') + let l:conf = expand(ale#Var(a:buffer, 'kotlin_kotlinc_config_file'), 1) + + if filereadable(l:conf) + execute 'source ' . fnameescape(l:conf) + endif + endif + + " If use module and module file is readable use that and return + if ale#Var(a:buffer, 'kotlin_kotlinc_use_module_file') + let l:module_filename = ale#Escape(expand(ale#Var(a:buffer, 'kotlin_kotlinc_module_filename'), 1)) + + if filereadable(l:module_filename) + let l:kotlinc_opts .= ' -module ' . l:module_filename + let l:command .= 'kotlinc ' . l:kotlinc_opts + + return l:command + endif + endif + + " We only get here if not using module or the module file not readable + if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# '' + let l:kotlinc_opts .= ' -cp ' . ale#Var(a:buffer, 'kotlin_kotlinc_classpath') + else + " get classpath from maven/gradle + let l:kotlinc_opts .= s:BuildClassPathOption(a:buffer, a:import_paths) + endif + + let l:fname = '' + + if ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath') isnot# '' + let l:fname .= expand(ale#Var(a:buffer, 'kotlin_kotlinc_sourcepath'), 1) . ' ' + else + " Find the src directory for files in this project. + let l:project_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + let l:src_dir = l:project_root + else + let l:src_dir = ale#path#FindNearestDirectory(a:buffer, 'src/main/java') + \ . ' ' . ale#path#FindNearestDirectory(a:buffer, 'src/main/kotlin') + endif + + let l:fname .= expand(l:src_dir, 1) . ' ' + endif + + let l:fname .= ale#Escape(expand('#' . a:buffer . ':p')) + let l:command .= l:kotlinc_opts . ' ' . l:fname + + return l:command +endfunction + +function! ale_linters#kotlin#kotlinc#Handle(buffer, lines) abort + let l:code_pattern = '^\(.*\):\([0-9]\+\):\([0-9]\+\):\s\+\(error\|warning\):\s\+\(.*\)' + let l:general_pattern = '^\(warning\|error\|info\):\s*\(.*\)' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:code_pattern) + + if len(l:match) == 0 + continue + endif + + let l:file = l:match[1] + let l:line = l:match[2] + 0 + let l:column = l:match[3] + 0 + let l:type = l:match[4] + let l:text = l:match[5] + + let l:buf_abspath = fnamemodify(l:file, ':p') + let l:curbuf_abspath = expand('#' . a:buffer . ':p') + + " Skip if file is not loaded + if l:buf_abspath isnot# l:curbuf_abspath + continue + endif + + let l:type_marker_str = l:type is# 'warning' ? 'W' : 'E' + + call add(l:output, { + \ 'lnum': l:line, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type_marker_str, + \}) + endfor + + " Non-code related messages + for l:line in a:lines + let l:match = matchlist(l:line, l:general_pattern) + + if len(l:match) == 0 + continue + endif + + let l:type = l:match[1] + let l:text = l:match[2] + + let l:type_marker_str = l:type is# 'warning' || l:type is# 'info' ? 'W' : 'E' + + call add(l:output, { + \ 'lnum': 1, + \ 'text': l:text, + \ 'type': l:type_marker_str, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('kotlin', { +\ 'name': 'kotlinc', +\ 'executable': 'kotlinc', +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#kotlin#kotlinc#RunWithImportPaths'), +\ 'callback': 'ale_linters#kotlin#kotlinc#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim new file mode 100644 index 00000000..0bb64b19 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/kotlin/ktlint.vim @@ -0,0 +1,10 @@ +" Author: Francis Agyapong +" Description: Lint kotlin files using ktlint + +call ale#linter#Define('kotlin', { +\ 'name': 'ktlint', +\ 'executable': 'ktlint', +\ 'command': function('ale#handlers#ktlint#GetCommand'), +\ 'callback': 'ale#handlers#ktlint#Handle', +\ 'output_stream': 'stderr' +\}) diff --git a/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim new file mode 100644 index 00000000..af78c0e0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/kotlin/languageserver.vim @@ -0,0 +1,29 @@ +" Author: MTDL9 +" Description: Support for the Kotlin language server https://github.com/fwcd/KotlinLanguageServer + +call ale#Set('kotlin_languageserver_executable', 'kotlin-language-server') + +function! ale_linters#kotlin#languageserver#GetProjectRoot(buffer) abort + let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:gradle_root) + return l:gradle_root + endif + + let l:maven_pom_file = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:maven_pom_file) + return fnamemodify(l:maven_pom_file, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('kotlin', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'kotlin_languageserver_executable')}, +\ 'command': '%e', +\ 'language': 'kotlin', +\ 'project_root': function('ale_linters#kotlin#languageserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/less/lessc.vim b/sources_non_forked/ale/ale_linters/less/lessc.vim new file mode 100644 index 00000000..8e21f5b4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/less/lessc.vim @@ -0,0 +1,47 @@ +" Author: zanona , w0rp +" Description: This file adds support for checking Less code with lessc. + +call ale#Set('less_lessc_executable', 'lessc') +call ale#Set('less_lessc_options', '') +call ale#Set('less_lessc_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#less#lessc#GetCommand(buffer) abort + return '%e --no-color --lint' + \ . ' --include-path=' . ale#Escape(expand('#' . a:buffer . ':p:h')) + \ . ale#Pad(ale#Var(a:buffer, 'less_lessc_options')) + \ . ' -' +endfunction + +function! ale_linters#less#lessc#Handle(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + " Matches patterns like the following: + let l:pattern = '^\(\w\+\): \(.\{-}\) in \(.\{-}\) on line \(\d\+\), column \(\d\+\):$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[4] + 0, + \ 'col': l:match[5] + 0, + \ 'text': l:match[2], + \ 'type': 'E', + \} + + if l:match[3] isnot# '-' + let l:item.filename = ale#path#GetAbsPath(l:dir, l:match[3]) + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('less', { +\ 'name': 'lessc', +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_lessc', [ +\ 'node_modules/.bin/lessc', +\ ])}, +\ 'command': function('ale_linters#less#lessc#GetCommand'), +\ 'callback': 'ale_linters#less#lessc#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/less/stylelint.vim b/sources_non_forked/ale/ale_linters/less/stylelint.vim new file mode 100644 index 00000000..83f784c4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/less/stylelint.vim @@ -0,0 +1,20 @@ +" Author: diartyz , w0rp + +call ale#Set('less_stylelint_executable', 'stylelint') +call ale#Set('less_stylelint_options', '') +call ale#Set('less_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#less#stylelint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'less_stylelint_options') + + return '%e' . ale#Pad(l:options) . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('less', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'less_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': function('ale_linters#less#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/llvm/llc.vim b/sources_non_forked/ale/ale_linters/llvm/llc.vim new file mode 100644 index 00000000..594be063 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/llvm/llc.vim @@ -0,0 +1,24 @@ +" Author: rhysd +" Description: Support for checking LLVM IR with llc + +call ale#Set('llvm_llc_executable', 'llc') + +function! ale_linters#llvm#llc#HandleErrors(buffer, lines) abort + " Handle '{path}: {file}:{line}:{col}: error: {message}' format + let l:pattern = '\v^[a-zA-Z]?:?[^:]+: [^:]+:(\d+):(\d+): (.+)$' + + return map(ale#util#GetMatches(a:lines, l:pattern), "{ + \ 'lnum': str2nr(v:val[1]), + \ 'col': str2nr(v:val[2]), + \ 'text': v:val[3], + \ 'type': 'E', + \}") +endfunction + +call ale#linter#Define('llvm', { +\ 'name': 'llc', +\ 'executable': {b -> ale#Var(b, 'llvm_llc_executable')}, +\ 'output_stream': 'stderr', +\ 'command': {-> '%e -filetype=null -o=' . g:ale#util#nul_file}, +\ 'callback': 'ale_linters#llvm#llc#HandleErrors', +\}) diff --git a/sources_non_forked/ale/ale_linters/lua/cspell.vim b/sources_non_forked/ale/ale_linters/lua/cspell.vim new file mode 100644 index 00000000..215b82f8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Lua files. + +call ale#handlers#cspell#DefineLinter('lua') diff --git a/sources_non_forked/ale/ale_linters/lua/luac.vim b/sources_non_forked/ale/ale_linters/lua/luac.vim new file mode 100644 index 00000000..41674a43 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/luac.vim @@ -0,0 +1,31 @@ +" Author: Jon Xie https://github.com/xiejiangzhi +" Description: luac linter for lua files + +call ale#Set('lua_luac_executable', 'luac') + +function! ale_linters#lua#luac#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " luac: stdin:5: '=' expected near ')' + " luac: stdin:8: ')' expected (to close '(' at line 6) near '123' + let l:pattern = '\v^.*:(\d+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': 'E', + \ 'text': l:match[2], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('lua', { +\ 'name': 'luac', +\ 'executable': {b -> ale#Var(b, 'lua_luac_executable')}, +\ 'command': '%e -p -', +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#lua#luac#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/lua/luacheck.vim b/sources_non_forked/ale/ale_linters/lua/luacheck.vim new file mode 100644 index 00000000..34be2b5a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/luacheck.vim @@ -0,0 +1,44 @@ +" Author: Sol Bekic https://github.com/s-ol +" Description: luacheck linter for lua files + +call ale#Set('lua_luacheck_executable', 'luacheck') +call ale#Set('lua_luacheck_options', '') + +function! ale_linters#lua#luacheck#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_luacheck_options')) + \ . ' --formatter plain --codes --filename %s -' +endfunction + +function! ale_linters#lua#luacheck#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " artal.lua:159:17: (W111) shadowing definition of loop variable 'i' on line 106 + " artal.lua:182:7: (W213) unused loop variable 'i' + let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\(\d\+\)) \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + \ && l:match[3] is# 'W' + \ && index(range(611, 614), str2nr(l:match[4])) >= 0 + continue + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3], + \ 'code': l:match[3] . l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('lua', { +\ 'name': 'luacheck', +\ 'executable': {b -> ale#Var(b, 'lua_luacheck_executable')}, +\ 'command': function('ale_linters#lua#luacheck#GetCommand'), +\ 'callback': 'ale_linters#lua#luacheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/lua/selene.vim b/sources_non_forked/ale/ale_linters/lua/selene.vim new file mode 100644 index 00000000..6b33cbfd --- /dev/null +++ b/sources_non_forked/ale/ale_linters/lua/selene.vim @@ -0,0 +1,46 @@ +call ale#Set('lua_selene_executable', 'selene') +call ale#Set('lua_selene_options', '') + +function! ale_linters#lua#selene#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'lua_selene_options')) + \ . ' --display-style=json -' +endfunction + +function! ale_linters#lua#selene#Handle(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + " as of version 0.17.0, selene has no way to suppress summary + " information when outputting json, so stop processing when we hit it + " (PR for this here: https://github.com/Kampfkarren/selene/pull/356) + if l:line is# 'Results:' + break + endif + + let l:json = json_decode(l:line) + let l:lint = { + \ 'lnum': l:json.primary_label.span.start_line + 1, + \ 'end_lnum': l:json.primary_label.span.end_line + 1, + \ 'col': l:json.primary_label.span.start_column + 1, + \ 'end_col': l:json.primary_label.span.end_column, + \ 'text': l:json.message, + \ 'code': l:json.code, + \ 'type': l:json.severity is# 'Warning' ? 'W' : 'E', + \} + + if has_key(l:json, 'notes') && len(l:json.notes) > 0 + let l:lint.detail = l:lint.text . "\n\n" . join(l:json.notes, "\n") + endif + + call add(l:output, l:lint) + endfor + + return l:output +endfunction + +call ale#linter#Define('lua', { +\ 'name': 'selene', +\ 'executable': {b -> ale#Var(b, 'lua_selene_executable')}, +\ 'command': function('ale_linters#lua#selene#GetCommand'), +\ 'callback': 'ale_linters#lua#selene#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/mail/alex.vim b/sources_non_forked/ale/ale_linters/mail/alex.vim new file mode 100644 index 00000000..0fceea7b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mail/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for mail files + +call ale#handlers#alex#DefineLinter('mail', '--text') diff --git a/sources_non_forked/ale/ale_linters/mail/languagetool.vim b/sources_non_forked/ale/ale_linters/mail/languagetool.vim new file mode 100644 index 00000000..f68dab7a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mail/languagetool.vim @@ -0,0 +1,5 @@ +" Author: Vincent (wahrwolf [at] wolfpit.net) +" Description: languagetool for mails + + +call ale#handlers#languagetool#DefineLinter('mail') diff --git a/sources_non_forked/ale/ale_linters/mail/proselint.vim b/sources_non_forked/ale/ale_linters/mail/proselint.vim new file mode 100644 index 00000000..82c8d1f8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mail/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for mail files + +call ale#linter#Define('mail', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/mail/vale.vim b/sources_non_forked/ale/ale_linters/mail/vale.vim new file mode 100644 index 00000000..e6dfd2ec --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mail/vale.vim @@ -0,0 +1,9 @@ +" Author: chew-z https://github.com/chew-z +" Description: vale for Markdown files + +call ale#linter#Define('mail', { +\ 'name': 'vale', +\ 'executable': 'vale', +\ 'command': 'vale --output=JSON %t', +\ 'callback': 'ale#handlers#vale#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/make/checkmake.vim b/sources_non_forked/ale/ale_linters/make/checkmake.vim new file mode 100644 index 00000000..fed01b5f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/make/checkmake.vim @@ -0,0 +1,37 @@ +" Author: aurieh - https://github.com/aurieh + +call ale#Set('make_checkmake_config', '') + +function! ale_linters#make#checkmake#Handle(buffer, lines) abort + let l:pattern = '\v^(\d+):(.+):(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:match[1] + 0, + \ 'type': 'E', + \ 'code': l:match[2], + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#make#checkmake#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'make_checkmake_config') + let l:cmd = 'checkmake' + \ . ' --format="{{.LineNumber}}:{{.Rule}}:{{.Violation}}{{\"\r\n\"}}"' + \ . (!empty(l:config) ? ' --config="' . l:config . '"' : '') + \ . ' %s' + + return l:cmd +endfunction + +call ale#linter#Define('make', { +\ 'name': 'checkmake', +\ 'executable': 'checkmake', +\ 'command': function('ale_linters#make#checkmake#GetCommand'), +\ 'callback': 'ale_linters#make#checkmake#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/alex.vim b/sources_non_forked/ale/ale_linters/markdown/alex.vim new file mode 100644 index 00000000..63769b5e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for markdown files + +call ale#handlers#alex#DefineLinter('markdown', '') diff --git a/sources_non_forked/ale/ale_linters/markdown/cspell.vim b/sources_non_forked/ale/ale_linters/markdown/cspell.vim new file mode 100644 index 00000000..45c586cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Markdown files. + +call ale#handlers#cspell#DefineLinter('markdown') diff --git a/sources_non_forked/ale/ale_linters/markdown/languagetool.vim b/sources_non_forked/ale/ale_linters/markdown/languagetool.vim new file mode 100644 index 00000000..422a38c3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/languagetool.vim @@ -0,0 +1,5 @@ +" Author: Vincent (wahrwolf [at] wolfpit.net) +" Description: languagetool for markdown files + + +call ale#handlers#languagetool#DefineLinter('markdown') diff --git a/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim new file mode 100644 index 00000000..7a293938 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/markdownlint.vim @@ -0,0 +1,22 @@ +" Author: Ty-Lucas Kelley +" Description: Adds support for markdownlint + +call ale#Set('markdown_markdownlint_options', '') + +function! ale_linters#markdown#markdownlint#GetCommand(buffer) abort + let l:executable = 'markdownlint' + + let l:options = ale#Var(a:buffer, 'markdown_markdownlint_options') + + return ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' %s' +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'markdownlint', +\ 'executable': 'markdownlint', +\ 'lint_file': 1, +\ 'output_stream': 'both', +\ 'command': function('ale_linters#markdown#markdownlint#GetCommand'), +\ 'callback': 'ale#handlers#markdownlint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/mdl.vim b/sources_non_forked/ale/ale_linters/markdown/mdl.vim new file mode 100644 index 00000000..fd44de6e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/mdl.vim @@ -0,0 +1,43 @@ +" Author: Steve Dignam , Josh Leeb-du Toit +" Description: Support for mdl, a markdown linter. + +call ale#Set('markdown_mdl_executable', 'mdl') +call ale#Set('markdown_mdl_options', '') + +function! ale_linters#markdown#mdl#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'markdown_mdl_executable') +endfunction + +function! ale_linters#markdown#mdl#GetCommand(buffer) abort + let l:executable = ale_linters#markdown#mdl#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'bundle$' + \ ? ' exec mdl' + \ : '' + + let l:options = ale#Var(a:buffer, 'markdown_mdl_options') + + return ale#Escape(l:executable) . l:exec_args + \ . ' -j' . (!empty(l:options) ? ' ' . l:options : '') +endfunction + +function! ale_linters#markdown#mdl#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + call add(l:output, { + \ 'lnum': l:error['line'], + \ 'code': l:error['rule'] . '/' . join(l:error['aliases'], '/'), + \ 'text': l:error['description'], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'mdl', +\ 'executable': function('ale_linters#markdown#mdl#GetExecutable'), +\ 'command': function('ale_linters#markdown#mdl#GetCommand'), +\ 'callback': 'ale_linters#markdown#mdl#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/proselint.vim b/sources_non_forked/ale/ale_linters/markdown/proselint.vim new file mode 100644 index 00000000..289d8819 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/proselint.vim @@ -0,0 +1,9 @@ +" Author: poohzrn https://github.com/poohzrn +" Description: proselint for Markdown files + +call ale#linter#Define('markdown', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/redpen.vim b/sources_non_forked/ale/ale_linters/markdown/redpen.vim new file mode 100644 index 00000000..ff2cbaf8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('markdown', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f markdown -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim new file mode 100644 index 00000000..6085e7ef --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/remark_lint.vim @@ -0,0 +1,48 @@ +scriptencoding utf-8 +" Author rhysd https://rhysd.github.io/, Dirk Roorda (dirkroorda), Adrián González Rus (@adrigzr) +" Description: remark-lint for Markdown files +call ale#Set('markdown_remark_lint_executable', 'remark') +call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('markdown_remark_lint_options', '') + +function! ale_linters#markdown#remark_lint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options') + + return '%e' . ale#Pad(l:options) . ' --no-stdout --no-color' +endfunction + +function! ale_linters#markdown#remark_lint#Handle(buffer, lines) abort + " matches: ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint' + " matches: ' 18:71-19:1 error Missing new line after list item list-item-spacing remark-lint', + let l:pattern = '^ \+\(\d\+\):\(\d\+\)\(-\(\d\+\):\(\d\+\)\)\? \(warning\|error\) \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[6] is# 'error' ? 'E' : 'W', + \ 'text': l:match[7], + \} + + if l:match[3] isnot# '' + let l:item.end_lnum = l:match[4] + 0 + let l:item.end_col = l:match[5] + 0 + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'remark_lint', +\ 'aliases': ['remark-lint'], +\ 'executable': {b -> ale#path#FindExecutable(b, 'markdown_remark_lint', [ +\ 'node_modules/.bin/remark', +\ ])}, +\ 'command': function('ale_linters#markdown#remark_lint#GetCommand'), +\ 'callback': 'ale_linters#markdown#remark_lint#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/textlint.vim b/sources_non_forked/ale/ale_linters/markdown/textlint.vim new file mode 100644 index 00000000..613c8411 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/textlint.vim @@ -0,0 +1,9 @@ +" Author: tokida https://rouger.info, Yasuhiro Kiyota +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#linter#Define('markdown', { +\ 'name': 'textlint', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/vale.vim b/sources_non_forked/ale/ale_linters/markdown/vale.vim new file mode 100644 index 00000000..06a64416 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/vale.vim @@ -0,0 +1,24 @@ +" Author: chew-z https://github.com/chew-z +" Description: vale for Markdown files + +call ale#Set('markdown_vale_executable', 'vale') +call ale#Set('markdown_vale_input_file', '%t') +call ale#Set('markdown_vale_options', '') + +function! ale_linters#markdown#vale#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_vale_executable') + let l:input_file = ale#Var(a:buffer, 'markdown_vale_input_file') + + " Defaults to `vale --output=JSON %t` + return ale#Escape(l:executable) + \ . ' --output=JSON ' + \ . ale#Var(a:buffer, 'markdown_vale_options') + \ . ' ' . l:input_file +endfunction + +call ale#linter#Define('markdown', { +\ 'name': 'vale', +\ 'executable': {b -> ale#Var(b, 'markdown_vale_executable')}, +\ 'command': function('ale_linters#markdown#vale#GetCommand'), +\ 'callback': 'ale#handlers#vale#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/markdown/writegood.vim b/sources_non_forked/ale/ale_linters/markdown/writegood.vim new file mode 100644 index 00000000..7108e7ac --- /dev/null +++ b/sources_non_forked/ale/ale_linters/markdown/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for Markdown files + +call ale#handlers#writegood#DefineLinter('markdown') diff --git a/sources_non_forked/ale/ale_linters/matlab/mlint.vim b/sources_non_forked/ale/ale_linters/matlab/mlint.vim new file mode 100644 index 00000000..e7daf37e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/matlab/mlint.vim @@ -0,0 +1,44 @@ +" Author: awlayton +" Description: mlint for MATLAB files + +call ale#Set('matlab_mlint_executable', 'mlint') + +function! ale_linters#matlab#mlint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " L 27 (C 1): FNDEF: Terminate statement with semicolon to suppress output. + " L 30 (C 13-15): FNDEF: A quoted string is unterminated. + let l:pattern = '^L \(\d\+\) (C \([0-9-]\+\)): \([A-Z]\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:lnum = l:match[1] + 0 + let l:col = l:match[2] + 0 + let l:code = l:match[3] + let l:text = l:match[4] + + " Suppress erroneous warning about filename + " TODO: Enable this error when copying filename is supported + if l:code is# 'FNDEF' + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:lnum, + \ 'col': l:col, + \ 'text': l:text, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('matlab', { +\ 'name': 'mlint', +\ 'executable': {b -> ale#Var(b, 'matlab_mlint_executable')}, +\ 'command': '%e -id %t', +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#matlab#mlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/mercury/mmc.vim b/sources_non_forked/ale/ale_linters/mercury/mmc.vim new file mode 100644 index 00000000..85969e10 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/mercury/mmc.vim @@ -0,0 +1,38 @@ +" Author: stewy33 +" Description: Lints mercury files using mmc + +call ale#Set('mercury_mmc_executable', 'mmc') +call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100') + +function! ale_linters#mercury#mmc#GetCommand(buffer) abort + return '%e --errorcheck-only ' + \ . ale#Var(a:buffer, 'mercury_mmc_options') + \ . ' %s:t:r' +endfunction + +function! ale_linters#mercury#mmc#Handle(buffer, lines) abort + " output format + " :: : + let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': substitute(l:match[1], '\v^0*', '', '') + 0, + \ 'type': l:match[2][0] =~? 'W' ? 'W' : 'E', + \ 'text': l:match[2] . ': ' . l:match[3] + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('mercury', { +\ 'name': 'mmc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#mercury#mmc#GetCommand'), +\ 'callback': 'ale_linters#mercury#mmc#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/nasm/nasm.vim b/sources_non_forked/ale/ale_linters/nasm/nasm.vim new file mode 100644 index 00000000..c4f53629 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nasm/nasm.vim @@ -0,0 +1,41 @@ +" Author: Oyvind Ingvaldsen +" Description: NASM linter for asmsyntax nasm. + +call ale#Set('nasm_nasm_executable', 'nasm') +call ale#Set('nasm_nasm_options', '') + +function! ale_linters#nasm#nasm#GetCommand(buffer) abort + " Note that NASM requires a trailing slash for the -I option. + let l:separator = has('win32') ? '\' : '/' + let l:output_null = has('win32') ? 'NUL' : '/dev/null' + + return '%e -X gnu -I %s:h' . l:separator + \ . ale#Pad(ale#Var(a:buffer, 'nasm_nasm_options')) + \ . ' %s' + \ . ' -o ' . l:output_null +endfunction + +function! ale_linters#nasm#nasm#Handle(buffer, lines) abort + " Note that we treat 'fatal' as errors. + let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] =~? 'error\|fatal' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('nasm', { +\ 'name': 'nasm', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\ 'executable': {b -> ale#Var(b, 'nasm_nasm_executable')}, +\ 'command': function('ale_linters#nasm#nasm#GetCommand'), +\ 'callback': 'ale_linters#nasm#nasm#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/nim/nimcheck.vim b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim new file mode 100644 index 00000000..b739ca04 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nim/nimcheck.vim @@ -0,0 +1,79 @@ +" Author: Baabelfish +" Description: Typechecking for nim files + +let s:end_col_patterns = [ +\ '\v''([^'']+)'' is declared but not used.*', +\ '\videntifier expected, but found ''([^'']+)''', +\ '\vimported and not used: ''([^'']+)''.*', +\ '\vundeclared identifier: ''([^'']+)''', +\ '\v''([^'']+)'' cannot be assigned to', +\ '\vredefinition of ''([^'']+)'';', +\] + +function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort + let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p:t') + let l:pattern = '^\(.\+\.nim\)(\(\d\+\), \(\d\+\)) \(.\+\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " Only show errors of the current buffer + " NOTE: Checking filename only is OK because nim enforces unique + " module names. + let l:temp_buffer_filename = fnamemodify(l:match[1], ':p:t') + + if l:buffer_filename isnot# '' && l:temp_buffer_filename isnot# l:buffer_filename + continue + endif + + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'W', + \} + + " Extract error type from message of type 'Error: Some error message' + let l:error_match = matchlist(l:item.text, '^\(.\{-}\): \(.\+\)$') + + if !empty(l:error_match) + if l:error_match[1] is# 'Error' + let l:item.type = 'E' + let l:item.text = l:error_match[2] + elseif l:error_match[1] is# 'Warning' + \|| l:error_match[1] is# 'Hint' + let l:item.text = l:error_match[2] + endif + endif + + let l:code_match = matchlist(l:item.text, '\v^(.+) \[([^ \[]+)\]$') + + if !empty(l:code_match) + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + " Find position end_col. + for l:col_match in ale#util#GetMatches(l:item.text, s:end_col_patterns) + let l:item.end_col = l:item.col + len(l:col_match[1]) - 1 + endfor + + call add(l:output, l:item) + endfor + + return l:output +endfunction + + +function! ale_linters#nim#nimcheck#GetCommand(buffer) abort + return 'nim check --verbosity:0 --colors:off --listFullPaths %s' +endfunction + + +call ale#linter#Define('nim', { +\ 'name': 'nimcheck', +\ 'executable': 'nim', +\ 'output_stream': 'both', +\ 'command': function('ale_linters#nim#nimcheck#GetCommand'), +\ 'callback': 'ale_linters#nim#nimcheck#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/nim/nimlsp.vim b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim new file mode 100644 index 00000000..5d041043 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nim/nimlsp.vim @@ -0,0 +1,33 @@ +" Author: jeremija +" Description: Support for nimlsp (language server for nim) + +call ale#Set('nim_nimlsp_nim_sources', '') + +function! ale_linters#nim#nimlsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale_linters#nim#nimlsp#GetCommand(buffer) abort + let l:nim_sources = ale#Var(a:buffer, 'nim_nimlsp_nim_sources') + + if !empty(l:nim_sources) + let l:nim_sources = ale#Escape(l:nim_sources) + endif + + return '%e' . ale#Pad(l:nim_sources) +endfunction + +call ale#linter#Define('nim', { +\ 'name': 'nimlsp', +\ 'lsp': 'stdio', +\ 'executable': 'nimlsp', +\ 'command': function('ale_linters#nim#nimlsp#GetCommand'), +\ 'language': 'nim', +\ 'project_root': function('ale_linters#nim#nimlsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/nix.vim b/sources_non_forked/ale/ale_linters/nix/nix.vim new file mode 100644 index 00000000..7c2ce963 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/nix.vim @@ -0,0 +1,63 @@ +" Author: Alistair Bill <@alibabzo> +" Author: Maximilian Bosch +" Description: nix-instantiate linter for nix files + +function! ale_linters#nix#nix#Command(buffer, output, meta) abort + let l:version = a:output[0][22:] + + if l:version =~# '^\(2.[4-9]\|3\).*' + return 'nix-instantiate --log-format internal-json --parse -' + else + return 'nix-instantiate --parse -' + endif +endfunction + +function! ale_linters#nix#nix#Handle(buffer, lines) abort + let l:output = [] + + if empty(a:lines) + return l:output + endif + + if a:lines[0] =~# '^@nix .*' + for l:line in a:lines + if l:line =~# '^@nix .*' + let l:result = json_decode(strpart(l:line, 4)) + + if has_key(l:result, 'column') + call add(l:output, { + \ 'type': 'E', + \ 'lnum': l:result.line, + \ 'col': l:result.column, + \ 'text': l:result.raw_msg + \}) + endif + endif + endfor + else + let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'col': l:match[4] + 0, + \ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''), + \ 'type': l:match[1] =~# '^error' ? 'E' : 'W', + \}) + endfor + endif + + return l:output +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'nix', +\ 'output_stream': 'stderr', +\ 'executable': 'nix-instantiate', +\ 'command': {buffer -> ale#command#Run( +\ buffer, +\ 'nix-instantiate --version', +\ function('ale_linters#nix#nix#Command') +\ )}, +\ 'callback': 'ale_linters#nix#nix#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim new file mode 100644 index 00000000..949bed1c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim @@ -0,0 +1,16 @@ +" Author: jD91mZM2 +" Description: rnix-lsp language client + +function! ale_linters#nix#rnix_lsp#GetProjectRoot(buffer) abort + " rnix-lsp does not yet use the project root, so getting it right is not + " important + return fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'rnix_lsp', +\ 'lsp': 'stdio', +\ 'executable': 'rnix-lsp', +\ 'command': '%e', +\ 'project_root': function('ale_linters#nix#rnix_lsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/nix/statix.vim b/sources_non_forked/ale/ale_linters/nix/statix.vim new file mode 100644 index 00000000..a90a68a6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nix/statix.vim @@ -0,0 +1,18 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: statix analysis and suggestions for Nix files + +call ale#Set('nix_statix_check_executable', 'statix') +call ale#Set('nix_statix_check_options', '') + +function! ale_linters#nix#statix#GetCommand(buffer) abort + return '%e check -o errfmt --stdin' + \ . ale#Pad(ale#Var(a:buffer, 'nix_statix_check_options')) +endfunction + +call ale#linter#Define('nix', { +\ 'name': 'statix', +\ 'executable': {b -> ale#Var(b, 'nix_statix_check_executable')}, +\ 'command': function('ale_linters#nix#statix#GetCommand'), +\ 'callback': 'ale#handlers#statix#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/nroff/alex.vim b/sources_non_forked/ale/ale_linters/nroff/alex.vim new file mode 100644 index 00000000..3f06af26 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nroff/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for nroff files + +call ale#handlers#alex#DefineLinter('nroff', '--text') diff --git a/sources_non_forked/ale/ale_linters/nroff/proselint.vim b/sources_non_forked/ale/ale_linters/nroff/proselint.vim new file mode 100644 index 00000000..a23e56b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nroff/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for nroff files + +call ale#linter#Define('nroff', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/nroff/writegood.vim b/sources_non_forked/ale/ale_linters/nroff/writegood.vim new file mode 100644 index 00000000..bcf344f6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/nroff/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for nroff files + +call ale#handlers#writegood#DefineLinter('nroff') diff --git a/sources_non_forked/ale/ale_linters/objc/ccls.vim b/sources_non_forked/ale/ale_linters/objc/ccls.vim new file mode 100644 index 00000000..7aef5325 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objc/ccls.vim @@ -0,0 +1,15 @@ +" Author: Ye Jingchen , Ben Falconer , jtalowell +" Description: A language server for Objective-C + +call ale#Set('objc_ccls_executable', 'ccls') +call ale#Set('objc_ccls_init_options', {}) +call ale#Set('c_build_dir', '') + +call ale#linter#Define('objc', { +\ 'name': 'ccls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'objc_ccls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale#handlers#ccls#GetProjectRoot'), +\ 'initialization_options': {b -> ale#handlers#ccls#GetInitOpts(b, 'objc_ccls_init_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/objc/clang.vim b/sources_non_forked/ale/ale_linters/objc/clang.vim new file mode 100644 index 00000000..cafb97db --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objc/clang.vim @@ -0,0 +1,23 @@ +" Author: Bang Lee +" Description: clang linter for objc files + +" Set this option to change the Clang options for warnings for ObjC. +if !exists('g:ale_objc_clang_options') + let g:ale_objc_clang_options = '-std=c11 -Wall' +endif + +function! ale_linters#objc#clang#GetCommand(buffer) abort + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + return 'clang -S -x objective-c -fsyntax-only ' + \ . '-iquote %s:h' + \ . ' ' . ale#Var(a:buffer, 'objc_clang_options') . ' -' +endfunction + +call ale#linter#Define('objc', { +\ 'name': 'clang', +\ 'output_stream': 'stderr', +\ 'executable': 'clang', +\ 'command': function('ale_linters#objc#clang#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/objc/clangd.vim b/sources_non_forked/ale/ale_linters/objc/clangd.vim new file mode 100644 index 00000000..318d85b5 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objc/clangd.vim @@ -0,0 +1,17 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('objc_clangd_executable', 'clangd') +call ale#Set('objc_clangd_options', '') + +function! ale_linters#objc#clangd#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'objc_clangd_options')) +endfunction + +call ale#linter#Define('objc', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'objc_clangd_executable')}, +\ 'command': function('ale_linters#objc#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/objcpp/clang.vim b/sources_non_forked/ale/ale_linters/objcpp/clang.vim new file mode 100644 index 00000000..35a40c6f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objcpp/clang.vim @@ -0,0 +1,23 @@ +" Author: Bang Lee +" Description: clang linter for objcpp files + +" Set this option to change the Clang options for warnings for ObjCPP. +if !exists('g:ale_objcpp_clang_options') + let g:ale_objcpp_clang_options = '-std=c++14 -Wall' +endif + +function! ale_linters#objcpp#clang#GetCommand(buffer) abort + " -iquote with the directory the file is in makes #include work for + " headers in the same directory. + return 'clang++ -S -x objective-c++ -fsyntax-only ' + \ . '-iquote %s:h' + \ . ' ' . ale#Var(a:buffer, 'objcpp_clang_options') . ' -' +endfunction + +call ale#linter#Define('objcpp', { +\ 'name': 'clang', +\ 'output_stream': 'stderr', +\ 'executable': 'clang++', +\ 'command': function('ale_linters#objcpp#clang#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes', +\}) diff --git a/sources_non_forked/ale/ale_linters/objcpp/clangd.vim b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim new file mode 100644 index 00000000..29455325 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/objcpp/clangd.vim @@ -0,0 +1,17 @@ +" Author: Andrey Melentyev +" Description: Clangd language server + +call ale#Set('objcpp_clangd_executable', 'clangd') +call ale#Set('objcpp_clangd_options', '') + +function! ale_linters#objcpp#clangd#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'objcpp_clangd_options')) +endfunction + +call ale#linter#Define('objcpp', { +\ 'name': 'clangd', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'objcpp_clangd_executable')}, +\ 'command': function('ale_linters#objcpp#clangd#GetCommand'), +\ 'project_root': function('ale#c#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/merlin.vim b/sources_non_forked/ale/ale_linters/ocaml/merlin.vim new file mode 100644 index 00000000..cfec9966 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocaml/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in OCaml code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#ocaml#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('ocaml', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#ocaml#merlin#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim new file mode 100644 index 00000000..4ff7419c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocaml', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocaml/ols.vim b/sources_non_forked/ale/ale_linters/ocaml/ols.vim new file mode 100644 index 00000000..ec71bdb4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocaml/ols.vim @@ -0,0 +1,14 @@ +" Author: Michael Jungo +" Description: A language server for OCaml + +call ale#Set('ocaml_ols_executable', 'ocaml-language-server') +call ale#Set('ocaml_ols_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('ocaml', { +\ 'name': 'ols', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ols#GetExecutable'), +\ 'command': function('ale#handlers#ols#GetCommand'), +\ 'language': function('ale#handlers#ols#GetLanguage'), +\ 'project_root': function('ale#handlers#ols#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim new file mode 100644 index 00000000..799490f7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in OCaml code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#ocamlinterface#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#ocamlinterface#merlin#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim new file mode 100644 index 00000000..cd4bea80 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ocamlinterface/ocamllsp.vim @@ -0,0 +1,13 @@ +" Author: Risto Stevcev +" Description: The official language server for OCaml + +call ale#Set('ocaml_ocamllsp_use_opam', 1) + +call ale#linter#Define('ocamlinterface', { +\ 'name': 'ocamllsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'), +\ 'command': function('ale#handlers#ocamllsp#GetCommand'), +\ 'language': function('ale#handlers#ocamllsp#GetLanguage'), +\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim new file mode 100644 index 00000000..446931a2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim @@ -0,0 +1,58 @@ +" Author: Horacio Sanson + +call ale#Set('openapi_ibm_validator_executable', 'lint-openapi') +call ale#Set('openapi_ibm_validator_options', '') + +function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options')) + \ . ' %t' +endfunction + +function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort + let l:output = [] + let l:type = 'E' + let l:message = '' + let l:nr = -1 + + for l:line in a:lines + let l:match = matchlist(l:line, '^errors$') + + if !empty(l:match) + let l:type = 'E' + endif + + let l:match = matchlist(l:line, '^warnings$') + + if !empty(l:match) + let l:type = 'W' + endif + + let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$') + + if !empty(l:match) + let l:message = l:match[1] + endif + + let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$') + + if !empty(l:match) + let l:nr = l:match[1] + + call add(l:output, { + \ 'lnum': l:nr + 0, + \ 'col': 0, + \ 'text': l:message, + \ 'type': l:type, + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('openapi', { +\ 'name': 'ibm_validator', +\ 'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')}, +\ 'command': function('ale_linters#openapi#ibm_validator#GetCommand'), +\ 'callback': 'ale_linters#openapi#ibm_validator#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/openapi/yamllint.vim b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim new file mode 100644 index 00000000..2b8952cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openapi/yamllint.vim @@ -0,0 +1,9 @@ +call ale#Set('yaml_yamllint_executable', 'yamllint') +call ale#Set('yaml_yamllint_options', '') + +call ale#linter#Define('openapi', { +\ 'name': 'yamllint', +\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/openscad/sca2d.vim b/sources_non_forked/ale/ale_linters/openscad/sca2d.vim new file mode 100644 index 00000000..60804a13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/openscad/sca2d.vim @@ -0,0 +1,24 @@ +" Description: SCA2D linter for OpenSCAD files + +call ale#Set('openscad_sca2d_executable', 'sca2d') +call ale#Set('openscad_sca2d_options', '') + +function! ale_linters#openscad#sca2d#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'openscad_sca2d_executable') +endfunction + +function! ale_linters#openscad#sca2d#GetCommand(buffer) abort + let l:executable = ale_linters#openscad#sca2d#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'openscad_sca2d_options') + + return ale#Escape(l:executable) . ale#Pad(l:options) . ' %s' +endfunction + +call ale#linter#Define('openscad', { +\ 'name': 'SCA2D', +\ 'aliases': ['sca2d'], +\ 'executable': function('ale_linters#openscad#sca2d#GetExecutable'), +\ 'command': function('ale_linters#openscad#sca2d#GetCommand'), +\ 'callback': 'ale#handlers#openscad#SCA2D_callback', +\ 'lint_file': 1, +\ }) diff --git a/sources_non_forked/ale/ale_linters/perl/perl.vim b/sources_non_forked/ale/ale_linters/perl/perl.vim new file mode 100644 index 00000000..0f06528a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/perl/perl.vim @@ -0,0 +1,64 @@ +" Author: Vincent Lequertier +" Description: This file adds support for checking perl syntax + +call ale#Set('perl_perl_executable', 'perl') +call ale#Set('perl_perl_options', '-c -Mwarnings -Ilib') + +function! ale_linters#perl#perl#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'perl_perl_options')) . ' %t' +endfunction + +let s:begin_failed_skip_pattern = '\v' . join([ +\ '^Compilation failed in require', +\ '^Can''t locate', +\], '|') + +function! ale_linters#perl#perl#Handle(buffer, lines) abort + if empty(a:lines) + return [] + endif + + let l:pattern = '\(..\{-}\) at \(..\{-}\) line \(\d\+\)' + let l:output = [] + let l:basename = expand('#' . a:buffer . ':t') + + let l:type = 'E' + + if a:lines[-1] =~# 'syntax OK' + let l:type = 'W' + endif + + let l:seen = {} + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:line = l:match[3] + let l:file = l:match[2] + let l:text = l:match[1] + + if ale#path#IsBufferPath(a:buffer, l:file) + \ && !has_key(l:seen,l:line) + \ && ( + \ l:text isnot# 'BEGIN failed--compilation aborted' + \ || empty(l:output) + \ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0 + \ ) + call add(l:output, { + \ 'lnum': l:line, + \ 'text': l:text, + \ 'type': l:type, + \}) + + let l:seen[l:line] = 1 + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('perl', { +\ 'name': 'perl', +\ 'executable': {b -> ale#Var(b, 'perl_perl_executable')}, +\ 'output_stream': 'both', +\ 'command': function('ale_linters#perl#perl#GetCommand'), +\ 'callback': 'ale_linters#perl#perl#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/perl/perlcritic.vim b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim new file mode 100644 index 00000000..f3154c09 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/perl/perlcritic.vim @@ -0,0 +1,61 @@ +" Author: Vincent Lequertier , Chris Weyl +" Description: This file adds support for checking perl with perl critic + +call ale#Set('perl_perlcritic_executable', 'perlcritic') +call ale#Set('perl_perlcritic_profile', '.perlcriticrc') +call ale#Set('perl_perlcritic_options', '') +call ale#Set('perl_perlcritic_showrules', 0) + +function! ale_linters#perl#perlcritic#GetProfile(buffer) abort + " first see if we've been overridden + let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile') + + if l:profile is? '' + return '' + endif + + " otherwise, iterate upwards to find it + return ale#path#FindNearestFile(a:buffer, l:profile) +endfunction + +function! ale_linters#perl#perlcritic#GetCommand(buffer) abort + let l:critic_verbosity = '%l:%c %m\n' + + if ale#Var(a:buffer, 'perl_perlcritic_showrules') + let l:critic_verbosity = '%l:%c %m [%p]\n' + endif + + let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer) + let l:options = ale#Var(a:buffer, 'perl_perlcritic_options') + + return '%e' + \ . ' --verbose ' . ale#Escape(l:critic_verbosity) + \ . ' --nocolor' + \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '') + \ . ale#Pad(l:options) +endfunction + + +function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort + let l:pattern = '\(\d\+\):\(\d\+\) \(.\+\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1], + \ 'col': l:match[2], + \ 'text': l:match[3], + \ 'type': 'W' + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('perl', { +\ 'name': 'perlcritic', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'perl_perlcritic_executable')}, +\ 'command': function('ale_linters#perl#perlcritic#GetCommand'), +\ 'callback': 'ale_linters#perl#perlcritic#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/perl6/perl6.vim b/sources_non_forked/ale/ale_linters/perl6/perl6.vim new file mode 100644 index 00000000..444ae4d7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/perl6/perl6.vim @@ -0,0 +1,166 @@ +" Author:Travis Gibson +" Description: This file adds support for checking perl6 syntax + +let g:ale_perl6_perl6_executable = +\ get(g:, 'ale_perl6_perl6_executable', 'perl6') + +let g:ale_perl6_perl6_options = +\ get(g:, 'ale_perl6_perl6_options', '-c -Ilib') + +let $PERL6_EXCEPTIONS_HANDLER = 'JSON' + +let $RAKUDO_ERROR_COLOR = 0 + +function! ale_linters#perl6#perl6#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'perl6_perl6_executable') +endfunction + +function! ale_linters#perl6#perl6#GetCommand(buffer) abort + return ale_linters#perl6#perl6#GetExecutable(a:buffer) + \ . ' ' . ale#Var(a:buffer, 'perl6_perl6_options') + \ . ' %t' +endfunction + +function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort + let l:file = '' + let l:line = 1 + let l:column = '' + let l:text = '' + let l:pre = '' + let l:counter = 2 + let l:end_line = '' + let l:linepatternmessage = 'at\s\+line\s\+\(\d\+\)' + + if has_key(a:dict[a:item], 'filename') && !empty(a:dict[a:item]['filename']) + let l:file = a:dict[a:item]['filename'] + endif + + if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line']) + let l:line = a:dict[a:item]['line'] + let l:counter -= 1 + endif + + if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column']) + let l:column = a:dict[a:item]['column'] + endif + + if has_key(a:dict[a:item], 'message') && !empty(a:dict[a:item]['message']) + let l:text = substitute(a:dict[a:item]['message'], '\s*\n\s*', ' ', 'g') + let l:counter -= 1 + endif + + if has_key(a:dict[a:item], 'line-real') && !empty(a:dict[a:item]['line-real']) + let l:end_line = l:line + let l:line = a:dict[a:item]['line-real'] + endif + + for l:match in ale#util#GetMatches(l:text, l:linepatternmessage) + let l:line = l:match[1] + let l:counter -= 1 + endfor + +" Currently, filenames and line numbers are not always given in the error output + if l:counter < 2 + \&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) + return { + \ 'lnum': '' . l:line, + \ 'text': l:text, + \ 'type': a:type, + \ 'col': l:column, + \ 'end_lnum': l:end_line, + \ 'code': a:item, + \} + endif + + return '' +endfunction + +function! ale_linters#perl6#perl6#Handle(buffer, lines) abort + let l:output = [] + + if empty(a:lines) + return l:output + endif + + if a:lines[0] is# 'Syntax OK' + return l:output + endif + + try + let l:json = json_decode(join(a:lines, '')) + catch /E474\|E491/ + call add(l:output, { + \ 'lnum': '1', + \ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details', + \ 'detail': join(a:lines, "\n"), + \ 'type': 'W', + \ }) + + return l:output + endtry + + if type(l:json) is v:t_dict + for l:key in keys(l:json) + if has_key(l:json[l:key], 'sorrows') + \&& has_key(l:json[l:key], 'worries') + if !empty(l:json[l:key]['sorrows']) + for l:dictionary in get(l:json[l:key], 'sorrows') + for l:item in keys(l:dictionary) + let l:result = + \ ale_linters#perl6#perl6#ExtractError( + \ l:dictionary, + \ l:item, + \ 'E', + \ a:buffer, + \ ) + + if l:result isnot# '' + call add(l:output, l:result) + endif + endfor + endfor + endif + + if !empty(l:json[l:key]['worries']) + for l:dictionary in get(l:json[l:key], 'worries') + for l:item in keys(l:dictionary) + let l:result = + \ ale_linters#perl6#perl6#ExtractError( + \ l:dictionary, + \ l:item, + \ 'W', + \ a:buffer, + \ ) + + if l:result isnot# '' + call add(l:output, l:result) + endif + endfor + endfor + endif + else + let l:result = ale_linters#perl6#perl6#ExtractError( + \ l:json, + \ l:key, + \ 'E', + \ a:buffer, + \ ) + + if l:result isnot# '' + call add(l:output, l:result) + endif + endif + endfor + endif + + return l:output +endfunction + +call ale#linter#Define('perl6', { +\ 'name': 'perl6', +\ 'executable': function('ale_linters#perl6#perl6#GetExecutable'), +\ 'output_stream': 'both', +\ 'command': function('ale_linters#perl6#perl6#GetCommand'), +\ 'callback': 'ale_linters#perl6#perl6#Handle', +\}) + diff --git a/sources_non_forked/ale/ale_linters/php/cspell.vim b/sources_non_forked/ale/ale_linters/php/cspell.vim new file mode 100644 index 00000000..574df575 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for PHP files. + +call ale#handlers#cspell#DefineLinter('php') diff --git a/sources_non_forked/ale/ale_linters/php/intelephense.vim b/sources_non_forked/ale/ale_linters/php/intelephense.vim new file mode 100644 index 00000000..0fdcc93e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/intelephense.vim @@ -0,0 +1,32 @@ +" Author: Eric Stern , +" Arnold Chand +" Description: Intelephense language server integration for ALE + +call ale#Set('php_intelephense_executable', 'intelephense') +call ale#Set('php_intelephense_use_global', 1) +call ale#Set('php_intelephense_config', {}) + +function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#intelephense#GetInitializationOptions(buffer) abort + return ale#Var(a:buffer, 'php_intelephense_config') +endfunction + +call ale#linter#Define('php', { +\ 'name': 'intelephense', +\ 'lsp': 'stdio', +\ 'initialization_options': function('ale_linters#php#intelephense#GetInitializationOptions'), +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_intelephense', [])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#php#intelephense#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/langserver.vim b/sources_non_forked/ale/ale_linters/php/langserver.vim new file mode 100644 index 00000000..c3d89a00 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/langserver.vim @@ -0,0 +1,27 @@ +" Author: Eric Stern +" Description: PHP Language server integration for ALE + +call ale#Set('php_langserver_executable', 'php-language-server.php') +call ale#Set('php_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#php#langserver#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('php', { +\ 'name': 'langserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_langserver', [ +\ 'vendor/bin/php-language-server.php', +\ ])}, +\ 'command': 'php %e', +\ 'project_root': function('ale_linters#php#langserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phan.vim b/sources_non_forked/ale/ale_linters/php/phan.vim new file mode 100644 index 00000000..50c6d6e6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phan.vim @@ -0,0 +1,75 @@ +" Author: diegoholiveira , haginaga +" Description: static analyzer for PHP + +" Define the minimum severity +let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0) + +let g:ale_php_phan_executable = get(g:, 'ale_php_phan_executable', 'phan') +let g:ale_php_phan_use_client = get(g:, 'ale_php_phan_use_client', 0) + +function! ale_linters#php#phan#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'php_phan_executable') + + if ale#Var(a:buffer, 'php_phan_use_client') == 1 && l:executable is# 'phan' + let l:executable = 'phan_client' + endif + + return l:executable +endfunction + +function! ale_linters#php#phan#GetCommand(buffer) abort + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + let l:args = '-l ' + \ . ' %s' + else + let l:args = '-y ' + \ . ale#Var(a:buffer, 'php_phan_minimum_severity') + \ . ' %s' + endif + + let l:executable = ale_linters#php#phan#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:args +endfunction + +function! ale_linters#php#phan#Handle(buffer, lines) abort + " Matches against lines like the following: + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + " Phan error: ERRORTYPE: message in /path/to/some-filename.php on line nnn + let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$' + else + " /path/to/some-filename.php:18 ERRORTYPE message + let l:pattern = '^\(.*\):\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + endif + + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if ale#Var(a:buffer, 'php_phan_use_client') == 1 + let l:dict = { + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[2], + \ 'filename': l:match[3], + \ 'type': 'W', + \} + else + let l:dict = { + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': 'W', + \ 'filename': l:match[1], + \} + endif + + call add(l:output, l:dict) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phan', +\ 'executable': function('ale_linters#php#phan#GetExecutable'), +\ 'command': function('ale_linters#php#phan#GetCommand'), +\ 'callback': 'ale_linters#php#phan#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/php/php.vim b/sources_non_forked/ale/ale_linters/php/php.vim new file mode 100644 index 00000000..51a109b9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/php.vim @@ -0,0 +1,39 @@ +" Author: Spencer Wood , Adriaan Zonnenberg +" Description: This file adds support for checking PHP with php-cli + +call ale#Set('php_php_executable', 'php') + +function! ale_linters#php#php#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " PHP 7.1<= - Parse error: syntax error, unexpected ';', expecting ']' in - on line 15 + " PHP 7.2>= - Parse error: syntax error, unexpected ';', expecting ']' in Standard input code on line 15 + let l:pattern = '\v^%(Fatal|Parse) error:\s+(.+unexpected ''(.+)%(expecting.+)@ ale#Var(b, 'php_php_executable')}, +\ 'output_stream': 'stdout', +\ 'command': '%e -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --', +\ 'callback': 'ale_linters#php#php#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpactor.vim b/sources_non_forked/ale/ale_linters/php/phpactor.vim new file mode 100644 index 00000000..b137eaf1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phpactor.vim @@ -0,0 +1,23 @@ +" Author: Arizard +" Description: PHPactor integration for ALE + +" Copied from langserver.vim +function! ale_linters#php#phpactor#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpactor', +\ 'lsp': 'stdio', +\ 'executable': 'phpactor', +\ 'command': '%e language-server', +\ 'project_root': function('ale_linters#php#phpactor#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpcs.vim b/sources_non_forked/ale/ale_linters/php/phpcs.vim new file mode 100644 index 00000000..ce47a13b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phpcs.vim @@ -0,0 +1,54 @@ +" Author: jwilliams108 , Eric Stern +" Description: phpcs for PHP files + +let g:ale_php_phpcs_standard = get(g:, 'ale_php_phpcs_standard', '') + +call ale#Set('php_phpcs_options', '') +call ale#Set('php_phpcs_executable', 'phpcs') +call ale#Set('php_phpcs_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#php#phpcs#GetCommand(buffer) abort + let l:standard = ale#Var(a:buffer, 'php_phpcs_standard') + let l:standard_option = !empty(l:standard) + \ ? '--standard=' . ale#Escape(l:standard) + \ : '' + + return '%e -s --report=emacs --stdin-path=%s' + \ . ale#Pad(l:standard_option) + \ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options')) +endfunction + +function! ale_linters#php#phpcs#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " /path/to/some-filename.php:18:3: error - Line indented incorrectly; expected 4 spaces, found 2 (Generic.WhiteSpace.ScopeIndent.IncorrectExact) + let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) - \(.\+\) (\(.\+\)).*$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[5] + let l:text = l:match[4] . ' (' . l:code . ')' + let l:type = l:match[3] + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:text, + \ 'type': l:type is# 'error' ? 'E' : 'W', + \ 'sub_type': 'style', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpcs', +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_phpcs', [ +\ 'vendor/bin/phpcs', +\ 'phpcs' +\ ])}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#php#phpcs#GetCommand'), +\ 'callback': 'ale_linters#php#phpcs#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpmd.vim b/sources_non_forked/ale/ale_linters/php/phpmd.vim new file mode 100644 index 00000000..9b1d1e44 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phpmd.vim @@ -0,0 +1,38 @@ +" Author: medains , David Sierra +" Description: phpmd for PHP files + +let g:ale_php_phpmd_executable = get(g:, 'ale_php_phpmd_executable', 'phpmd') + +" Set to change the ruleset +let g:ale_php_phpmd_ruleset = get(g:, 'ale_php_phpmd_ruleset', 'cleancode,codesize,controversial,design,naming,unusedcode') + +function! ale_linters#php#phpmd#GetCommand(buffer) abort + return '%e %s text' + \ . ale#Pad(ale#Var(a:buffer, 'php_phpmd_ruleset')) + \ . ' --ignore-violations-on-exit %t' +endfunction + +function! ale_linters#php#phpmd#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " /path/to/some-filename.php:18 message + let l:pattern = '^.*:\(\d\+\)\s\+\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[2], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpmd', +\ 'executable': {b -> ale#Var(b, 'php_phpmd_executable')}, +\ 'command': function('ale_linters#php#phpmd#GetCommand'), +\ 'callback': 'ale_linters#php#phpmd#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/php/phpstan.vim b/sources_non_forked/ale/ale_linters/php/phpstan.vim new file mode 100644 index 00000000..4dce5d5f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/phpstan.vim @@ -0,0 +1,89 @@ +" Author: medains , ardis , Arizard +" Description: phpstan for PHP files + +" Set to change the ruleset +let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpstan') +let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '') +let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '') +let g:ale_php_phpstan_autoload = get(g:, 'ale_php_phpstan_autoload', '') +let g:ale_php_phpstan_memory_limit = get(g:, 'ale_php_phpstan_memory_limit', '') +call ale#Set('php_phpstan_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#php#phpstan#GetCommand(buffer, version) abort + let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration') + let l:configuration_option = !empty(l:configuration) + \ ? ' -c ' . ale#Escape(l:configuration) + \ : '' + + let l:autoload = ale#Var(a:buffer, 'php_phpstan_autoload') + let l:autoload_option = !empty(l:autoload) + \ ? ' -a ' . ale#Escape(l:autoload) + \ : '' + + let l:memory_limit = ale#Var(a:buffer, 'php_phpstan_memory_limit') + let l:memory_limit_option = !empty(l:memory_limit) + \ ? ' --memory-limit ' . ale#Escape(l:memory_limit) + \ : '' + + let l:level = ale#Var(a:buffer, 'php_phpstan_level') + let l:config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon') + let l:dist_config_file_exists = ale#path#FindNearestFile(a:buffer, 'phpstan.neon.dist') + + if empty(l:level) && empty(l:config_file_exists) && empty(l:dist_config_file_exists) + " if no configuration file is found, then use 4 as a default level + let l:level = '4' + endif + + let l:level_option = !empty(l:level) + \ ? ' -l ' . ale#Escape(l:level) + \ : '' + + let l:error_format = ale#semver#GTE(a:version, [0, 10, 3]) + \ ? ' --error-format json' + \ : ' --errorFormat json' + + return '%e analyze --no-progress' + \ . l:error_format + \ . l:configuration_option + \ . l:autoload_option + \ . l:level_option + \ . l:memory_limit_option + \ . ' %s' +endfunction + +function! ale_linters#php#phpstan#Handle(buffer, lines) abort + let l:res = ale#util#FuzzyJSONDecode(a:lines, {'files': []}) + let l:output = [] + + if type(l:res.files) is v:t_list + return l:output + endif + + for l:err in l:res.files[expand('#' . a:buffer .':p')].messages + call add(l:output, { + \ 'lnum': l:err.line, + \ 'text': l:err.message, + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phpstan', +\ 'executable': {buffer -> ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ])}, +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#path#FindExecutable(buffer, 'php_phpstan', [ +\ 'vendor/bin/phpstan', +\ 'phpstan' +\ ]), +\ '%e --version', +\ function('ale_linters#php#phpstan#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#php#phpstan#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/php/psalm.vim b/sources_non_forked/ale/ale_linters/php/psalm.vim new file mode 100644 index 00000000..f1280057 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/psalm.vim @@ -0,0 +1,32 @@ +" Author: Matt Brown +" Description: plugin for Psalm, static analyzer for PHP + +call ale#Set('php_psalm_executable', 'psalm') +call ale#Set('php_psalm_options', '') +call ale#Set('php_psalm_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#php#psalm#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if (!empty(l:composer_path)) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#psalm#GetCommand(buffer) abort + return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'php_psalm_options')) +endfunction + +call ale#linter#Define('php', { +\ 'name': 'psalm', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'php_psalm', [ +\ 'vendor/bin/psalm', +\ ])}, +\ 'command': function('ale_linters#php#psalm#GetCommand'), +\ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/php/tlint.vim b/sources_non_forked/ale/ale_linters/php/tlint.vim new file mode 100644 index 00000000..80bdd1f6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/php/tlint.vim @@ -0,0 +1,80 @@ +" Author: Jose Soto +" +" Description: Tighten Opinionated PHP Linting +" Website: https://github.com/tightenco/tlint + +call ale#Set('php_tlint_executable', 'tlint') +call ale#Set('php_tlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_tlint_options', '') + +function! ale_linters#php#tlint#GetProjectRoot(buffer) abort + let l:composer_path = ale#path#FindNearestFile(a:buffer, 'composer.json') + + if !empty(l:composer_path) + return fnamemodify(l:composer_path, ':h') + endif + + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#php#tlint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_tlint', [ + \ 'vendor/bin/tlint', + \ 'tlint', + \]) +endfunction + +function! ale_linters#php#tlint#GetCommand(buffer) abort + let l:executable = ale_linters#php#tlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'php_tlint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' lint %s' +endfunction + +function! ale_linters#php#tlint#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " ! There should be 1 space around `.` concatenations, and additional lines should always start with a `.` + " 22 : ` $something = 'a'.'name';` + " + let l:loop_count = 0 + let l:messages_pattern = '^\! \(.*\)' + let l:output = [] + let l:pattern = '^\(\d\+\) \:' + let l:temp_messages = [] + + for l:message in ale#util#GetMatches(a:lines, l:messages_pattern) + call add(l:temp_messages, l:message) + endfor + + let l:loop_count = 0 + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:num = l:match[1] + let l:text = l:temp_messages[l:loop_count] + + call add(l:output, { + \ 'lnum': l:num, + \ 'col': 0, + \ 'text': l:text, + \ 'type': 'W', + \ 'sub_type': 'style', + \}) + + let l:loop_count += 1 + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'tlint', +\ 'executable': function('ale_linters#php#tlint#GetExecutable'), +\ 'command': function('ale_linters#php#tlint#GetCommand'), +\ 'callback': 'ale_linters#php#tlint#Handle', +\ 'project_root': function('ale_linters#php#tlint#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/po/alex.vim b/sources_non_forked/ale/ale_linters/po/alex.vim new file mode 100644 index 00000000..05c67f15 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/po/alex.vim @@ -0,0 +1,4 @@ +" Author: Cian Butler https://github.com/butlerx +" Description: alex for PO files + +call ale#handlers#alex#DefineLinter('po', '--text') diff --git a/sources_non_forked/ale/ale_linters/po/msgfmt.vim b/sources_non_forked/ale/ale_linters/po/msgfmt.vim new file mode 100644 index 00000000..8279ccdc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/po/msgfmt.vim @@ -0,0 +1,30 @@ +" Author: Cian Butler https://github.com/butlerx +" Description: msgfmt for PO files + +function! ale_linters#po#msgfmt#Handle(buffer, lines) abort + let l:results = ale#handlers#unix#HandleAsWarning(a:buffer, a:lines) + let l:index = 0 + + for l:item in l:results + if l:index > 0 && l:item.text =~? 'this is the location of the first definition' + let l:last_item = l:results[l:index - 1] + + if l:last_item.text =~? 'duplicate message definition' + let l:last_item.text = 'duplicate of message at line ' . l:item.lnum + let l:item.text = 'first location of duplicate of message at line ' . l:last_item.lnum + endif + endif + + let l:index += 1 + endfor + + return l:results +endfunction + +call ale#linter#Define('po', { +\ 'name': 'msgfmt', +\ 'executable': 'msgfmt', +\ 'output_stream': 'stderr', +\ 'command': 'msgfmt --statistics --output-file=- %t', +\ 'callback': 'ale_linters#po#msgfmt#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/po/proselint.vim b/sources_non_forked/ale/ale_linters/po/proselint.vim new file mode 100644 index 00000000..ce132508 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/po/proselint.vim @@ -0,0 +1,9 @@ +" Author: Cian Butler https://github.com/butlerx +" Description: proselint for PO files + +call ale#linter#Define('po', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/po/writegood.vim b/sources_non_forked/ale/ale_linters/po/writegood.vim new file mode 100644 index 00000000..14686473 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/po/writegood.vim @@ -0,0 +1,4 @@ +" Author: Cian Butler https://github.com/butlerx +" Description: write-good for PO files + +call ale#handlers#writegood#DefineLinter('po') diff --git a/sources_non_forked/ale/ale_linters/pod/alex.vim b/sources_non_forked/ale/ale_linters/pod/alex.vim new file mode 100644 index 00000000..c89f8330 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pod/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for pod files + +call ale#handlers#alex#DefineLinter('pod', '--text') diff --git a/sources_non_forked/ale/ale_linters/pod/proselint.vim b/sources_non_forked/ale/ale_linters/pod/proselint.vim new file mode 100644 index 00000000..2eb83f56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pod/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for Pod files + +call ale#linter#Define('pod', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/pod/writegood.vim b/sources_non_forked/ale/ale_linters/pod/writegood.vim new file mode 100644 index 00000000..9f5461e6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pod/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for Pod files + +call ale#handlers#writegood#DefineLinter('pod') diff --git a/sources_non_forked/ale/ale_linters/pony/ponyc.vim b/sources_non_forked/ale/ale_linters/pony/ponyc.vim new file mode 100644 index 00000000..6d4594f9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pony/ponyc.vim @@ -0,0 +1,16 @@ +" Description: ponyc linter for pony files + +call ale#Set('pony_ponyc_executable', 'ponyc') +call ale#Set('pony_ponyc_options', '--pass paint') + +function! ale_linters#pony#ponyc#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'pony_ponyc_options')) +endfunction + +call ale#linter#Define('pony', { +\ 'name': 'ponyc', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'pony_ponyc_executable')}, +\ 'command': function('ale_linters#pony#ponyc#GetCommand'), +\ 'callback': 'ale#handlers#pony#HandlePonycFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/powershell/cspell.vim b/sources_non_forked/ale/ale_linters/powershell/cspell.vim new file mode 100644 index 00000000..4a66dbaa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/powershell/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for PowerShell files. + +call ale#handlers#cspell#DefineLinter('powershell') diff --git a/sources_non_forked/ale/ale_linters/powershell/powershell.vim b/sources_non_forked/ale/ale_linters/powershell/powershell.vim new file mode 100644 index 00000000..5f49f72c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/powershell/powershell.vim @@ -0,0 +1,100 @@ +" Author: Jesse Harris - https://github.com/zigford +" Description: This file adds support for powershell scripts synatax errors + +call ale#Set('powershell_powershell_executable', 'pwsh') + +function! ale_linters#powershell#powershell#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'powershell_powershell_executable') +endfunction + +" Some powershell magic to show syntax errors without executing the script +" thanks to keith hill: +" https://rkeithhill.wordpress.com/2007/10/30/powershell-quicktip-preparsing-scripts-to-check-for-syntax-errors/ +function! ale_linters#powershell#powershell#GetCommand(buffer) abort + let l:script = ['Param($Script); + \ $ErrorView = "Normal"; + \ trap {$_;continue} & { + \ $Contents = Get-Content -Path $Script; + \ $Contents = [string]::Join([Environment]::NewLine, $Contents); + \ [void]$ExecutionContext.InvokeCommand.NewScriptBlock($Contents); + \ };'] + + return ale#powershell#RunPowerShell( + \ a:buffer, 'powershell_powershell', l:script) +endfunction + +" Parse powershell error output using regex into a list of dicts +function! ale_linters#powershell#powershell#Handle(buffer, lines) abort + let l:output = [] + " Our 3 patterns we need to scrape the data for the dicts + let l:patterns = [ + \ '\v^At line:(\d+) char:(\d+)', + \ '\v^(At|\+| )@!.*', + \ '\vFullyQualifiedErrorId : (\w+)', + \] + + let l:matchcount = 0 + + for l:match in ale#util#GetMatches(a:lines, l:patterns) + " We want to work with 3 matches per syntax error + let l:matchcount = l:matchcount + 1 + + if l:matchcount == 1 || str2nr(l:match[1]) + " First match consists of 2 capture groups, and + " can capture the line and col + if exists('l:item') + " We may be here because the last syntax + " didn't emit a code, and so only had 2 + " matches + call add(l:output, l:item) + let l:matchcount = 1 + endif + + " If the match is 0, it was a failed match + " probably due to an unexpected token which + " contained a newline. Reset matchcount. to + " continue to the next match + if !empty(l:match[1]) + let l:item = { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': 'E', + \} + else + let l:matchcount = 0 + endif + elseif l:matchcount == 2 + " Second match[0] grabs the full line in order + " to handles the text + let l:item['text'] = l:match[0] + else + " Final match handles the code, however + " powershell only emits 1 code for all errors + " so, we get the final code on the last error + " and loop over the previously added items to + " append the code we now know + call add(l:output, l:item) + unlet l:item + + if len(l:match[1]) > 0 + for l:i in l:output + let l:i['code'] = l:match[1] + endfor + endif + + " Reset the matchcount so we can begin gathering + " matches for the next syntax error + let l:matchcount = 0 + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('powershell', { +\ 'name': 'powershell', +\ 'executable': function('ale_linters#powershell#powershell#GetExecutable'), +\ 'command': function('ale_linters#powershell#powershell#GetCommand'), +\ 'output_stream': 'stdout', +\ 'callback': 'ale_linters#powershell#powershell#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim b/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim new file mode 100644 index 00000000..8a8b4b45 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/powershell/psscriptanalyzer.vim @@ -0,0 +1,76 @@ +" Author: Jesse Harris - https://github.com/zigford +" Description: This file adds support for lintng powershell scripts +" using the PSScriptAnalyzer module. + +" let g:ale_powershell_psscriptanalyzer_exclusions = +" \ 'PSAvoidUsingWriteHost,PSAvoidGlobalVars' +call ale#Set('powershell_psscriptanalyzer_exclusions', '') +call ale#Set('powershell_psscriptanalyzer_executable', 'pwsh') +call ale#Set('powershell_psscriptanalyzer_module', +\ 'psscriptanalyzer') + +function! ale_linters#powershell#psscriptanalyzer#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'powershell_psscriptanalyzer_executable') +endfunction + +" Run Invoke-ScriptAnalyzer and output each linting message as 4 separate lines +" for each parsing +function! ale_linters#powershell#psscriptanalyzer#GetCommand(buffer) abort + let l:exclude_option = ale#Var( + \ a:buffer, 'powershell_psscriptanalyzer_exclusions') + let l:module = ale#Var( + \ a:buffer, 'powershell_psscriptanalyzer_module') + let l:script = ['Param($Script); + \ Invoke-ScriptAnalyzer "$Script" ' + \ . (!empty(l:exclude_option) ? '-Exclude ' . l:exclude_option : '') + \ . '| ForEach-Object { + \ $_.Line; + \ $_.Severity; + \ $_.Message; + \ $_.RuleName}'] + + return ale#powershell#RunPowerShell( + \ a:buffer, + \ 'powershell_psscriptanalyzer', + \ l:script) +endfunction + +" add every 4 lines to an item(Dict) and every item to a list +" return the list +function! ale_linters#powershell#psscriptanalyzer#Handle(buffer, lines) abort + let l:output = [] + let l:lcount = 0 + + for l:line in a:lines + if l:lcount is# 0 + " the very first line + let l:item = {'lnum': str2nr(l:line)} + elseif l:lcount is# 1 + if l:line is# 'Error' + let l:item['type'] = 'E' + elseif l:line is# 'Information' + let l:item['type'] = 'I' + else + let l:item['type'] = 'W' + endif + elseif l:lcount is# 2 + let l:item['text'] = l:line + elseif l:lcount is# 3 + let l:item['code'] = l:line + call add(l:output, l:item) + let l:lcount = -1 + endif + + let l:lcount = l:lcount + 1 + endfor + + return l:output +endfunction + +call ale#linter#Define('powershell', { +\ 'name': 'psscriptanalyzer', +\ 'executable': function('ale_linters#powershell#psscriptanalyzer#GetExecutable'), +\ 'command': function('ale_linters#powershell#psscriptanalyzer#GetCommand'), +\ 'output_stream': 'stdout', +\ 'callback': 'ale_linters#powershell#psscriptanalyzer#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/prolog/swipl.vim b/sources_non_forked/ale/ale_linters/prolog/swipl.vim new file mode 100644 index 00000000..82859eb0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/prolog/swipl.vim @@ -0,0 +1,110 @@ +" Author: Takuya Fujiwara +" Description: swipl syntax / semantic check for Prolog files + +call ale#Set('prolog_swipl_executable', 'swipl') +call ale#Set('prolog_swipl_load', 'current_prolog_flag(argv, [File]), load_files(File, [sandboxed(true)]), halt.') +call ale#Set('prolog_swipl_timeout', 3) +call ale#Set('prolog_swipl_alarm', 'alarm(%t, (%h), _, [])') +call ale#Set('prolog_swipl_alarm_handler', 'writeln(user_error, "ERROR: Exceeded %t seconds, Please change g:prolog_swipl_timeout to modify the limit."), halt(1)') + +function! ale_linters#prolog#swipl#GetCommand(buffer) abort + let l:goals = ale#Var(a:buffer, 'prolog_swipl_load') + let l:goals = l:goals =~# '^\s*$' ? 'halt' : l:goals + let l:timeout = ale#Var(a:buffer, 'prolog_swipl_timeout') + 0 + + if l:timeout > 0 + let l:goals = s:GetAlarm(a:buffer, l:timeout) . ', ' . l:goals + endif + + return '%e -g ' . ale#Escape(l:goals) . ' -- %s' +endfunction + +function! s:GetAlarm(buffer, timeout) abort + let l:handler = ale#Var(a:buffer, 'prolog_swipl_alarm_handler') + let l:handler = s:Subst(l:handler, {'t': a:timeout}) + let l:alarm = ale#Var(a:buffer, 'prolog_swipl_alarm') + let l:alarm = s:Subst(l:alarm, {'t': a:timeout, 'h': l:handler}) + + return l:alarm +endfunction + +function! s:Subst(format, vars) abort + let l:vars = extend(copy(a:vars), {'%': '%'}) + + return substitute(a:format, '%\(.\)', '\=get(l:vars, submatch(1), "")', 'g') +endfunction + +function! ale_linters#prolog#swipl#Handle(buffer, lines) abort + let l:output = [] + let l:i = 0 + + let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$' + + while l:i < len(a:lines) + let l:match = matchlist(a:lines[l:i], l:pattern) + + if empty(l:match) + let l:i += 1 + continue + endif + + let [l:i, l:text] = s:GetErrMsg(l:i, a:lines, l:match[4]) + let l:item = { + \ 'lnum': (l:match[2] + 0 ? l:match[2] + 0 : 1), + \ 'col': l:match[3] + 0, + \ 'text': l:text, + \ 'type': (l:match[1] is# 'ERROR' ? 'E' : 'W'), + \} + + if !s:Ignore(l:item) + call add(l:output, l:item) + endif + endwhile + + return l:output +endfunction + +" This returns [, ] +function! s:GetErrMsg(i, lines, text) abort + if a:text !~# '^\s*$' + return [a:i + 1, a:text] + endif + + let l:i = a:i + 1 + let l:text = [] + + let l:pattern = '\v^(ERROR|Warning)?:?(.*)$' + + while l:i < len(a:lines) + let l:match = matchlist(a:lines[l:i], l:pattern) + + if empty(l:match) || empty(l:match[2]) + let l:i += 1 + break + endif + + call add(l:text, s:Trim(l:match[2])) + let l:i += 1 + endwhile + + return [l:i, join(l:text, '. ')] +endfunction + +function! s:Trim(str) abort + return substitute(a:str, '\v^\s+|\s+$', '', 'g') +endfunction + +" Skip sandbox error which is caused by directives +" because what we want is syntactic or semantic check. +function! s:Ignore(item) abort + return a:item.type is# 'E' + \ && a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' +endfunction + +call ale#linter#Define('prolog', { +\ 'name': 'swipl', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'prolog_swipl_executable')}, +\ 'command': function('ale_linters#prolog#swipl#GetCommand'), +\ 'callback': 'ale_linters#prolog#swipl#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/proto/buf_lint.vim b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim new file mode 100644 index 00000000..a22f8e53 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/buf_lint.vim @@ -0,0 +1,26 @@ +" Author: Alex McKinney +" Description: Run buf lint. + +call ale#Set('proto_buf_lint_executable', 'buf') +call ale#Set('proto_buf_lint_config', '') +call ale#Set('proto_buf_lint_options', '') + +function! ale_linters#proto#buf_lint#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'proto_buf_lint_config') + let l:options = ale#Var(a:buffer, 'proto_buf_lint_options') + + return '%e lint' + \ . (!empty(l:config) ? ' --config=' . ale#Escape(l:config) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %s#include_package_files=true' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'buf_lint', +\ 'aliases': ['buf-lint'], +\ 'lint_file': 1, +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'proto_buf_lint_executable')}, +\ 'command': function('ale_linters#proto#buf_lint#GetCommand'), +\ 'callback': 'ale#handlers#go#Handler', +\}) diff --git a/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim b/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim new file mode 100644 index 00000000..c3d10935 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/protoc_gen_lint.vim @@ -0,0 +1,27 @@ +" Author: Jeff Willette +" Description: run the protoc-gen-lint plugin for the protoc binary + +call ale#Set('proto_protoc_gen_lint_options', '') + +function! ale_linters#proto#protoc_gen_lint#GetCommand(buffer) abort + let l:dirname = expand('#' . a:buffer . ':p:h') + + let l:options = ['-I ' . ale#Escape(l:dirname)] + + if !empty(ale#Var(a:buffer, 'proto_protoc_gen_lint_options')) + let l:options += [ale#Var(a:buffer, 'proto_protoc_gen_lint_options')] + endif + + let l:options += ['--lint_out=. ' . '%s'] + + return 'protoc' . ' ' . join(l:options) +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'protoc-gen-lint', +\ 'lint_file': 1, +\ 'output_stream': 'stderr', +\ 'executable': 'protoc', +\ 'command': function('ale_linters#proto#protoc_gen_lint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) diff --git a/sources_non_forked/ale/ale_linters/proto/protolint.vim b/sources_non_forked/ale/ale_linters/proto/protolint.vim new file mode 100644 index 00000000..2754c7b6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/proto/protolint.vim @@ -0,0 +1,24 @@ +" Author: Yohei Yoshimuta +" Description: run the protolint for Protocol Buffer files + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale_linters#proto#protolint#GetCommand(buffer) abort + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return '%e lint' + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -reporter=unix' + \ . ' %s' +endfunction + +call ale#linter#Define('proto', { +\ 'name': 'protolint', +\ 'lint_file': 1, +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'proto_protolint_executable')}, +\ 'command': function('ale_linters#proto#protolint#GetCommand'), +\ 'callback': 'ale#handlers#unix#HandleAsError', +\}) + diff --git a/sources_non_forked/ale/ale_linters/pug/puglint.vim b/sources_non_forked/ale/ale_linters/pug/puglint.vim new file mode 100644 index 00000000..b552cc06 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pug/puglint.vim @@ -0,0 +1,56 @@ +" Author: w0rp - +" Description: pug-lint for checking Pug/Jade files. + +call ale#Set('pug_puglint_options', '') +call ale#Set('pug_puglint_executable', 'pug-lint') +call ale#Set('pug_puglint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! s:FindConfig(buffer) abort + for l:filename in [ + \ '.pug-lintrc', + \ '.pug-lintrc.js', + \ '.pug-lintrc.json', + \ 'package.json', + \] + let l:config = ale#path#FindNearestFile(a:buffer, l:filename) + + if !empty(l:config) + return l:config + endif + endfor + + return '' +endfunction + +function! ale_linters#pug#puglint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'pug_puglint_options') + let l:config = s:FindConfig(a:buffer) + + return '%e' . ale#Pad(l:options) + \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') + \ . ' -r inline %t' +endfunction + +function! ale_linters#pug#puglint#Handle(buffer, lines) abort + for l:line in a:lines[:10] + if l:line =~# '^SyntaxError: ' + return [{ + \ 'lnum': 1, + \ 'text': 'puglint configuration error (type :ALEDetail for more information)', + \ 'detail': join(a:lines, "\n"), + \}] + endif + endfor + + return ale#handlers#unix#HandleAsError(a:buffer, a:lines) +endfunction + +call ale#linter#Define('pug', { +\ 'name': 'puglint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'pug_puglint', [ +\ 'node_modules/.bin/pug-lint', +\ ])}, +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#pug#puglint#GetCommand'), +\ 'callback': 'ale_linters#pug#puglint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/puppet/languageserver.vim b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim new file mode 100644 index 00000000..2078695f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/puppet/languageserver.vim @@ -0,0 +1,37 @@ +" Author: Alexander Olofsson +" Description: Puppet Language Server integration for ALE + +call ale#Set('puppet_languageserver_executable', 'puppet-languageserver') + +function! ale_linters#puppet#languageserver#GetProjectRoot(buffer) abort + " Note: The metadata.json file is recommended for Puppet 4+ modules, but + " there's no requirement to have it, so fall back to the other possible + " Puppet module directories + let l:root_path = ale#path#FindNearestFile(a:buffer, 'metadata.json') + + if !empty(l:root_path) + return fnamemodify(l:root_path, ':h') + endif + + for l:test_path in [ + \ 'manifests', + \ 'templates', + \] + let l:root_path = ale#path#FindNearestDirectory(a:buffer, l:test_path) + + if !empty(l:root_path) + return fnamemodify(l:root_path, ':h:h') + endif + endfor + + return '' +endfunction + +call ale#linter#Define('puppet', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'puppet_languageserver_executable')}, +\ 'command': '%e --stdio', +\ 'language': 'puppet', +\ 'project_root': function('ale_linters#puppet#languageserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppet.vim b/sources_non_forked/ale/ale_linters/puppet/puppet.vim new file mode 100644 index 00000000..59228dc8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/puppet/puppet.vim @@ -0,0 +1,39 @@ +" Author: Alexander Olofsson + +call ale#Set('puppet_puppet_executable', 'puppet') +call ale#Set('puppet_puppet_options', '') + +function! ale_linters#puppet#puppet#Handle(buffer, lines) abort + " Matches patterns like the following: + " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 + " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5" + " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5) + " Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11) + " Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp) + let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[5] + 0, + \ 'col': l:match[7] + 0, + \ 'text': l:match[1], + \}) + endfor + + return l:output +endfunction + +function! ale_linters#puppet#puppet#GetCommand(buffer) abort + return '%e parser validate --color=false ' + \ . ale#Pad(ale#Var(a:buffer, 'puppet_puppet_options')) + \ . ' %t' +endfunction + +call ale#linter#Define('puppet', { +\ 'name': 'puppet', +\ 'executable': {b -> ale#Var(b, 'puppet_puppet_executable')}, +\ 'output_stream': 'stderr', +\ 'command': function('ale_linters#puppet#puppet#GetCommand'), +\ 'callback': 'ale_linters#puppet#puppet#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim new file mode 100644 index 00000000..985d6a4d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/puppet/puppetlint.vim @@ -0,0 +1,18 @@ +" Author: Alexander Olofsson , Robert Flechtner +" Description: puppet-lint for puppet files + +call ale#Set('puppet_puppetlint_executable', 'puppet-lint') +call ale#Set('puppet_puppetlint_options', '--no-autoloader_layout-check') + +function! ale_linters#puppet#puppetlint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'puppet_puppetlint_options')) + \ . ' --log-format "-:%{line}:%{column}: %{kind}: [%{check}] %{message}"' + \ . ' %t' +endfunction + +call ale#linter#Define('puppet', { +\ 'name': 'puppetlint', +\ 'executable': {b -> ale#Var(b, 'puppet_puppetlint_executable')}, +\ 'command': function('ale_linters#puppet#puppetlint#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/purescript/ls.vim b/sources_non_forked/ale/ale_linters/purescript/ls.vim new file mode 100644 index 00000000..a20fae47 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/purescript/ls.vim @@ -0,0 +1,49 @@ +" Author: Drew Olson +" Description: Integrate ALE with purescript-language-server. + +call ale#Set('purescript_ls_executable', 'purescript-language-server') +call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('purescript_ls_config', {}) + +function! ale_linters#purescript#ls#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'purescript_ls', [ + \ 'node_modules/.bin/purescript-language-server', + \]) +endfunction + +function! ale_linters#purescript#ls#GetCommand(buffer) abort + let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall') + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('purescript', { +\ 'name': 'purescript-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#purescript#ls#GetExecutable'), +\ 'command': function('ale_linters#purescript#ls#GetCommand'), +\ 'project_root': function('ale_linters#purescript#ls#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'purescript_ls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/pyrex/cython.vim b/sources_non_forked/ale/ale_linters/pyrex/cython.vim new file mode 100644 index 00000000..247c3060 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/pyrex/cython.vim @@ -0,0 +1,36 @@ +" Author: w0rp , +" Nicolas Pauss +" Description: cython syntax checking for cython files. + +call ale#Set('pyrex_cython_executable', 'cython') +call ale#Set('pyrex_cython_options', '--warning-extra') + +function! ale_linters#pyrex#cython#GetCommand(buffer) abort + return '%e --working %s:h --include-dir %s:h' + \ . ale#Pad(ale#Var(a:buffer, 'pyrex_cython_options')) + \ . ' --output-file ' . g:ale#util#nul_file . ' %t' +endfunction + +function! ale_linters#pyrex#cython#Handle(buffer, lines) abort + let l:pattern = '\v^(\w+: )?[^:]+:(\d+):?(\d+)?:? ?(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': l:match[1][0] is# 'w' ? 'W' : 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('pyrex', { +\ 'name': 'cython', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'pyrex_cython_executable')}, +\ 'command': function('ale_linters#pyrex#cython#GetCommand'), +\ 'callback': 'ale_linters#pyrex#cython#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/bandit.vim b/sources_non_forked/ale/ale_linters/python/bandit.vim new file mode 100644 index 00000000..9cfca7c0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/bandit.vim @@ -0,0 +1,76 @@ +" Author: Martino Pilia +" Description: bandit linting for python files + +call ale#Set('python_bandit_executable', 'bandit') +call ale#Set('python_bandit_options', '') +call ale#Set('python_bandit_use_config', 1) +call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_bandit_auto_pipenv', 0) +call ale#Set('python_bandit_auto_poetry', 0) + +function! ale_linters#python#bandit#GetExecutable(buffer) abort + if ( + \ ale#Var(a:buffer, 'python_auto_pipenv') + \ || ale#Var(a:buffer, 'python_bandit_auto_pipenv') + \) && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if ( + \ ale#Var(a:buffer, 'python_auto_poetry') + \ || ale#Var(a:buffer, 'python_bandit_auto_poetry') + \) && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit']) +endfunction + +function! ale_linters#python#bandit#GetCommand(buffer) abort + let l:executable = ale_linters#python#bandit#GetExecutable(a:buffer) + let l:flags = ' --format custom' + \ . ' --msg-template "{line}:{test_id}:{severity}:{msg}" ' + + if ale#Var(a:buffer, 'python_bandit_use_config') + let l:config_path = ale#path#FindNearestFile(a:buffer, '.bandit') + + if !empty(l:config_path) + let l:flags = ' --ini ' . ale#Escape(l:config_path) . l:flags + endif + endif + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run bandit' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . l:flags + \ . ale#Pad(ale#Var(a:buffer, 'python_bandit_options')) + \ . ' -' +endfunction + +function! ale_linters#python#bandit#Handle(buffer, lines) abort + " Custom format defined in GetCommand via --msg-template + let l:pattern = '\v^([0-9]+):(B[0-9]+):([A-Z]+):(.*)$' + let l:severity = {'LOW': 'I', 'MEDIUM': 'W', 'HIGH': 'E'} + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': str2nr(l:match[1]), + \ 'code': l:match[2], + \ 'type': l:severity[l:match[3]], + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'bandit', +\ 'executable': function('ale_linters#python#bandit#GetExecutable'), +\ 'command': function('ale_linters#python#bandit#GetCommand'), +\ 'callback': 'ale_linters#python#bandit#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/cspell.vim b/sources_non_forked/ale/ale_linters/python/cspell.vim new file mode 100644 index 00000000..a2325311 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Python files. + +call ale#handlers#cspell#DefineLinter('python') diff --git a/sources_non_forked/ale/ale_linters/python/flake8.vim b/sources_non_forked/ale/ale_linters/python/flake8.vim new file mode 100644 index 00000000..9950614a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/flake8.vim @@ -0,0 +1,170 @@ +" Author: w0rp +" Description: flake8 for python files + +call ale#Set('python_flake8_executable', 'flake8') +call ale#Set('python_flake8_options', '') +call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_flake8_change_directory', 'project') +call ale#Set('python_flake8_auto_pipenv', 0) +call ale#Set('python_flake8_auto_poetry', 0) + +function! s:UsingModule(buffer) abort + return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8' +endfunction + +function! ale_linters#python#flake8#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_flake8_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flake8_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if !s:UsingModule(a:buffer) + return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8']) + endif + + return ale#Var(a:buffer, 'python_flake8_executable') +endfunction + +function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort + let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) + + let l:module_string = s:UsingModule(a:buffer) ? ' -m flake8' : '' + let l:command = ale#Escape(l:executable) . l:module_string . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale_linters#python#flake8#GetCommand'), + \) +endfunction + +function! ale_linters#python#flake8#GetCwd(buffer) abort + let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory') + let l:cwd = '' + + if l:change_directory is# 'project' + let l:project_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:project_root) + let l:cwd = l:project_root + endif + endif + + if (l:change_directory is# 'project' && empty(l:cwd)) + \|| l:change_directory is# 1 + \|| l:change_directory is# 'file' + let l:cwd = '%s:h' + endif + + return l:cwd +endfunction + +function! ale_linters#python#flake8#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run flake8' + \ : '' + + " Only include the --stdin-display-name argument if we can parse the + " flake8 version, and it is recent enough to support it. + let l:display_name_args = ale#semver#GTE(a:version, [3, 0, 0]) + \ ? ' --stdin-display-name %s' + \ : '' + + let l:options = ale#Var(a:buffer, 'python_flake8_options') + + return ale#Escape(l:executable) . l:exec_args + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --format=default' + \ . l:display_name_args . ' -' +endfunction + +let s:end_col_pattern_map = { +\ 'F405': '\(.\+\) may be undefined', +\ 'F821': 'undefined name ''\([^'']\+\)''', +\ 'F999': '^''\([^'']\+\)''', +\ 'F841': 'local variable ''\([^'']\+\)''', +\} + +function! ale_linters#python#flake8#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches patterns line the following: + " + " Matches patterns line the following: + " + " stdin:6:6: E111 indentation is not a multiple of four + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+):? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[3] + + if (l:code is# 'W291' || l:code is# 'W293') + \ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:code is# 'W391' + \&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines') + " Skip warnings for trailing blank lines if the option is off + continue + endif + + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'vcol': 1, + \ 'text': l:match[4], + \ 'code': l:code, + \ 'type': 'W', + \} + + if l:code[:0] is# 'F' + if l:code isnot# 'F401' + let l:item.type = 'E' + endif + elseif l:code[:0] is# 'E' + let l:item.type = 'E' + + if l:code isnot# 'E999' && l:code isnot# 'E112' + let l:item.sub_type = 'style' + endif + elseif l:code[:0] is# 'W' + let l:item.sub_type = 'style' + endif + + let l:end_col_pattern = get(s:end_col_pattern_map, l:code, '') + + if !empty(l:end_col_pattern) + let l:end_col_match = matchlist(l:match[4], l:end_col_pattern) + + if !empty(l:end_col_match) + let l:item.end_col = l:item.col + len(l:end_col_match[1]) - 1 + endif + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'flake8', +\ 'executable': function('ale_linters#python#flake8#GetExecutable'), +\ 'cwd': function('ale_linters#python#flake8#GetCwd'), +\ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'), +\ 'callback': 'ale_linters#python#flake8#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/flakehell.vim b/sources_non_forked/ale/ale_linters/python/flakehell.vim new file mode 100644 index 00000000..ffe87e29 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/flakehell.vim @@ -0,0 +1,175 @@ +" Author: w0rp +" Description: flakehell for python files + +call ale#Set('python_flakehell_executable', 'flakehell') +call ale#Set('python_flakehell_options', '') +call ale#Set('python_flakehell_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_flakehell_change_directory', 'project') +call ale#Set('python_flakehell_auto_pipenv', 0) +call ale#Set('python_flakehell_auto_poetry', 0) + +function! s:UsingModule(buffer) abort + return ale#Var(a:buffer, 'python_flakehell_executable') is? 'python' +endfunction + +function! ale_linters#python#flakehell#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_flakehell_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flakehell_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if !s:UsingModule(a:buffer) + return ale#python#FindExecutable(a:buffer, 'python_flakehell', ['flakehell']) + endif + + return ale#Var(a:buffer, 'python_flakehell_executable') +endfunction + +function! ale_linters#python#flakehell#RunWithVersionCheck(buffer) abort + let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer) + + let l:module_string = s:UsingModule(a:buffer) ? ' -m flakehell' : '' + let l:command = ale#Escape(l:executable) . l:module_string . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale_linters#python#flakehell#GetCommand'), + \) +endfunction + +function! ale_linters#python#flakehell#GetCwd(buffer) abort + let l:change_directory = ale#Var(a:buffer, 'python_flakehell_change_directory') + let l:cwd = '' + + if l:change_directory is# 'project' + let l:project_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:project_root) + let l:cwd = l:project_root + endif + endif + + if (l:change_directory is# 'project' && empty(l:cwd)) + \|| l:change_directory is# 1 + \|| l:change_directory is# 'file' + let l:cwd = '%s:h' + endif + + return l:cwd +endfunction + +function! ale_linters#python#flakehell#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer) + + if (l:executable =~? 'pipenv\|poetry$') + let l:exec_args = ' run flakehell' + elseif (l:executable is? 'python') + let l:exec_args = ' -m flakehell' + else + let l:exec_args = '' + endif + + " Only include the --stdin-display-name argument if we can parse the + " flakehell version, and it is recent enough to support it. + let l:display_name_args = ale#semver#GTE(a:version, [0, 8, 0]) + \ ? ' --stdin-display-name %s' + \ : '' + + let l:options = ale#Var(a:buffer, 'python_flakehell_options') + + return ale#Escape(l:executable) + \ . l:exec_args + \ . (!empty(l:options) ? ' lint ' . l:options : ' lint') + \ . ' --format=default' + \ . l:display_name_args . ' -' +endfunction + +let s:end_col_pattern_map = { +\ 'F405': '\(.\+\) may be undefined', +\ 'F821': 'undefined name ''\([^'']\+\)''', +\ 'F999': '^''\([^'']\+\)''', +\ 'F841': 'local variable ''\([^'']\+\)''', +\} + +function! ale_linters#python#flakehell#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches patterns line the following: + " + " Matches patterns line the following: + " + " stdin:6:6: E111 indentation is not a multiple of four + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?: ([[:alnum:]]+):? (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[3] + + if (l:code is# 'W291' || l:code is# 'W293') + \ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:code is# 'W391' + \&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines') + " Skip warnings for trailing blank lines if the option is off + continue + endif + + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'vcol': 1, + \ 'text': l:match[4], + \ 'code': l:code, + \ 'type': 'W', + \} + + if l:code[:0] is# 'F' + if l:code isnot# 'F401' + let l:item.type = 'E' + endif + elseif l:code[:0] is# 'E' + let l:item.type = 'E' + + if l:code isnot# 'E999' && l:code isnot# 'E112' + let l:item.sub_type = 'style' + endif + elseif l:code[:0] is# 'W' + let l:item.sub_type = 'style' + endif + + let l:end_col_pattern = get(s:end_col_pattern_map, l:code, '') + + if !empty(l:end_col_pattern) + let l:end_col_match = matchlist(l:match[4], l:end_col_pattern) + + if !empty(l:end_col_match) + let l:item.end_col = l:item.col + len(l:end_col_match[1]) - 1 + endif + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'flakehell', +\ 'executable': function('ale_linters#python#flakehell#GetExecutable'), +\ 'cwd': function('ale_linters#python#flakehell#GetCwd'), +\ 'command': function('ale_linters#python#flakehell#RunWithVersionCheck'), +\ 'callback': 'ale_linters#python#flakehell#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/jedils.vim b/sources_non_forked/ale/ale_linters/python/jedils.vim new file mode 100644 index 00000000..eae5fb07 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/jedils.vim @@ -0,0 +1,34 @@ +" Author: Dalius Dobravolskas +" Description: https://github.com/pappasam/jedi-language-server + +call ale#Set('python_jedils_executable', 'jedi-language-server') +call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_jedils_auto_pipenv', 0) + +function! ale_linters#python#jedils#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server']) +endfunction + +function! ale_linters#python#jedils#GetCommand(buffer) abort + let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv$' + \ ? ' run jedi-language-server' + \ : '' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +call ale#linter#Define('python', { +\ 'name': 'jedils', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#jedils#GetExecutable'), +\ 'command': function('ale_linters#python#jedils#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/mypy.vim b/sources_non_forked/ale/ale_linters/python/mypy.vim new file mode 100644 index 00000000..9d469a1a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/mypy.vim @@ -0,0 +1,103 @@ +" Author: Keith Smiley , w0rp +" Description: mypy support for optional python typechecking + +call ale#Set('python_mypy_executable', 'mypy') +call ale#Set('python_mypy_ignore_invalid_syntax', 0) +call ale#Set('python_mypy_show_notes', 1) +call ale#Set('python_mypy_options', '') +call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_mypy_auto_pipenv', 0) +call ale#Set('python_mypy_auto_poetry', 0) + +function! ale_linters#python#mypy#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_mypy_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy']) +endfunction + +" The directory to change to before running mypy +function! ale_linters#python#mypy#GetCwd(buffer) abort + " If we find a directory with "mypy.ini" in it use that, + " else try and find the "python project" root, or failing + " that, run from the same folder as the current file + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + if filereadable(l:path . '/mypy.ini') + return l:path + endif + endfor + + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) + \ ? l:project_root + \ : expand('#' . a:buffer . ':p:h') +endfunction + +function! ale_linters#python#mypy#GetCommand(buffer) abort + let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run mypy' + \ : '' + + return '%e' . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options')) + \ . ' --show-column-numbers' + \ . ' --shadow-file %s %t %s' +endfunction + +function! ale_linters#python#mypy#Handle(buffer, lines) abort + let l:dir = ale_linters#python#mypy#GetCwd(a:buffer) + " Look for lines like the following: + " + " file.py:4: error: No library stub file for module 'django.db' + " + " Lines like these should be ignored below: + " + " file.py:4: note: (Stub files are from https://github.com/python/typeshed) + + let l:types = 'error|warning' + + if ale#Var(a:buffer, 'python_mypy_show_notes') + let l:types = 'error|warning|note' + endif + + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (' + \ . l:types + \ . '): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " Skip invalid syntax errors if the option is on. + if l:match[5] is# 'invalid syntax' + \&& ale#Var(a:buffer, 'python_mypy_ignore_invalid_syntax') + continue + endif + + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4] is# 'error' ? 'E' : (l:match[4] is# 'note' ? 'I': 'W'), + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'mypy', +\ 'executable': function('ale_linters#python#mypy#GetExecutable'), +\ 'cwd': function('ale_linters#python#mypy#GetCwd'), +\ 'command': function('ale_linters#python#mypy#GetCommand'), +\ 'callback': 'ale_linters#python#mypy#Handle', +\ 'output_stream': 'both' +\}) diff --git a/sources_non_forked/ale/ale_linters/python/prospector.vim b/sources_non_forked/ale/ale_linters/python/prospector.vim new file mode 100644 index 00000000..3623bda0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/prospector.vim @@ -0,0 +1,106 @@ +" Author: chocoelho +" Description: prospector linter python files + +call ale#Set('python_prospector_auto_pipenv', 0) +call ale#Set('python_prospector_auto_poetry', 0) + +let g:ale_python_prospector_executable = +\ get(g:, 'ale_python_prospector_executable', 'prospector') + +let g:ale_python_prospector_options = +\ get(g:, 'ale_python_prospector_options', '') + +let g:ale_python_prospector_use_global = get(g:, 'ale_python_prospector_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#python#prospector#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_prospector_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_prospector_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector']) +endfunction + +function! ale_linters#python#prospector#GetCommand(buffer) abort + let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run prospector' + \ : '' + + return ale#Escape(l:executable) + \ . l:exec_args + \ . ' ' . ale#Var(a:buffer, 'python_prospector_options') + \ . ' --messages-only --absolute-paths --zero-exit --output-format json' + \ . ' %s' +endfunction + +function! ale_linters#python#prospector#Handle(buffer, lines) abort + let l:output = [] + + if empty(a:lines) + return [] + endif + + let l:prospector_error = json_decode(join(a:lines, '')) + + for l:error in l:prospector_error.messages + if (l:error.code is# 'W291' || l:error.code is# 'W293' || l:error.code is# 'trailing-whitespace') + \ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:error.code is# 'W391' + \&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines') + " Skip warnings for trailing blank lines if the option is off + continue + endif + + if l:error.source =~# '\v\[%(dodgy|mccabe|pep8|pep257|pyroma)\]$' + let l:sub_type = 'style' + else + let l:sub_type = '' + endif + + if l:error.source =~# '\v\[pylint\]$' + let l:type = l:error.code =~? '\m^[CRW]' ? 'W' : 'E' + elseif l:error.source =~# '\v\[%(frosted|pep8)\]$' + let l:type = l:error.code =~? '\m^W' ? 'W' : 'E' + elseif l:error.source =~# '\v\[%(dodgy|pyroma|vulture)\]$' + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:item = { + \ 'lnum': l:error.location.line, + \ 'col': l:error.location.character + 1, + \ 'text': l:error.message, + \ 'code': printf('(%s) %s', l:error.source, l:error.code), + \ 'type': l:type, + \ 'sub_type': l:sub_type, + \} + + if l:sub_type is# '' + unlet l:item.sub_type + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'prospector', +\ 'executable': function('ale_linters#python#prospector#GetExecutable'), +\ 'command': function('ale_linters#python#prospector#GetCommand'), +\ 'callback': 'ale_linters#python#prospector#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pycodestyle.vim b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim new file mode 100644 index 00000000..3fb94d69 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pycodestyle.vim @@ -0,0 +1,81 @@ +" Author: Michael Thiesen +" Description: pycodestyle linting for python files + +call ale#Set('python_pycodestyle_executable', 'pycodestyle') +call ale#Set('python_pycodestyle_options', '') +call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pycodestyle_auto_pipenv', 0) +call ale#Set('python_pycodestyle_auto_poetry', 0) + +function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycodestyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle']) +endfunction + +function! ale_linters#python#pycodestyle#GetCommand(buffer) abort + let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pycodestyle' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . ' ' + \ . ale#Var(a:buffer, 'python_pycodestyle_options') + \ . ' -' +endfunction + +function! ale_linters#python#pycodestyle#Handle(buffer, lines) abort + let l:pattern = '\v^(\S*):(\d*):(\d*): ([EW]\d+) (.*)$' + let l:output = [] + + " lines are formatted as follows: + " file.py:21:26: W291 trailing whitespace + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if(l:match[4] is# 'W291' || l:match[4] is# 'W293') + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:match[4] is# 'W391' + \&& !ale#Var(a:buffer, 'warn_about_trailing_blank_lines') + " Skip warnings for trailing blank lines if the option is off + continue + endif + + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'type': l:match[4][0], + \ 'sub_type': 'style', + \ 'text': l:match[5], + \ 'code': l:match[4], + \} + + " E999 and E112 are syntax errors. + if l:match[4] is# 'E999' || l:match[4] is# 'E112' + unlet l:item.sub_type + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pycodestyle', +\ 'executable': function('ale_linters#python#pycodestyle#GetExecutable'), +\ 'command': function('ale_linters#python#pycodestyle#GetCommand'), +\ 'callback': 'ale_linters#python#pycodestyle#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pydocstyle.vim b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim new file mode 100644 index 00000000..ef0d818c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pydocstyle.vim @@ -0,0 +1,77 @@ +" Author: Pablo Acosta +" Description: pydocstyle for python files + +call ale#Set('python_pydocstyle_executable', 'pydocstyle') +call ale#Set('python_pydocstyle_options', '') +call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pydocstyle_auto_pipenv', 0) +call ale#Set('python_pydocstyle_auto_poetry', 0) + +function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pydocstyle_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle']) +endfunction + +function! ale_linters#python#pydocstyle#GetCommand(buffer) abort + let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pydocstyle' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options')) + \ . ' %s' +endfunction + +function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort + " Matches patterns like the following: + " mydir/myfile.py:33 in public function `myfunction`: + " DXXX: Error description + let l:line1_pattern = '\v^.*:\s*(\d+)\s+.*$' + let l:line2_pattern = '\v^.*([a-zA-Z]\d+):\s*(.*)$' + let l:output = [] + + let l:num_lines = len(a:lines) + let l:index = 0 + + while l:index < l:num_lines + let l:lnum = matchlist(a:lines[l:index], l:line1_pattern) + + if !empty(l:lnum) && (l:index + 1 < l:num_lines) + let l:desc = matchlist(a:lines[l:index + 1], l:line2_pattern) + + if !empty(l:desc) + call add(l:output, { + \ 'lnum': l:lnum[1] + 0, + \ 'col': 1, + \ 'type': 'W', + \ 'text': l:desc[2], + \ 'code': l:desc[1], + \}) + endif + + let l:index = l:index + 2 + else + let l:index = l:index + 1 + endif + endwhile + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pydocstyle', +\ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'), +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#python#pydocstyle#GetCommand'), +\ 'callback': 'ale_linters#python#pydocstyle#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pyflakes.vim b/sources_non_forked/ale/ale_linters/python/pyflakes.vim new file mode 100644 index 00000000..2567c533 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pyflakes.vim @@ -0,0 +1,56 @@ +" Author: w0rp +" Description: pyflakes for python files + +call ale#Set('python_pyflakes_executable', 'pyflakes') +call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pyflakes_auto_pipenv', 0) +call ale#Set('python_pyflakes_auto_poetry', 0) + +function! ale_linters#python#pyflakes#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflakes_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes']) +endfunction + +function! ale_linters#python#pyflakes#GetCommand(buffer) abort + let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pyflakes' + \ : '' + + return ale#Escape(l:executable) + \ . l:exec_args + \ . ' %t' +endfunction + +function! ale_linters#python#pyflakes#Handle(buffer, lines) abort + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pyflakes', +\ 'executable': function('ale_linters#python#pyflakes#GetExecutable'), +\ 'command': function('ale_linters#python#pyflakes#GetCommand'), +\ 'callback': 'ale_linters#python#pyflakes#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pylama.vim b/sources_non_forked/ale/ale_linters/python/pylama.vim new file mode 100644 index 00000000..14f8071a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pylama.vim @@ -0,0 +1,154 @@ +" Author: Kevin Locke +" Description: pylama for python files + +call ale#Set('python_pylama_executable', 'pylama') +call ale#Set('python_pylama_options', '') +call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylama_auto_pipenv', 0) +call ale#Set('python_pylama_auto_poetry', 0) +call ale#Set('python_pylama_change_directory', 1) + +function! ale_linters#python#pylama#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylama_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylama_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama']) +endfunction + +function! ale_linters#python#pylama#RunWithVersionCheck(buffer) abort + let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pylama' + \ : '' + + let l:command = ale#Escape(l:executable) . l:exec_args . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale_linters#python#pylama#GetCommand'), + \) +endfunction + +function! ale_linters#python#pylama#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_pylama_change_directory') + " Pylama loads its configuration from the current directory only, and + " applies file masks using paths relative to the current directory. + " Run from project root, if found, otherwise buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +endfunction + +function! ale_linters#python#pylama#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pylama' + \ : '' + + " json format is added in version 8.1.4 + " https://github.com/klen/pylama/blob/develop/Changelog + let l:format_json_args = ale#semver#GTE(a:version, [8, 1, 4]) + \ ? ' --format json' + \ : '' + + " Note: Using %t to lint changes would be preferable, but many pylama + " checks use surrounding paths (e.g. C0103 module name, E0402 relative + " import beyond top, etc.). Neither is ideal. + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options')) + \ . l:format_json_args + \ . ' %s' +endfunction + +function! ale_linters#python#pylama#Handle(buffer, version, lines) abort + if empty(a:lines) + return [] + endif + + let l:output = ale#python#HandleTraceback(a:lines, 1) + + " First letter of error code is a pylint-compatible message type + " http://pylint.pycqa.org/en/latest/user_guide/output.html#source-code-analysis-section + " D is for Documentation (pydocstyle) + let l:pylint_type_to_ale_type = { + \ 'I': 'I', + \ 'R': 'W', + \ 'C': 'W', + \ 'W': 'W', + \ 'E': 'E', + \ 'F': 'E', + \ 'D': 'W', + \} + let l:pylint_type_to_ale_sub_type = { + \ 'R': 'style', + \ 'C': 'style', + \ 'D': 'style', + \} + + if ale#semver#GTE(a:version, [8, 1, 4]) + try + let l:errors = json_decode(join(a:lines, '')) + catch + return l:output + endtry + + if empty(l:errors) + return l:output + endif + + for l:error in l:errors + call add(l:output, { + \ 'lnum': l:error['lnum'], + \ 'col': l:error['col'], + \ 'code': l:error['number'], + \ 'type': get(l:pylint_type_to_ale_type, l:error['etype'], 'W'), + \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:error['etype'], ''), + \ 'text': printf('%s [%s]', l:error['message'], l:error['source']), + \}) + endfor + else + let l:pattern = '\v^.{-}:([0-9]+):([0-9]+): +%(([A-Z][0-9]+):? +)?(.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'code': l:match[3], + \ 'type': get(l:pylint_type_to_ale_type, l:match[3][0], 'W'), + \ 'sub_type': get(l:pylint_type_to_ale_sub_type, l:match[3][0], ''), + \ 'text': l:match[4], + \}) + endfor + endif + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylama', +\ 'executable': function('ale_linters#python#pylama#GetExecutable'), +\ 'cwd': function('ale_linters#python#pylama#GetCwd'), +\ 'command': function('ale_linters#python#pylama#RunWithVersionCheck'), +\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#python#pylama#GetExecutable(buffer), +\ '%e --version', +\ {buffer, version -> ale_linters#python#pylama#Handle( +\ buffer, +\ l:version, +\ lines)}, +\ )}, +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pylint.vim b/sources_non_forked/ale/ale_linters/python/pylint.vim new file mode 100644 index 00000000..2ce5376f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pylint.vim @@ -0,0 +1,120 @@ +" Author: keith +" Description: pylint for python files + +call ale#Set('python_pylint_executable', 'pylint') +call ale#Set('python_pylint_options', '') +call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylint_change_directory', 1) +call ale#Set('python_pylint_auto_pipenv', 0) +call ale#Set('python_pylint_auto_poetry', 0) +call ale#Set('python_pylint_use_msg_id', 0) + +function! ale_linters#python#pylint#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylint_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylint_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint']) +endfunction + +function! ale_linters#python#pylint#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_pylint_change_directory') + " pylint only checks for pylintrc in the packages above its current + " directory before falling back to user and global pylintrc. + " Run from project root, if found, otherwise buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +endfunction + +function! ale_linters#python#pylint#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pylint' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_pylint_options')) + \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n' + \ . (ale#semver#GTE(a:version, [2, 4, 0]) ? ' --from-stdin' : '') + \ . ' %s' +endfunction + +function! ale_linters#python#pylint#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches patterns like the following: + " + " test.py:4:4: W0101 (unreachable) Unreachable code + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ([[:alnum:]]+) \(([^(]*)\) (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + "let l:failed = append(0, l:match) + let l:code = l:match[3] + + if (l:code is# 'C0303') + \ && !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:code is# 'I0011' + " Skip 'Locally disabling' message + continue + endif + + if ale#Var(a:buffer, 'python_pylint_use_msg_id') is# 1 + let l:code_out = l:code + else + let l:code_out = l:match[4] + endif + + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 1, + \ 'text': l:match[5], + \ 'code': l:code_out, + \ 'type': 'W', + \} + + if l:code[:0] is# 'E' + let l:item.type = 'E' + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylint', +\ 'executable': function('ale_linters#python#pylint#GetExecutable'), +\ 'lint_file': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])}, +\ )}, +\ 'cwd': function('ale_linters#python#pylint#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'python_pylint_executable'), +\ '%e --version', +\ function('ale_linters#python#pylint#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#python#pylint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pylsp.vim b/sources_non_forked/ale/ale_linters/python/pylsp.vim new file mode 100644 index 00000000..537d1e74 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pylsp.vim @@ -0,0 +1,43 @@ +" Author: aurieh +" Description: A language server for Python + +call ale#Set('python_pylsp_executable', 'pylsp') +call ale#Set('python_pylsp_options', '') +call ale#Set('python_pylsp_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pylsp_auto_pipenv', 0) +call ale#Set('python_pylsp_auto_poetry', 0) +call ale#Set('python_pylsp_config', {}) + +function! ale_linters#python#pylsp#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pylsp_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylsp_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp']) +endfunction + +function! ale_linters#python#pylsp#GetCommand(buffer) abort + let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer) + + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run pylsp' + \ : '' + + return ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pylsp_options')) +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pylsp', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#pylsp#GetExecutable'), +\ 'command': function('ale_linters#python#pylsp#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': {b -> ale#Var(b, 'python_pylsp_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pyre.vim b/sources_non_forked/ale/ale_linters/python/pyre.vim new file mode 100644 index 00000000..5e5786f9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pyre.vim @@ -0,0 +1,44 @@ +" Author: dsifford +" Description: A performant type-checker supporting LSP for Python 3 created by Facebook + +call ale#Set('python_pyre_executable', 'pyre') +call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pyre_auto_pipenv', 0) +call ale#Set('python_pyre_auto_poetry', 0) + +function! ale_linters#python#pyre#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyre_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre']) +endfunction + +function! ale_linters#python#pyre#GetCommand(buffer) abort + let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) + let l:exec_args = (l:executable =~? 'pipenv\|poetry$' ? ' run pyre' : '') . ' persistent' + + return ale#Escape(l:executable) . l:exec_args +endfunction + +function! ale_linters#python#pyre#GetCwd(buffer) abort + let l:local_config = ale#path#FindNearestFile(a:buffer, '.pyre_configuration.local') + + return fnamemodify(l:local_config, ':h') +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pyre', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#python#pyre#GetExecutable'), +\ 'command': function('ale_linters#python#pyre#GetCommand'), +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'cwd': function('ale_linters#python#pyre#GetCwd'), +\}) diff --git a/sources_non_forked/ale/ale_linters/python/pyright.vim b/sources_non_forked/ale/ale_linters/python/pyright.vim new file mode 100644 index 00000000..422ecd61 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/pyright.vim @@ -0,0 +1,43 @@ +call ale#Set('python_pyright_executable', 'pyright-langserver') +call ale#Set('python_pyright_config', {}) + +function! ale_linters#python#pyright#GetConfig(buffer) abort + let l:config = deepcopy(ale#Var(a:buffer, 'python_pyright_config')) + + if !has_key(l:config, 'python') + let l:config.python = {} + endif + + if type(l:config.python) is v:t_dict + " Automatically detect the virtualenv path and use it. + if !has_key(l:config.python, 'venvPath') + let l:venv = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:venv) + let l:config.python.venvPath = l:venv + endif + endif + + " Automatically use the version of Python in virtualenv. + if type(get(l:config.python, 'venvPath')) is v:t_string + \&& !empty(l:config.python.venvPath) + \&& !has_key(l:config.python, 'pythonPath') + let l:config.python.pythonPath = ale#path#Simplify( + \ l:config.python.venvPath + \ . (has('win32') ? '/Scripts/python' : '/bin/python') + \) + endif + endif + + return l:config +endfunction + +call ale#linter#Define('python', { +\ 'name': 'pyright', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'python_pyright_executable')}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale#python#FindProjectRoot'), +\ 'completion_filter': 'ale#completion#python#CompletionItemFilter', +\ 'lsp_config': function('ale_linters#python#pyright#GetConfig'), +\}) diff --git a/sources_non_forked/ale/ale_linters/python/ruff.vim b/sources_non_forked/ale/ale_linters/python/ruff.vim new file mode 100644 index 00000000..67595fe3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/ruff.vim @@ -0,0 +1,84 @@ +" Author: Yining +" Description: ruff as linter for python files + +call ale#Set('python_ruff_executable', 'ruff') +call ale#Set('python_ruff_options', '') +call ale#Set('python_ruff_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_ruff_change_directory', 1) +call ale#Set('python_ruff_auto_pipenv', 0) +call ale#Set('python_ruff_auto_poetry', 0) + +call ale#fix#registry#Add('ruff', +\ 'ale#fixers#ruff#Fix', +\ ['python'], +\ 'A python linter/fixer for Python written in Rust' +\) + +function! ale_linters#python#ruff#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_ruff_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_ruff_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff']) +endfunction + +function! ale_linters#python#ruff#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_ruff_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +endfunction + +function! ale_linters#python#ruff#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run ruff' + \ : '' + + " NOTE: ruff version `0.0.69` supports liniting input from stdin + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_ruff_options')) + \ . ' --format text' + \ . (ale#semver#GTE(a:version, [0, 0, 69]) ? ' -' : ' %s') +endfunction + +function! ale_linters#python#ruff#Handle(buffer, lines) abort + "Example: path/to/file.py:10:5: E999 SyntaxError: unexpected indent + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('python', { +\ 'name': 'ruff', +\ 'executable': function('ale_linters#python#ruff#GetExecutable'), +\ 'cwd': function('ale_linters#python#ruff#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#python#ruff#GetExecutable(buffer), +\ '%e --version', +\ function('ale_linters#python#ruff#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#python#ruff#Handle', +\ 'output_stream': 'both', +\ 'read_buffer': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/python/unimport.vim b/sources_non_forked/ale/ale_linters/python/unimport.vim new file mode 100644 index 00000000..71fd80f0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/unimport.vim @@ -0,0 +1,75 @@ +" Author: Author: Jon Parise + +call ale#Set('python_unimport_executable', 'unimport') +call ale#Set('python_unimport_options', '') +call ale#Set('python_unimport_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_unimport_auto_pipenv', 0) +call ale#Set('python_unimport_auto_poetry', 0) + +function! ale_linters#python#unimport#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_unimport_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_unimport_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_unimport', ['unimport']) +endfunction + +function! ale_linters#python#unimport#GetCommand(buffer) abort + let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run unimport' + \ : '' + + return '%e' . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_unimport_options')) + \ . ' --check' + \ . ' %t' +endfunction + + +function! ale_linters#python#unimport#GetCwd(buffer) abort + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) + \ ? l:project_root + \ : expand('#' . a:buffer . ':p:h') +endfunction + + +function! ale_linters#python#unimport#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches lines like: + " + " urllib.parse at path/to/file.py:9 + let l:pattern = '\v(.+) at [^:]+:(\d+)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'W', + \ 'text': 'unused: ' . l:match[1], + \}) + endfor + + return l:output +endfunction + + +call ale#linter#Define('python', { +\ 'name': 'unimport', +\ 'executable': function('ale_linters#python#unimport#GetExecutable'), +\ 'cwd': function('ale_linters#python#unimport#GetCwd'), +\ 'command': function('ale_linters#python#unimport#GetCommand'), +\ 'callback': 'ale_linters#python#unimport#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/python/vulture.vim b/sources_non_forked/ale/ale_linters/python/vulture.vim new file mode 100644 index 00000000..a7ba1860 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/python/vulture.vim @@ -0,0 +1,79 @@ +" Author: Yauheni Kirylau +" Description: vulture linting for python files + +call ale#Set('python_vulture_executable', 'vulture') +call ale#Set('python_vulture_options', '') +call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_vulture_change_directory', 1) + +" The directory to change to before running vulture +function! s:GetDir(buffer) abort + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) + \ ? l:project_root + \ : expand('#' . a:buffer . ':p:h') +endfunction + +function! ale_linters#python#vulture#GetExecutable(buffer) abort + return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture']) +endfunction + +function! ale_linters#python#vulture#GetCwd(buffer) abort + if !ale#Var(a:buffer, 'python_vulture_change_directory') + return '' + endif + + return s:GetDir(a:buffer) +endfunction + +function! ale_linters#python#vulture#GetCommand(buffer) abort + let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run vulture' + \ : '' + let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') + \ ? ' .' + \ : ' %s' + + return ale#Escape(l:executable) . l:exec_args + \ . ' ' + \ . ale#Var(a:buffer, 'python_vulture_options') + \ . l:lint_dest +endfunction + + +function! ale_linters#python#vulture#Handle(buffer, lines) abort + let l:output = ale#python#HandleTraceback(a:lines, 10) + + if !empty(l:output) + return l:output + endif + + " Matches patterns line the following: + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (.*)$' + let l:dir = s:GetDir(a:buffer) + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:abspath = ale#path#GetAbsPath(l:dir, l:match[1]) + let l:item = { + \ 'filename': l:abspath, + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \} + call add(l:output, l:item) + endfor + + return l:output +endfunction + + +call ale#linter#Define('python', { +\ 'name': 'vulture', +\ 'executable': function('ale_linters#python#vulture#GetExecutable'), +\ 'cwd': function('ale_linters#python#vulture#GetCwd'), +\ 'command': function('ale_linters#python#vulture#GetCommand'), +\ 'callback': 'ale_linters#python#vulture#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim new file mode 100644 index 00000000..11cc9413 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/qml/qmlfmt.vim @@ -0,0 +1,25 @@ +" Author: pylipp (www.github.com/pylipp) +" Description: qmlfmt for QML files + +call ale#Set('qml_qmlfmt_executable', 'qmlfmt') + +" Find lines like +" Error:11:1: Expected token `}' +function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort + let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$' + + return map(ale#util#GetMatches(a:lines, l:pattern), "{ + \ 'lnum': v:val[2] + 0, + \ 'col': v:val[3] + 0, + \ 'text': v:val[4], + \ 'type': v:val[1] is# 'Warning' ? 'W' : 'E', + \}") +endfunction + +call ale#linter#Define('qml', { +\ 'name': 'qmlfmt', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'qml_qmlfmt_executable')}, +\ 'command': '%e -e', +\ 'callback': 'ale_linters#qml#qmlfmt#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/qml/qmllint.vim b/sources_non_forked/ale/ale_linters/qml/qmllint.vim new file mode 100644 index 00000000..c2258a14 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/qml/qmllint.vim @@ -0,0 +1,29 @@ +" Author: pylipp (www.github.com/pylipp) +" Description: qmllint for QML files + +" Find lines like +" /home/foo_user42/code-base/qml/Screen.qml:11 : Expected token `}' +function! ale_linters#qml#qmllint#Handle(buffer, lines) abort + let l:pattern = '\v^[/_-a-zA-z0-9\. ]+:(\d+) : (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': 'E', + \} + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('qml', { +\ 'name': 'qmllint', +\ 'output_stream': 'stderr', +\ 'executable': 'qmllint', +\ 'command': 'qmllint %t', +\ 'callback': 'ale_linters#qml#qmllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/r/languageserver.vim b/sources_non_forked/ale/ale_linters/r/languageserver.vim new file mode 100644 index 00000000..bab869d1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/r/languageserver.vim @@ -0,0 +1,27 @@ +" Author: Eric Zhao <21zhaoe@protonmail.com> +" Author: ourigen +" Description: Implementation of the Language Server Protocol for R. + +call ale#Set('r_languageserver_cmd', 'languageserver::run()') +call ale#Set('r_languageserver_config', {}) + +function! ale_linters#r#languageserver#GetCommand(buffer) abort + let l:cmd_string = ale#Var(a:buffer, 'r_languageserver_cmd') + + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) +endfunction + +function! ale_linters#r#languageserver#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, '.Rprofile') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : fnamemodify(a:buffer, ':h') +endfunction + +call ale#linter#Define('r', { +\ 'name': 'languageserver', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'r_languageserver_config')}, +\ 'executable': 'Rscript', +\ 'command': function('ale_linters#r#languageserver#GetCommand'), +\ 'project_root': function('ale_linters#r#languageserver#GetProjectRoot') +\}) diff --git a/sources_non_forked/ale/ale_linters/r/lintr.vim b/sources_non_forked/ale/ale_linters/r/lintr.vim new file mode 100644 index 00000000..339ad2b0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/r/lintr.vim @@ -0,0 +1,35 @@ +" Author: Michel Lang , w0rp , +" Fenner Macrae , +" ourigen +" Description: This file adds support for checking R code with lintr. + +let g:ale_r_lintr_options = get(g:, 'ale_r_lintr_options', 'with_defaults()') +" A reasonable alternative default: +" get(g:, 'ale_r_lintr_options', 'with_defaults(object_usage_linter = NULL)') + + +let g:ale_r_lintr_lint_package = get(g:, 'ale_r_lintr_lint_package', 0) + +function! ale_linters#r#lintr#GetCommand(buffer) abort + if ale#Var(a:buffer, 'r_lintr_lint_package') + let l:lint_cmd = 'lint_package(cache = FALSE, linters = ' + \ . ale#Var(a:buffer, 'r_lintr_options') . ')' + else + let l:lint_cmd = 'lint(cache = FALSE, commandArgs(TRUE), ' + \ . ale#Var(a:buffer, 'r_lintr_options') . ')' + endif + + let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));' + \ . l:lint_cmd + + return 'Rscript --no-save --no-restore --no-site-file --no-init-file -e ' . ale#Escape(l:cmd_string) . ' %t' +endfunction + +call ale#linter#Define('r', { +\ 'name': 'lintr', +\ 'executable': 'Rscript', +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#r#lintr#GetCommand'), +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/racket/langserver.vim b/sources_non_forked/ale/ale_linters/racket/langserver.vim new file mode 100644 index 00000000..ec80ed7b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/racket/langserver.vim @@ -0,0 +1,7 @@ +call ale#linter#Define('racket', { +\ 'name': 'racket_langserver', +\ 'lsp': 'stdio', +\ 'executable': 'racket', +\ 'command': '%e -l racket-langserver', +\ 'project_root': function('ale#racket#FindProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/racket/raco.vim b/sources_non_forked/ale/ale_linters/racket/raco.vim new file mode 100644 index 00000000..5b26065f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/racket/raco.vim @@ -0,0 +1,34 @@ +" Author: aqui18 +" Description: This file adds support for checking Racket code with raco. +" 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. + +function! ale_linters#racket#raco#Handle(buffer, lines) abort + " Matches patterns + " :: + " eg: + " info.rkt:4:0: infotab-module: not a well-formed definition + let l:pattern = '^\(\s\)\@!\(.\+\):\(\d\+\):\(\d\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': l:match[2], + \ 'lnum': l:match[3] + 0, + \ 'col': l:match[4] + 0, + \ 'type': 'E', + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('racket', { +\ 'name': 'raco', +\ 'executable': 'raco', +\ 'output_stream': 'stderr', +\ 'command': 'raco expand %s', +\ 'callback': 'ale_linters#racket#raco#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/reason/ls.vim b/sources_non_forked/ale/ale_linters/reason/ls.vim new file mode 100644 index 00000000..fb1114ae --- /dev/null +++ b/sources_non_forked/ale/ale_linters/reason/ls.vim @@ -0,0 +1,23 @@ +" Author: David Buchan-Swanson +" Description: Integrate ALE with reason-language-server. + +call ale#Set('reason_ls_executable', '') + +function! ale_linters#reason#ls#FindProjectRoot(buffer) abort + let l:reason_config = ale#path#FindNearestFile(a:buffer, 'bsconfig.json') + + if !empty(l:reason_config) + return fnamemodify(l:reason_config, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('reason', { +\ 'name': 'reason-language-server', +\ 'lsp': 'stdio', +\ 'executable': {buffer -> ale#Var(buffer, 'reason_ls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#reason#ls#FindProjectRoot'), +\ 'language': 'reason', +\}) diff --git a/sources_non_forked/ale/ale_linters/reason/merlin.vim b/sources_non_forked/ale/ale_linters/reason/merlin.vim new file mode 100644 index 00000000..7bef7df8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/reason/merlin.vim @@ -0,0 +1,17 @@ +" Author: Andrey Popp -- @andreypopp +" Description: Report errors in ReasonML code with Merlin + +if !exists('g:merlin') + finish +endif + +function! ale_linters#reason#merlin#Handle(buffer, lines) abort + return merlin#ErrorLocList() +endfunction + +call ale#linter#Define('reason', { +\ 'name': 'merlin', +\ 'executable': 'ocamlmerlin', +\ 'command': 'true', +\ 'callback': 'ale_linters#reason#merlin#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/reason/ols.vim b/sources_non_forked/ale/ale_linters/reason/ols.vim new file mode 100644 index 00000000..9fbd9b4f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/reason/ols.vim @@ -0,0 +1,14 @@ +" Author: Michael Jungo +" Description: A language server for Reason + +call ale#Set('reason_ols_executable', 'ocaml-language-server') +call ale#Set('reason_ols_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('reason', { +\ 'name': 'ols', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#ols#GetExecutable'), +\ 'command': function('ale#handlers#ols#GetCommand'), +\ 'language': function('ale#handlers#ols#GetLanguage'), +\ 'project_root': function('ale#handlers#ols#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/rego/cspell.vim b/sources_non_forked/ale/ale_linters/rego/cspell.vim new file mode 100644 index 00000000..a54a5379 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rego/cspell.vim @@ -0,0 +1,4 @@ +scriptencoding utf-8 +" Description: cspell support for rego files. + +call ale#handlers#cspell#DefineLinter('rego') diff --git a/sources_non_forked/ale/ale_linters/rego/opacheck.vim b/sources_non_forked/ale/ale_linters/rego/opacheck.vim new file mode 100644 index 00000000..77d8c93a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rego/opacheck.vim @@ -0,0 +1,56 @@ +" Description: opa check for rego files + +call ale#Set('rego_opacheck_executable', 'opa') +call ale#Set('rego_opacheck_options', '') + +function! ale_linters#rego#opacheck#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'rego_opacheck_executable') +endfunction + +function! ale_linters#rego#opacheck#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'rego_opacheck_options') + + return ale#Escape(ale_linters#rego#opacheck#GetExecutable(a:buffer)) + \ . ' check %s --format json ' + \ . (!empty(l:options) ? ' ' . l:options : '') +endfunction + +function! ale_linters#rego#opacheck#Handle(buffer, lines) abort + let l:output = [] + + let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'errors': []}) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:file = expand('#' . a:buffer . ':p') + + for l:error in l:errors['errors'] + if has_key(l:error, 'location') + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['location']['file']), + \ 'lnum': l:error['location']['row'], + \ 'col': l:error['location']['col'], + \ 'text': l:error['message'], + \ 'code': l:error['code'], + \ 'type': 'E', + \}) + else + call add(l:output, { + \ 'filename': l:file, + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:error['message'], + \ 'code': l:error['code'], + \ 'type': 'E', + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('rego', { +\ 'name': 'opacheck', +\ 'output_stream': 'both', +\ 'executable': function('ale_linters#rego#opacheck#GetExecutable'), +\ 'command': function('ale_linters#rego#opacheck#GetCommand'), +\ 'callback': 'ale_linters#rego#opacheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/review/redpen.vim b/sources_non_forked/ale/ale_linters/review/redpen.vim new file mode 100644 index 00000000..0006cab9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/review/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('review', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f review -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/robot/rflint.vim b/sources_non_forked/ale/ale_linters/robot/rflint.vim new file mode 100644 index 00000000..8fe2d797 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/robot/rflint.vim @@ -0,0 +1,46 @@ +" Author: Samuel Branisa +" Description: rflint linting for robot framework files + +call ale#Set('robot_rflint_executable', 'rflint') + +function! ale_linters#robot#rflint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'robot_rflint_executable') +endfunction + +function! ale_linters#robot#rflint#GetCommand(buffer) abort + let l:executable = ale_linters#robot#rflint#GetExecutable(a:buffer) + let l:flags = '--format' + \ . ' "{filename}:{severity}:{linenumber}:{char}:{rulename}:{message}"' + + return l:executable + \ . ' ' + \ . l:flags + \ . ' %s' +endfunction + +function! ale_linters#robot#rflint#Handle(buffer, lines) abort + let l:pattern = '\v^([[:alnum:][:punct:]]+):(W|E):([[:digit:]]+):([[:digit:]]+):([[:alnum:]]+):(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'filename': l:match[1], + \ 'type': l:match[2], + \ 'lnum': str2nr(l:match[3]), + \ 'col': str2nr(l:match[4]), + \ 'text': l:match[5], + \ 'detail': l:match[6], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('robot', { +\ 'name': 'rflint', +\ 'executable': function('ale_linters#robot#rflint#GetExecutable'), +\ 'command': function('ale_linters#robot#rflint#GetCommand'), +\ 'callback': 'ale_linters#robot#rflint#Handle', +\}) + diff --git a/sources_non_forked/ale/ale_linters/rst/alex.vim b/sources_non_forked/ale/ale_linters/rst/alex.vim new file mode 100644 index 00000000..e7ca6fa0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for rst files + +call ale#handlers#alex#DefineLinter('rst', '--text') diff --git a/sources_non_forked/ale/ale_linters/rst/cspell.vim b/sources_non_forked/ale/ale_linters/rst/cspell.vim new file mode 100644 index 00000000..14cfb42e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for ReStructuredText files. + +call ale#handlers#cspell#DefineLinter('rst') diff --git a/sources_non_forked/ale/ale_linters/rst/proselint.vim b/sources_non_forked/ale/ale_linters/rst/proselint.vim new file mode 100644 index 00000000..018347ae --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for reStructuredText files + +call ale#linter#Define('rst', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/rst/redpen.vim b/sources_non_forked/ale/ale_linters/rst/redpen.vim new file mode 100644 index 00000000..ac966c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('rst', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f rest -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/rst/rstcheck.vim b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim new file mode 100644 index 00000000..e0cf0798 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/rstcheck.vim @@ -0,0 +1,31 @@ +" Author: John Nduli https://github.com/jnduli +" Description: Rstcheck for reStructuredText files + +function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort + " matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline + " mismatch.' + let l:pattern = '\v^(.+):(\d*): \(([a-zA-Z]*)/\d*\) (.+)$' + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': 0, + \ 'type': l:match[3] is# 'SEVERE' ? 'E' : 'W', + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('rst', { +\ 'name': 'rstcheck', +\ 'executable': 'rstcheck', +\ 'cwd': '%s:h', +\ 'command': 'rstcheck %t', +\ 'callback': 'ale_linters#rst#rstcheck#Handle', +\ 'output_stream': 'both', +\}) diff --git a/sources_non_forked/ale/ale_linters/rst/textlint.vim b/sources_non_forked/ale/ale_linters/rst/textlint.vim new file mode 100644 index 00000000..56dd8db8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/textlint.vim @@ -0,0 +1,9 @@ +" Author: hokorobi +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#linter#Define('rst', { +\ 'name': 'textlint', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/rst/vale.vim b/sources_non_forked/ale/ale_linters/rst/vale.vim new file mode 100644 index 00000000..2e654dc4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/vale.vim @@ -0,0 +1,9 @@ +" Author: chew-z https://github.com/chew-z +" Description: vale for RST files + +call ale#linter#Define('rst', { +\ 'name': 'vale', +\ 'executable': 'vale', +\ 'command': 'vale --output=JSON %t', +\ 'callback': 'ale#handlers#vale#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/rst/writegood.vim b/sources_non_forked/ale/ale_linters/rst/writegood.vim new file mode 100644 index 00000000..26b1152a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rst/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for reStructuredText files + +call ale#handlers#writegood#DefineLinter('rst') diff --git a/sources_non_forked/ale/ale_linters/ruby/brakeman.vim b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim new file mode 100644 index 00000000..2dc48740 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/brakeman.vim @@ -0,0 +1,51 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Brakeman, a static analyzer for Rails security + +call ale#Set('ruby_brakeman_options', '') +call ale#Set('ruby_brakeman_executable', 'brakeman') +call ale#Set('ruby_brakeman_options', '') + +function! ale_linters#ruby#brakeman#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + let l:sep = has('win32') ? '\' : '/' + " Brakeman always outputs paths relative to the Rails app root + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + for l:warning in get(l:json, 'warnings', []) + let l:text = l:warning.warning_type . ' ' . l:warning.message . ' (' . l:warning.confidence . ')' + let l:line = l:warning.line != v:null ? l:warning.line : 1 + + call add(l:output, { + \ 'filename': l:rails_root . l:sep . l:warning.file, + \ 'lnum': l:line, + \ 'type': 'W', + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#ruby#brakeman#GetCommand(buffer) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if l:rails_root is? '' + return '' + endif + + let l:executable = ale#Var(a:buffer, 'ruby_brakeman_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'brakeman') + \ . ' -f json -q ' + \ . ale#Var(a:buffer, 'ruby_brakeman_options') + \ . ' -p ' . ale#Escape(l:rails_root) +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'brakeman', +\ 'executable': {b -> ale#Var(b, 'ruby_brakeman_executable')}, +\ 'command': function('ale_linters#ruby#brakeman#GetCommand'), +\ 'callback': 'ale_linters#ruby#brakeman#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/cspell.vim b/sources_non_forked/ale/ale_linters/ruby/cspell.vim new file mode 100644 index 00000000..780356b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Ruby files. + +call ale#handlers#cspell#DefineLinter('ruby') diff --git a/sources_non_forked/ale/ale_linters/ruby/debride.vim b/sources_non_forked/ale/ale_linters/ruby/debride.vim new file mode 100644 index 00000000..3b2cc443 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/debride.vim @@ -0,0 +1,42 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: debride, a dead method detector for Ruby files + +call ale#Set('ruby_debride_executable', 'debride') +call ale#Set('ruby_debride_options', '') + +function! ale_linters#ruby#debride#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_debride_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'debride') + \ . ale#Var(a:buffer, 'ruby_debride_options') + \ . ' %s' +endfunction + +function! ale_linters#ruby#debride#HandleOutput(buffer, lines) abort + let l:output = [] + + for l:line in a:lines + if l:line !~# '^ ' + continue + endif + + let l:elements = split(l:line) + let l:method_name = l:elements[0] + let l:lnum = split(l:elements[1], ':')[1] + + call add(l:output, { + \ 'lnum': 0 + l:lnum, + \ 'text': 'Possible unused method: ' . l:method_name, + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'debride', +\ 'executable': {b -> ale#Var(b, 'ruby_debride_executable')}, +\ 'command': function('ale_linters#ruby#debride#GetCommand'), +\ 'callback': 'ale_linters#ruby#debride#HandleOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim new file mode 100644 index 00000000..36646647 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/rails_best_practices.vim @@ -0,0 +1,49 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: rails_best_practices, a code metric tool for rails projects + +call ale#Set('ruby_rails_best_practices_options', '') +call ale#Set('ruby_rails_best_practices_executable', 'rails_best_practices') + +function! ale_linters#ruby#rails_best_practices#Handle(buffer, lines) abort + let l:output = [] + + for l:warning in ale#util#FuzzyJSONDecode(a:lines, []) + if !ale#path#IsBufferPath(a:buffer, l:warning.filename) + continue + endif + + call add(l:output, { + \ 'lnum': l:warning.line_number + 0, + \ 'type': 'W', + \ 'text': l:warning.message, + \}) + endfor + + return l:output +endfunction + +function! ale_linters#ruby#rails_best_practices#GetCommand(buffer) abort + let l:rails_root = ale#ruby#FindRailsRoot(a:buffer) + + if l:rails_root is? '' + return '' + endif + + let l:executable = ale#Var(a:buffer, 'ruby_rails_best_practices_executable') + let l:output_file = has('win32') ? '%t ' : '/dev/stdout ' + let l:cat_file = has('win32') ? '; type %t' : '' + + return ale#ruby#EscapeExecutable(l:executable, 'rails_best_practices') + \ . ' --silent -f json --output-file ' . l:output_file + \ . ale#Var(a:buffer, 'ruby_rails_best_practices_options') + \ . ale#Escape(l:rails_root) + \ . l:cat_file +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'rails_best_practices', +\ 'executable': {b -> ale#Var(b, 'ruby_rails_best_practices_executable')}, +\ 'command': function('ale_linters#ruby#rails_best_practices#GetCommand'), +\ 'callback': 'ale_linters#ruby#rails_best_practices#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/reek.vim b/sources_non_forked/ale/ale_linters/ruby/reek.vim new file mode 100644 index 00000000..b6fa9d76 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/reek.vim @@ -0,0 +1,69 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Reek, a code smell detector for Ruby files + +call ale#Set('ruby_reek_show_context', 0) +call ale#Set('ruby_reek_show_wiki_link', 0) +call ale#Set('ruby_reek_options', '') +call ale#Set('ruby_reek_executable', 'reek') + +function! ale_linters#ruby#reek#GetCommand(buffer, version) abort + let l:executable = ale#Var(a:buffer, 'ruby_reek_executable') + + " Tell reek what the filename is if the version of reek is new enough. + let l:display_name_args = ale#semver#GTE(a:version, [5, 0, 0]) + \ ? ' --stdin-filename %s' + \ : '' + + return ale#ruby#EscapeExecutable(l:executable, 'reek') + \ . ' -f json --no-progress --no-color --force-exclusion' + \ . l:display_name_args +endfunction + +function! s:GetDocumentationLink(error) abort + return get(a:error, 'documentation_link', get(a:error, 'wiki_link', '')) +endfunction + +function! s:BuildText(buffer, error) abort + let l:parts = [] + + if ale#Var(a:buffer, 'ruby_reek_show_context') + call add(l:parts, a:error.context) + endif + + call add(l:parts, a:error.message) + + if ale#Var(a:buffer, 'ruby_reek_show_wiki_link') + call add(l:parts, '[' . s:GetDocumentationLink(a:error) . ']') + endif + + return join(l:parts, ' ') +endfunction + +function! ale_linters#ruby#reek#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + for l:location in l:error.lines + call add(l:output, { + \ 'lnum': l:location, + \ 'type': 'W', + \ 'text': s:BuildText(a:buffer, l:error), + \ 'code': l:error.smell_type, + \}) + endfor + endfor + + return l:output +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'reek', +\ 'executable': {b -> ale#Var(b, 'ruby_reek_executable')}, +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'ruby_reek_executable'), +\ '%e --version', +\ function('ale_linters#ruby#reek#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#ruby#reek#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/rubocop.vim b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim new file mode 100644 index 00000000..483806a6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/rubocop.vim @@ -0,0 +1,31 @@ +" Author: ynonp - https://github.com/ynonp, Eddie Lebow https://github.com/elebow +" Description: RuboCop, a code style analyzer for Ruby files + +call ale#Set('ruby_rubocop_executable', 'rubocop') +call ale#Set('ruby_rubocop_options', '') + +function! ale_linters#ruby#rubocop#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') + \ . ' --format json --force-exclusion ' + \ . ale#Var(a:buffer, 'ruby_rubocop_options') + \ . ' --stdin %s' +endfunction + +function! ale_linters#ruby#rubocop#GetType(severity) abort + if a:severity is? 'convention' + \|| a:severity is? 'warning' + \|| a:severity is? 'refactor' + return 'W' + endif + + return 'E' +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'rubocop', +\ 'executable': {b -> ale#Var(b, 'ruby_rubocop_executable')}, +\ 'command': function('ale_linters#ruby#rubocop#GetCommand'), +\ 'callback': 'ale#ruby#HandleRubocopOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/ruby.vim b/sources_non_forked/ale/ale_linters/ruby/ruby.vim new file mode 100644 index 00000000..621fcbc0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/ruby.vim @@ -0,0 +1,12 @@ +" Author: Brandon Roehl - https://github.com/BrandonRoehl +" Description: Ruby MRI for Ruby files + +call ale#Set('ruby_ruby_executable', 'ruby') + +call ale#linter#Define('ruby', { +\ 'name': 'ruby', +\ 'executable': {b -> ale#Var(b, 'ruby_ruby_executable')}, +\ 'command': '%e -w -c %t', +\ 'output_stream': 'stderr', +\ 'callback': 'ale#handlers#ruby#HandleSyntaxErrors', +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/solargraph.vim b/sources_non_forked/ale/ale_linters/ruby/solargraph.vim new file mode 100644 index 00000000..bf54a55c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/solargraph.vim @@ -0,0 +1,22 @@ +" Author: Horacio Sanson - https://github.com/hsanson +" Description: Solargraph Language Server https://solargraph.org/ +" +" Author: Devon Meunier +" Description: updated to use stdio + +call ale#Set('ruby_solargraph_executable', 'solargraph') +call ale#Set('ruby_solargraph_options', {}) + +function! ale_linters#ruby#solargraph#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'solargraph', +\ 'lsp': 'stdio', +\ 'language': 'ruby', +\ 'executable': {b -> ale#Var(b, 'ruby_solargraph_executable')}, +\ 'command': function('ale_linters#ruby#solargraph#GetCommand'), +\ 'project_root': function('ale#ruby#FindProjectRoot'), +\ 'initialization_options': {b -> ale#Var(b, 'ruby_solargraph_options')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/ruby/sorbet.vim b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim new file mode 100644 index 00000000..c67e20cc --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/sorbet.vim @@ -0,0 +1,26 @@ +call ale#Set('ruby_sorbet_executable', 'srb') +call ale#Set('ruby_sorbet_options', '') +call ale#Set('ruby_sorbet_enable_watchman', 0) + +function! ale_linters#ruby#sorbet#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') + let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') + let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman') + + return ale#ruby#EscapeExecutable(l:executable, 'srb') + \ . ' tc' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --lsp' + \ . (l:enable_watchman ? '' : ' --disable-watchman') +endfunction + +call ale#linter#Define('ruby', { +\ 'name': 'sorbet', +\ 'aliases': ['srb'], +\ 'lsp': 'stdio', +\ 'language': 'ruby', +\ 'executable': {b -> ale#Var(b, 'ruby_sorbet_executable')}, +\ 'command': function('ale_linters#ruby#sorbet#GetCommand'), +\ 'project_root': function('ale#ruby#FindProjectRoot') +\}) + diff --git a/sources_non_forked/ale/ale_linters/ruby/standardrb.vim b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim new file mode 100644 index 00000000..6ccfd2d6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/ruby/standardrb.vim @@ -0,0 +1,23 @@ +" Author: Justin Searls https://github.com/searls, ynonp - https://github.com/ynonp, Eddie Lebow https://github.com/elebow +" based on the ale rubocop linter +" Description: StandardRB - Ruby Style Guide, with linter & automatic code fixer + +call ale#Set('ruby_standardrb_executable', 'standardrb') +call ale#Set('ruby_standardrb_options', '') + +function! ale_linters#ruby#standardrb#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable') + + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') + \ . ' --format json --force-exclusion ' + \ . ale#Var(a:buffer, 'ruby_standardrb_options') + \ . ' --stdin %s' +endfunction + +" standardrb is based on RuboCop so the callback is the same +call ale#linter#Define('ruby', { +\ 'name': 'standardrb', +\ 'executable': {b -> ale#Var(b, 'ruby_standardrb_executable')}, +\ 'command': function('ale_linters#ruby#standardrb#GetCommand'), +\ 'callback': 'ale#ruby#HandleRubocopOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/analyzer.vim b/sources_non_forked/ale/ale_linters/rust/analyzer.vim new file mode 100644 index 00000000..3ead3871 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/analyzer.vim @@ -0,0 +1,36 @@ +" Author: Jon Gjengset +" Description: The next generation language server for Rust + +call ale#Set('rust_analyzer_executable', 'rust-analyzer') +call ale#Set('rust_analyzer_config', {}) + +function! ale_linters#rust#analyzer#GetCommand(buffer) abort + return '%e' +endfunction + +function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort + " Try to find nearest Cargo.toml for cargo projects + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + if !empty(l:cargo_file) + return fnamemodify(l:cargo_file, ':h') + endif + + " Try to find nearest rust-project.json for non-cargo projects + let l:rust_project = ale#path#FindNearestFile(a:buffer, 'rust-project.json') + + if !empty(l:rust_project) + return fnamemodify(l:rust_project, ':h') + endif + + return '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'analyzer', +\ 'lsp': 'stdio', +\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')}, +\ 'command': function('ale_linters#rust#analyzer#GetCommand'), +\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/cargo.vim b/sources_non_forked/ale/ale_linters/rust/cargo.vim new file mode 100644 index 00000000..37fd10a8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/cargo.vim @@ -0,0 +1,110 @@ +" Author: Daniel Schemala , +" Ivan Petkov +" Description: rustc invoked by cargo for rust files + +call ale#Set('rust_cargo_use_check', 1) +call ale#Set('rust_cargo_check_all_targets', 0) +call ale#Set('rust_cargo_check_examples', 0) +call ale#Set('rust_cargo_check_tests', 0) +call ale#Set('rust_cargo_avoid_whole_workspace', 1) +call ale#Set('rust_cargo_default_feature_behavior', 'default') +call ale#Set('rust_cargo_include_features', '') +call ale#Set('rust_cargo_use_clippy', 0) +call ale#Set('rust_cargo_clippy_options', '') +call ale#Set('rust_cargo_target_dir', '') + +function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort + if ale#path#FindNearestFile(a:bufnr, 'Cargo.toml') isnot# '' + return 'cargo' + else + " if there is no Cargo.toml file, we don't use cargo even if it exists, + " so we return '', because executable('') apparently always fails + return '' + endif +endfunction + +function! ale_linters#rust#cargo#GetCwd(buffer) abort + if ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace') + let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h') + + if l:nearest_cargo_dir isnot# '.' + return l:nearest_cargo_dir + endif + endif + + return '' +endfunction + +function! ale_linters#rust#cargo#GetCommand(buffer, version) abort + let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check') + \ && ale#semver#GTE(a:version, [0, 17, 0]) + let l:use_all_targets = ale#Var(a:buffer, 'rust_cargo_check_all_targets') + \ && ale#semver#GTE(a:version, [0, 22, 0]) + let l:use_examples = ale#Var(a:buffer, 'rust_cargo_check_examples') + \ && ale#semver#GTE(a:version, [0, 22, 0]) + let l:use_tests = ale#Var(a:buffer, 'rust_cargo_check_tests') + \ && ale#semver#GTE(a:version, [0, 22, 0]) + let l:target_dir = ale#Var(a:buffer, 'rust_cargo_target_dir') + let l:use_target_dir = !empty(l:target_dir) + \ && ale#semver#GTE(a:version, [0, 17, 0]) + + let l:include_features = ale#Var(a:buffer, 'rust_cargo_include_features') + + if !empty(l:include_features) + let l:include_features = ' --features ' . ale#Escape(l:include_features) + endif + + let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior') + + if l:default_feature_behavior is# 'all' + let l:include_features = '' + let l:default_feature = ' --all-features' + elseif l:default_feature_behavior is# 'none' + let l:default_feature = ' --no-default-features' + else + let l:default_feature = '' + endif + + let l:subcommand = l:use_check ? 'check' : 'build' + let l:clippy_options = '' + + if ale#Var(a:buffer, 'rust_cargo_use_clippy') + let l:subcommand = 'clippy' + let l:clippy_options = ale#Var(a:buffer, 'rust_cargo_clippy_options') + + if l:clippy_options =~# '^-- ' + let l:clippy_options = join(split(l:clippy_options, '-- ')) + endif + + if l:clippy_options isnot# '' + let l:clippy_options = ' -- ' . l:clippy_options + endif + endif + + return 'cargo ' + \ . l:subcommand + \ . (l:use_all_targets ? ' --all-targets' : '') + \ . (l:use_examples ? ' --examples' : '') + \ . (l:use_tests ? ' --tests' : '') + \ . (l:use_target_dir ? (' --target-dir ' . ale#Escape(l:target_dir)) : '') + \ . ' --frozen --message-format=json -q' + \ . l:default_feature + \ . l:include_features + \ . l:clippy_options +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'cargo', +\ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'), +\ 'cwd': function('ale_linters#rust#cargo#GetCwd'), +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale_linters#rust#cargo#GetCargoExecutable(buffer), +\ '%e --version', +\ function('ale_linters#rust#cargo#GetCommand'), +\ )}, +\ 'callback': 'ale#handlers#rust#HandleRustErrors', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/cspell.vim b/sources_non_forked/ale/ale_linters/rust/cspell.vim new file mode 100644 index 00000000..d2523c7d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Rust files. + +call ale#handlers#cspell#DefineLinter('rust') diff --git a/sources_non_forked/ale/ale_linters/rust/rls.vim b/sources_non_forked/ale/ale_linters/rust/rls.vim new file mode 100644 index 00000000..111d7558 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/rls.vim @@ -0,0 +1,27 @@ +" Author: w0rp +" Description: A language server for Rust + +call ale#Set('rust_rls_executable', 'rls') +call ale#Set('rust_rls_toolchain', '') +call ale#Set('rust_rls_config', {}) + +function! ale_linters#rust#rls#GetCommand(buffer) abort + let l:toolchain = ale#Var(a:buffer, 'rust_rls_toolchain') + + return '%e' . (!empty(l:toolchain) ? ' +' . ale#Escape(l:toolchain) : '') +endfunction + +function! ale_linters#rust#rls#GetProjectRoot(buffer) abort + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : '' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'rls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'rust_rls_config')}, +\ 'executable': {b -> ale#Var(b, 'rust_rls_executable')}, +\ 'command': function('ale_linters#rust#rls#GetCommand'), +\ 'project_root': function('ale_linters#rust#rls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/rust/rustc.vim b/sources_non_forked/ale/ale_linters/rust/rustc.vim new file mode 100644 index 00000000..bc6431ba --- /dev/null +++ b/sources_non_forked/ale/ale_linters/rust/rustc.vim @@ -0,0 +1,33 @@ +" Author: Daniel Schemala +" Description: rustc for rust files + +call ale#Set('rust_rustc_options', '--emit=mir -o /dev/null') + +function! ale_linters#rust#rustc#RustcCommand(buffer) abort + " Try to guess the library search path. If the project is managed by cargo, + " it's usually /target/debug/deps/ or + " /target/release/deps/ + let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml') + + if l:cargo_file isnot# '' + let l:root = fnamemodify(l:cargo_file, ':h') + let l:dependencies = ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/debug/deps')) + \ . ' -L ' . ale#Escape(ale#path#GetAbsPath(l:root, 'target/release/deps')) + else + let l:dependencies = '' + endif + + let l:options = ale#Var(a:buffer, 'rust_rustc_options') + + return 'rustc --error-format=json' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . l:dependencies . ' -' +endfunction + +call ale#linter#Define('rust', { +\ 'name': 'rustc', +\ 'executable': 'rustc', +\ 'command': function('ale_linters#rust#rustc#RustcCommand'), +\ 'callback': 'ale#handlers#rust#HandleRustErrors', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/salt/salt_lint.vim b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim new file mode 100644 index 00000000..47f66d83 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/salt/salt_lint.vim @@ -0,0 +1,33 @@ +" Author: Benjamin BINIER +" Description: salt-lint, saltstack linter + +call ale#Set('salt_salt_lint_executable', 'salt-lint') +call ale#Set('salt_salt_lint_options', '') + +function! ale_linters#salt#salt_lint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options')) + \ . ' --json' +endfunction + +function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + call add(l:output, { + \ 'lnum': l:error.linenumber + 0, + \ 'code': l:error.id + 0, + \ 'text': l:error.message, + \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('salt', { +\ 'name': 'salt_lint', +\ 'aliases': ['salt-lint'], +\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')}, +\ 'command': function('ale_linters#salt#salt_lint#GetCommand'), +\ 'callback': 'ale_linters#salt#salt_lint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/sass/sasslint.vim b/sources_non_forked/ale/ale_linters/sass/sasslint.vim new file mode 100644 index 00000000..ff396e68 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sass/sasslint.vim @@ -0,0 +1,28 @@ +" Author: sQVe - https://github.com/sQVe + +call ale#Set('sass_sasslint_executable', 'sass-lint') +call ale#Set('sass_sasslint_options', '') +call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#sass#sasslint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'sass_sasslint', [ + \ 'node_modules/sass-lint/bin/sass-lint.js', + \ 'node_modules/.bin/sass-lint', + \]) +endfunction + +function! ale_linters#sass#sasslint#GetCommand(buffer) abort + let l:executable = ale_linters#sass#sasslint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'sass_sasslint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -v -q -f compact %t' +endfunction + +call ale#linter#Define('sass', { +\ 'name': 'sasslint', +\ 'executable': function('ale_linters#sass#sasslint#GetExecutable'), +\ 'command': function('ale_linters#sass#sasslint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/sass/stylelint.vim b/sources_non_forked/ale/ale_linters/sass/stylelint.vim new file mode 100644 index 00000000..22abef9b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sass/stylelint.vim @@ -0,0 +1,13 @@ +" Author: diartyz + +call ale#Set('sass_stylelint_executable', 'stylelint') +call ale#Set('sass_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('sass', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'sass_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': '%e --stdin-filename %s', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/cspell.vim b/sources_non_forked/ale/ale_linters/scala/cspell.vim new file mode 100644 index 00000000..fa09d420 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Scala files. + +call ale#handlers#cspell#DefineLinter('scala') diff --git a/sources_non_forked/ale/ale_linters/scala/fsc.vim b/sources_non_forked/ale/ale_linters/scala/fsc.vim new file mode 100644 index 00000000..94135235 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/fsc.vim @@ -0,0 +1,14 @@ +" Author: Nils Leuzinger - https://github.com/PawkyPenguin +" Description: Basic scala support using fsc + +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'fsc', +\ 'executable': {buf -> s:IsSbt(buf) ? '' : 'fsc'}, +\ 'command': '%e -Ystop-after:parser %t', +\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/metals.vim b/sources_non_forked/ale/ale_linters/scala/metals.vim new file mode 100644 index 00000000..da9e855d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/metals.vim @@ -0,0 +1,50 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Metals Language Server for Scala https://scalameta.org/metals/ + +call ale#Set('scala_metals_executable', 'metals-vim') +call ale#Set('scala_metals_project_root', '') + +function! ale_linters#scala#metals#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_metals_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:potential_roots = [ + \ 'build.sc', + \ 'build.sbt', + \ '.bloop', + \ '.metals', + \] + + for l:root in l:potential_roots + let l:project_root = ale#path#ResolveLocalPath( + \ a:buffer, + \ l:root, + \ '' + \) + + if !empty(l:project_root) + return fnamemodify( + \ l:project_root, + \ ':h', + \) + endif + endfor + + return '' +endfunction + +function! ale_linters#scala#metals#GetCommand(buffer) abort + return '%e' . ale#Pad('stdio') +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'metals', +\ 'lsp': 'stdio', +\ 'language': 'scala', +\ 'executable': {b -> ale#Var(b, 'scala_metals_executable')}, +\ 'command': function('ale_linters#scala#metals#GetCommand'), +\ 'project_root': function('ale_linters#scala#metals#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/sbtserver.vim b/sources_non_forked/ale/ale_linters/scala/sbtserver.vim new file mode 100644 index 00000000..d4f137c2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/sbtserver.vim @@ -0,0 +1,31 @@ +" Author: ophirr33 +" Description: TCP lsp client for sbt Server + +call ale#Set('scala_sbtserver_address', '127.0.0.1:4273') +call ale#Set('scala_sbtserver_project_root', '') + +function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_sbtserver_project_root') + + if l:project_root is? '' + let l:project_root = ale#path#FindNearestFile(a:buffer, 'build.sbt') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' + endif + + return l:project_root +endfunction + +function! ale_linters#scala#sbtserver#GetAddress(buffer) abort + let l:address = ale#Var(a:buffer, 'scala_sbtserver_address') + + return l:address +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'sbtserver', +\ 'lsp': 'socket', +\ 'address': function('ale_linters#scala#sbtserver#GetAddress'), +\ 'language': 'scala', +\ 'project_root': function('ale_linters#scala#sbtserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/scalac.vim b/sources_non_forked/ale/ale_linters/scala/scalac.vim new file mode 100644 index 00000000..1dd579b4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/scalac.vim @@ -0,0 +1,15 @@ +" Author: Zoltan Kalmar - https://github.com/kalmiz, +" w0rp +" Description: Basic scala support using scalac + +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'scalac', +\ 'executable': {buf -> s:IsSbt(buf) ? '' : 'scalac'}, +\ 'command': '%e -Ystop-after:parser %t', +\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/scala/scalastyle.vim b/sources_non_forked/ale/ale_linters/scala/scalastyle.vim new file mode 100644 index 00000000..6e9e4c13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scala/scalastyle.vim @@ -0,0 +1,86 @@ +" Author: Kevin Kays - https://github.com/okkays +" Description: Support for the scalastyle checker. + +call ale#Set('scala_scalastyle_options', '') +" TODO: Remove support for the old option name in ALE 3.0. +call ale#Set('scala_scalastyle_config', +\ get(g:, 'ale_scalastyle_config_loc', '') +\) + +function! ale_linters#scala#scalastyle#Handle(buffer, lines) abort + " Look for help output from scalastyle first, which indicates that no + " configuration file was found. + for l:line in a:lines[:10] + if l:line =~# '-c, --config' + return [{ + \ 'lnum': 1, + \ 'text': '(See :help ale-scala-scalastyle)' + \ . ' No scalastyle configuration file was found.', + \}] + endif + endfor + + " Matches patterns like the following: + " + " warning file=/home/blurble/Doop.scala message=Missing or badly formed ScalaDoc: Extra @param foobles line=190 + let l:patterns = [ + \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\)$', + \ '^\(.\+\) .\+ message=\(.\+\) line=\(\d\+\) column=\(\d\+\)$', + \] + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:patterns) + let l:args = { + \ 'lnum': l:match[3] + 0, + \ 'type': l:match[1] =~? 'error' ? 'E' : 'W', + \ 'text': l:match[2] + \} + + if !empty(l:match[4]) + let l:args['col'] = l:match[4] + 1 + endif + + call add(l:output, l:args) + endfor + + return l:output +endfunction + +function! ale_linters#scala#scalastyle#GetCommand(buffer) abort + " Search for scalastyle config in parent directories. + let l:scalastyle_config = '' + let l:potential_configs = [ + \ 'scalastyle_config.xml', + \ 'scalastyle-config.xml' + \] + + for l:config in l:potential_configs + let l:scalastyle_config = ale#path#ResolveLocalPath( + \ a:buffer, + \ l:config, + \ '' + \) + + if !empty(l:scalastyle_config) + break + endif + endfor + + " If all else fails, try the global config. + if empty(l:scalastyle_config) + let l:scalastyle_config = ale#Var(a:buffer, 'scala_scalastyle_config') + endif + + return 'scalastyle' + \ . (!empty(l:scalastyle_config) ? ' --config ' . ale#Escape(l:scalastyle_config) : '') + \ . ale#Pad(ale#Var(a:buffer, 'scala_scalastyle_options')) + \ . ' %t' +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'scalastyle', +\ 'executable': 'scalastyle', +\ 'output_stream': 'stdout', +\ 'command': function('ale_linters#scala#scalastyle#GetCommand'), +\ 'callback': 'ale_linters#scala#scalastyle#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/scss/sasslint.vim b/sources_non_forked/ale/ale_linters/scss/sasslint.vim new file mode 100644 index 00000000..99027051 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scss/sasslint.vim @@ -0,0 +1,28 @@ +" Author: sQVe - https://github.com/sQVe + +call ale#Set('scss_sasslint_executable', 'sass-lint') +call ale#Set('scss_sasslint_options', '') +call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#scss#sasslint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'scss_sasslint', [ + \ 'node_modules/sass-lint/bin/sass-lint.js', + \ 'node_modules/.bin/sass-lint', + \]) +endfunction + +function! ale_linters#scss#sasslint#GetCommand(buffer) abort + let l:executable = ale_linters#scss#sasslint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'scss_sasslint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -v -q -f compact %t' +endfunction + +call ale#linter#Define('scss', { +\ 'name': 'sasslint', +\ 'executable': function('ale_linters#scss#sasslint#GetExecutable'), +\ 'command': function('ale_linters#scss#sasslint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/scss/scsslint.vim b/sources_non_forked/ale/ale_linters/scss/scsslint.vim new file mode 100644 index 00000000..7ce57241 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scss/scsslint.vim @@ -0,0 +1,34 @@ +" Author: w0rp +" Description: This file add scsslint support for SCSS support + +function! ale_linters#scss#scsslint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " test.scss:2:1 [W] Indentation: Line should be indented 2 spaces, but was indented 4 spaces + let l:pattern = '^.*:\(\d\+\):\(\d*\) \[\([^\]]\+\)\] \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + \&& l:match[4] =~# '^TrailingWhitespace' + " Skip trailing whitespace warnings if that option is off. + continue + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3] is# 'E' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('scss', { +\ 'name': 'scsslint', +\ 'executable': 'scss-lint', +\ 'command': 'scss-lint --stdin-file-path=%s', +\ 'callback': 'ale_linters#scss#scsslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/scss/stylelint.vim b/sources_non_forked/ale/ale_linters/scss/stylelint.vim new file mode 100644 index 00000000..fea4ea8f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/scss/stylelint.vim @@ -0,0 +1,19 @@ +" Author: diartyz + +call ale#Set('scss_stylelint_executable', 'stylelint') +call ale#Set('scss_stylelint_options', '') +call ale#Set('scss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#scss#stylelint#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'scss_stylelint_options')) + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('scss', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'scss_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': function('ale_linters#scss#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/bashate.vim b/sources_non_forked/ale/ale_linters/sh/bashate.vim new file mode 100644 index 00000000..3cd84245 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/bashate.vim @@ -0,0 +1,43 @@ +" Author: hsanson +" Description: Lints sh files using bashate +" URL: https://github.com/openstack/bashate + +call ale#Set('sh_bashate_executable', 'bashate') +call ale#Set('sh_bashate_options', '') + +function! ale_linters#sh#bashate#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'sh_bashate_executable') +endfunction + +function! ale_linters#sh#bashate#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'sh_bashate_options') + let l:executable = ale_linters#sh#bashate#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:options . ' ' . '%t' +endfunction + +function! ale_linters#sh#bashate#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " /path/to/script/file:694:1: E003 Indent not multiple of 4 + let l:pattern = ':\(\d\+\):\(\d\+\): \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'bashate', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#sh#bashate#GetExecutable'), +\ 'command': function('ale_linters#sh#bashate#GetCommand'), +\ 'callback': 'ale_linters#sh#bashate#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/cspell.vim b/sources_non_forked/ale/ale_linters/sh/cspell.vim new file mode 100644 index 00000000..e3c5a6f0 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for shell scripts. + +call ale#handlers#cspell#DefineLinter('sh') diff --git a/sources_non_forked/ale/ale_linters/sh/language_server.vim b/sources_non_forked/ale/ale_linters/sh/language_server.vim new file mode 100644 index 00000000..c6781584 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/language_server.vim @@ -0,0 +1,32 @@ +" Author: Christian Höltje (https://docwhat.org/) +" Description: BASH Language server integration for ALE +scriptencoding utf-8 + +call ale#Set('sh_language_server_executable', 'bash-language-server') +call ale#Set('sh_language_server_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#sh#language_server#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'sh_language_server', [ + \ 'node_modules/.bin/bash-language-server', + \]) +endfunction + +function! ale_linters#sh#language_server#GetCommand(buffer) abort + let l:exe = ale#Escape(ale_linters#sh#language_server#GetExecutable(a:buffer)) + + return l:exe . ' start' +endfunction + +function! ale_linters#sh#language_server#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'language_server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#sh#language_server#GetExecutable'), +\ 'command': function('ale_linters#sh#language_server#GetCommand'), +\ 'project_root': function('ale_linters#sh#language_server#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/shell.vim b/sources_non_forked/ale/ale_linters/sh/shell.vim new file mode 100644 index 00000000..73ab3608 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/shell.vim @@ -0,0 +1,59 @@ +" Author: w0rp +" Description: Lints shell files by invoking the shell with -n + +" Backwards compatibility +if exists('g:ale_linters_sh_shell_default_shell') + let g:ale_sh_shell_default_shell = g:ale_linters_sh_shell_default_shell +endif + +" This option can be changed to change the default shell when the shell +" cannot be taken from the hashbang line. +if !exists('g:ale_sh_shell_default_shell') + let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t') + + if g:ale_sh_shell_default_shell is# '' || g:ale_sh_shell_default_shell is# 'fish' + let g:ale_sh_shell_default_shell = 'bash' + endif +endif + +function! ale_linters#sh#shell#GetExecutable(buffer) abort + let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) + + if !empty(l:shell_type) + return l:shell_type + endif + + return ale#Var(a:buffer, 'sh_shell_default_shell') +endfunction + +function! ale_linters#sh#shell#GetCommand(buffer) abort + return ale_linters#sh#shell#GetExecutable(a:buffer) . ' -n %t' +endfunction + +function! ale_linters#sh#shell#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " bash: line 13: syntax error near unexpected token `d' + " bash:行0: 未预期的符号“done”附近有语法错误 + " bash: 列 90: 尋找匹配的「"」時遇到了未預期的檔案結束符 + " sh: 11: Syntax error: "(" unexpected + let l:pattern = '\v([^:]+:\D*)(\d+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'shell', +\ 'output_stream': 'stderr', +\ 'executable': function('ale_linters#sh#shell#GetExecutable'), +\ 'command': function('ale_linters#sh#shell#GetCommand'), +\ 'callback': 'ale_linters#sh#shell#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sh/shellcheck.vim b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim new file mode 100644 index 00000000..d9945126 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sh/shellcheck.vim @@ -0,0 +1,4 @@ +" Author: w0rp +" Description: shellcheck linter for shell scripts. + +call ale#handlers#shellcheck#DefineLinter('sh') diff --git a/sources_non_forked/ale/ale_linters/slim/slimlint.vim b/sources_non_forked/ale/ale_linters/slim/slimlint.vim new file mode 100644 index 00000000..1b365e25 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/slim/slimlint.vim @@ -0,0 +1,55 @@ +" Author: Markus Doits - https://github.com/doits +" Description: slim-lint for Slim files + +function! ale_linters#slim#slimlint#GetCommand(buffer) abort + let l:command = 'slim-lint %t' + + let l:rubocop_config = ale#path#FindNearestFile(a:buffer, '.rubocop.yml') + + " Set SLIM_LINT_RUBOCOP_CONF variable as it is needed for slim-lint to + " pick up the rubocop config. + " + " See https://github.com/sds/slim-lint/blob/master/lib/slim_lint/linter/README.md#rubocop + if !empty(l:rubocop_config) + if has('win32') + let l:command = 'set SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' && ' . l:command + else + let l:command = 'SLIM_LINT_RUBOCOP_CONF=' . ale#Escape(l:rubocop_config) . ' ' . l:command + endif + endif + + return l:command +endfunction + +function! ale_linters#slim#slimlint#Handle(buffer, lines) abort + " Matches patterns like the following: + " :5 [W] LineLength: Line is too long. [150/120] + let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2], + \ 'text': l:match[3] + \} + + let l:code_match = matchlist(l:item.text, '\v^([^:]+): (.+)$') + + if !empty(l:code_match) + let l:item.code = l:code_match[1] + let l:item.text = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('slim', { +\ 'name': 'slimlint', +\ 'executable': 'slim-lint', +\ 'command': function('ale_linters#slim#slimlint#GetCommand'), +\ 'callback': 'ale_linters#slim#slimlint#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/sml/smlnj.vim b/sources_non_forked/ale/ale_linters/sml/smlnj.vim new file mode 100644 index 00000000..852ea170 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sml/smlnj.vim @@ -0,0 +1,9 @@ +" Author: Paulo Alem , Jake Zimmerman +" Description: Single-file SML checking with SML/NJ compiler + +call ale#linter#Define('sml', { +\ 'name': 'smlnj', +\ 'executable': function('ale#handlers#sml#GetExecutableSmlnjFile'), +\ 'command': 'sml', +\ 'callback': 'ale#handlers#sml#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim b/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim new file mode 100644 index 00000000..9ad24af4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sml/smlnj_cm.vim @@ -0,0 +1,21 @@ +" Author: Jake Zimmerman +" Description: SML checking with SML/NJ Compilation Manager + +function! ale_linters#sml#smlnj_cm#GetCommand(buffer) abort + let l:cmfile = ale#handlers#sml#GetCmFile(a:buffer) + + return 'sml -m ' . l:cmfile . ' < /dev/null' +endfunction + +" Using CM requires that we set "lint_file: 1", since it reads the files +" from the disk itself. +call ale#linter#Define('sml', { +\ 'name': 'smlnj_cm', +\ 'aliases': ['smlnj-cm'], +\ 'executable': function('ale#handlers#sml#GetExecutableSmlnjCm'), +\ 'lint_file': 1, +\ 'command': function('ale_linters#sml#smlnj_cm#GetCommand'), +\ 'callback': 'ale#handlers#sml#Handle', +\}) + +" vim:ts=4:sts=4:sw=4 diff --git a/sources_non_forked/ale/ale_linters/solidity/solc.vim b/sources_non_forked/ale/ale_linters/solidity/solc.vim new file mode 100644 index 00000000..28977083 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/solidity/solc.vim @@ -0,0 +1,53 @@ +" Author: Karl Bartel - http://karl.berlin/ +" Description: Report solc compiler errors in Solidity code + +call ale#Set('solidity_solc_executable', 'solc') +call ale#Set('solidity_solc_options', '') + +function! ale_linters#solidity#solc#Handle(buffer, lines) abort + " Matches patterns like the following: + " Error: Expected ';' but got '(' + " --> /path/to/file/file.sol:1:10:) + let l:pattern = '\v(Error|Warning): (.*)$' + let l:line_and_column_pattern = '\v\.sol:(\d+):(\d+):' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:line_and_column_pattern) + + if len(l:match) > 0 + let l:index = len(l:output) - 1 + let l:output[l:index]['lnum'] = l:match[1] + 0 + let l:output[l:index]['col'] = l:match[2] + 0 + endif + else + let l:isError = l:match[1] is? 'Error' + + call add(l:output, { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:match[2], + \ 'type': l:isError ? 'E' : 'W', + \}) + endif + endfor + + return l:output +endfunction + +function! ale_linters#solidity#solc#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'solidity_solc_executable') + + return l:executable . ale#Pad(ale#Var(a:buffer, 'solidity_solc_options')) . ' %s' +endfunction + +call ale#linter#Define('solidity', { +\ 'name': 'solc', +\ 'executable': {b -> ale#Var(b, 'solidity_solc_executable')}, +\ 'command': function('ale_linters#solidity#solc#GetCommand'), +\ 'callback': 'ale_linters#solidity#solc#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/solidity/solhint.vim b/sources_non_forked/ale/ale_linters/solidity/solhint.vim new file mode 100644 index 00000000..505bd5bb --- /dev/null +++ b/sources_non_forked/ale/ale_linters/solidity/solhint.vim @@ -0,0 +1,12 @@ +" Authors: Franco Victorio - https://github.com/fvictorio, Henrique Barcelos +" https://github.com/hbarcelos +" Description: Report errors in Solidity code with solhint + +call ale#linter#Define('solidity', { +\ 'name': 'solhint', +\ 'output_stream': 'both', +\ 'executable': function('ale#handlers#solhint#GetExecutable'), +\ 'cwd': function('ale#handlers#solhint#GetCwd'), +\ 'command': function('ale#handlers#solhint#GetCommand'), +\ 'callback': 'ale#handlers#solhint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/solidity/solium.vim b/sources_non_forked/ale/ale_linters/solidity/solium.vim new file mode 100644 index 00000000..61ab184d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/solidity/solium.vim @@ -0,0 +1,9 @@ +" Author: Jeff Sutherland - https://github.com/jdsutherland +" Description: Report errors in Solidity code with solium + +call ale#linter#Define('solidity', { +\ 'name': 'solium', +\ 'executable': 'solium', +\ 'command': 'solium --reporter gcc --file %t', +\ 'callback': 'ale#handlers#gcc#HandleGCCFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/spec/rpmlint.vim b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim new file mode 100644 index 00000000..5594e3b8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/spec/rpmlint.vim @@ -0,0 +1,90 @@ +" Author: Jason Tibbitts +" Description: Adds support for checking RPM spec files with rpmlint + +" rpmlint will produce varions types of output: +" +" Lines like the following are output when the file is simply not able to be +" parsed by rpmspec -P: +" apcupsd.spec: E: specfile-error warning: bogus date in %changelog: Mon Oct 1 2005 - Foo +" apcupsd.spec: E: specfile-error error: %changelog not in descending chronological order +" They do not contain a line number, and there's not a whole lot that can be +" done to locate them besides grep for them. rpmlint is just passing the +" output from rpm along with the filename, an error indicator, and an error +" type. +" +" Lines like the following: +" cyrus-imapd.spec:23: W: macro-in-comment %version +" cyrus-imapd.spec:18: E: hardcoded-library-path in %_prefix/lib/%name +" indicate warnings and errors, respectively. No column numbers are provided +" +" Lines like: +" apcupsd.spec: I: checking +" apcupsd.spec: I: checking-url https://downloads.sourceforge.net/apcupsd/apcupsd-3.14.14.tar.gz (timeout 10 seconds) +" are merely informational and are only output when -v is passed. But they +" may be useful in a log to know why things are taking so long. +" +" And this is always output at the end and should just be ignored: +" 0 packages and 1 specfiles checked; 4 errors, 0 warnings. + +call ale#Set('spec_rpmlint_executable', 'rpmlint') +call ale#Set('spec_rpmlint_options', '') + +function! ale_linters#spec#rpmlint#GetCommand(buffer, version) abort + if ale#semver#GTE(a:version, [2, 0, 0]) + " The -o/--option flag was removed in version 2.0.0 + let l:version_dependent_args = '' + else + let l:version_dependent_args = ' -o "NetworkEnabled False"' + endif + + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options')) + \ . ' -v' + \ . l:version_dependent_args + \ . ' %t' +endfunction + +function! ale_linters#spec#rpmlint#Handle(buffer, lines) abort + " let l:pat_inform = '^.\+: I: \(.+\)' + let l:pat_errwarn = '^.\+:\(\d\+\): \([EW]\): \(.\+\)' + let l:pat_baderr = '^.\+: E: \(.\+\)' + let l:output = [] + + for l:line in a:lines + let l:match_errwarn = matchlist(l:line, l:pat_errwarn) + let l:match_baderr = matchlist(l:line, l:pat_baderr) + + if len(l:match_errwarn) > 0 + let l:text = l:match_errwarn[3] + let l:type = l:match_errwarn[2] + let l:lnum = l:match_errwarn[1] + 0 + elseif len(l:match_baderr) > 0 + let l:text = l:match_baderr[1] + let l:type = 'E' + let l:lnum = 1 + else + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ 'lnum': l:lnum, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('spec', { +\ 'name': 'rpmlint', +\ 'executable': {b -> ale#Var(b, 'spec_rpmlint_executable')}, +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'spec_rpmlint_executable'), +\ '%e --version', +\ function('ale_linters#spec#rpmlint#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#spec#rpmlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sql/sqlint.vim b/sources_non_forked/ale/ale_linters/sql/sqlint.vim new file mode 100644 index 00000000..ca893724 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sql/sqlint.vim @@ -0,0 +1,28 @@ +" Author: Adriaan Zonnenberg +" Description: sqlint for SQL files + +function! ale_linters#sql#sqlint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " stdin:3:1:ERROR syntax error at or near "WIBBLE" + let l:pattern = '\v^[^:]+:(\d+):(\d+):(\u+) (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3][0], + \ 'text': l:match[4], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sql', { +\ 'name': 'sqlint', +\ 'executable': 'sqlint', +\ 'command': 'sqlint', +\ 'callback': 'ale_linters#sql#sqlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/sql/sqllint.vim b/sources_non_forked/ale/ale_linters/sql/sqllint.vim new file mode 100644 index 00000000..78396fe9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sql/sqllint.vim @@ -0,0 +1,33 @@ +" ale_linters/sql/sqllint.vim +" Author: Joe Reynolds +" Description: sql-lint for SQL files. +" sql-lint can be found at +" https://www.npmjs.com/package/sql-lint +" https://github.com/joereynolds/sql-lint + +function! ale_linters#sql#sqllint#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " stdin:1 [ER_NO_DB_ERROR] No database selected + let l:pattern = '\v^[^:]+:(\d+) (.*)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3][0], + \ 'text': l:match[0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sql', { +\ 'name': 'sqllint', +\ 'aliases': ['sql-lint'], +\ 'executable': 'sql-lint', +\ 'command': 'sql-lint', +\ 'callback': 'ale_linters#sql#sqllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/stylus/stylelint.vim b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim new file mode 100644 index 00000000..b60e38ed --- /dev/null +++ b/sources_non_forked/ale/ale_linters/stylus/stylelint.vim @@ -0,0 +1,20 @@ +" Author: diartyz , w0rp + +call ale#Set('stylus_stylelint_executable', 'stylelint') +call ale#Set('stylus_stylelint_options', '') +call ale#Set('stylus_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#stylus#stylelint#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'stylus_stylelint_options')) + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('stylus', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'stylus_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': function('ale_linters#stylus#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim new file mode 100644 index 00000000..879ff0ca --- /dev/null +++ b/sources_non_forked/ale/ale_linters/sugarss/stylelint.vim @@ -0,0 +1,21 @@ +" Author: toastal +" Description: `stylelint` linter for SugarSS files + +call ale#Set('sugarss_stylelint_executable', 'stylelint') +call ale#Set('sugarss_stylelint_options', '') +call ale#Set('sugarss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#sugarss#stylelint#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'sugarss_stylelint_options')) + \ . ' --syntax=sugarss' + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('sugarss', { +\ 'name': 'stylelint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'sugarss_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ])}, +\ 'command': function('ale_linters#sugarss#stylelint#GetCommand'), +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim new file mode 100644 index 00000000..2200b582 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/svelte/svelteserver.vim @@ -0,0 +1,21 @@ +" Author: Joakim Repomaa +" Description: Svelte Language Server integration for ALE + +call ale#Set('svelte_svelteserver_executable', 'svelteserver') +call ale#Set('svelte_svelteserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#svelte#svelteserver#GetProjectRoot(buffer) abort + let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') + + return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : '' +endfunction + +call ale#linter#Define('svelte', { +\ 'name': 'svelteserver', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'svelte_svelteserver', [ +\ 'node_modules/.bin/svelteserver', +\ ])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#svelte#svelteserver#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim new file mode 100644 index 00000000..4c61764d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/appleswiftformat.vim @@ -0,0 +1,43 @@ +" Authors: Klaas Pieter Annema , bosr +" Description: Support for swift-format https://github.com/apple/swift-format + +function! ale_linters#swift#appleswiftformat#GetLinterCommand(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' lint %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return l:command_args +endfunction + +function! ale_linters#swift#appleswiftformat#Handle(buffer, lines) abort + " Matches the typical output of swift-format, that is lines of the following pattern: + " + " Sources/main.swift:4:21: warning: [DoNotUseSemicolons] remove ';' and move the next statement to the new line + " Sources/main.swift:3:12: warning: [Spacing] remove 1 space + let l:pattern = '\v^.*:(\d+):(\d+): (\S+): \[(\S+)\] (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('swift', { +\ 'name': 'apple-swift-format', +\ 'executable': function('ale#swift#GetAppleSwiftFormatExecutable'), +\ 'command': function('ale_linters#swift#appleswiftformat#GetLinterCommand'), +\ 'output_stream': 'stderr', +\ 'language': 'swift', +\ 'callback': 'ale_linters#swift#appleswiftformat#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/cspell.vim b/sources_non_forked/ale/ale_linters/swift/cspell.vim new file mode 100644 index 00000000..25451e9d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Swift files. + +call ale#handlers#cspell#DefineLinter('swift') diff --git a/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim b/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim new file mode 100644 index 00000000..560893bf --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/sourcekitlsp.vim @@ -0,0 +1,13 @@ +" Author: Dan Loman +" Description: Support for sourcekit-lsp https://github.com/apple/sourcekit-lsp + +call ale#Set('sourcekit_lsp_executable', 'sourcekit-lsp') + +call ale#linter#Define('swift', { +\ 'name': 'sourcekitlsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'sourcekit_lsp_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale#swift#FindProjectRoot'), +\ 'language': 'swift', +\}) diff --git a/sources_non_forked/ale/ale_linters/swift/swiftlint.vim b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim new file mode 100644 index 00000000..d08c68f6 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/swift/swiftlint.vim @@ -0,0 +1,69 @@ +" Author: David Mohundro , Gordon Fontenot +" Description: swiftlint for swift files + +call ale#Set('swift_swiftlint_executable', 'swiftlint') +call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'swift_swiftlint', [ + \ 'Pods/SwiftLint/swiftlint', + \ 'ios/Pods/SwiftLint/swiftlint', + \ 'swiftlint', + \]) +endfunction + +function! ale_linters#swift#swiftlint#GetCommand(buffer) abort + let l:executable = ale_linters#swift#swiftlint#GetExecutable(a:buffer) + let l:args = 'lint --use-stdin' + + return ale#Escape(l:executable) + \ . ' ' .l:args +endfunction + +function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'text': l:match[5], + \} + + if l:match[4] is# 'error' + let l:item.type = 'E' + elseif l:match[4] is# 'note' + let l:item.type = 'I' + endif + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + " Parse the code if it's there. + let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^ (]+)\)$') + + if !empty(l:code_match) + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('swift', { +\ 'name': 'swiftlint', +\ 'executable': function('ale_linters#swift#swiftlint#GetExecutable'), +\ 'command': function('ale_linters#swift#swiftlint#GetCommand'), +\ 'callback': 'ale_linters#swift#swiftlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim new file mode 100644 index 00000000..64eef8cf --- /dev/null +++ b/sources_non_forked/ale/ale_linters/systemd/systemd_analyze.vim @@ -0,0 +1,18 @@ +function! ale_linters#systemd#systemd_analyze#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, '\v(.+):([0-9]+): (.+)', {match -> { + \ 'lnum': str2nr(match[2]), + \ 'col': 1, + \ 'type': 'W', + \ 'text': match[3], + \}}) +endfunction + +call ale#linter#Define('systemd', { +\ 'name': 'systemd_analyze', +\ 'aliases': ['systemd-analyze'], +\ 'executable': 'systemd-analyze', +\ 'command': 'SYSTEMD_LOG_COLOR=0 %e --user verify %s', +\ 'callback': 'ale_linters#systemd#systemd_analyze#Handle', +\ 'output_stream': 'both', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim new file mode 100644 index 00000000..5a4940e1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tcl/nagelfar.vim @@ -0,0 +1,39 @@ +" Author: Nick James +" Description: nagelfar linter for tcl files + +call ale#Set('tcl_nagelfar_executable', 'nagelfar.tcl') +call ale#Set('tcl_nagelfar_options', '') + +function! ale_linters#tcl#nagelfar#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'tcl_nagelfar_options') + + return '%e' . ale#Pad(l:options) . ' %s' +endfunction + +function! ale_linters#tcl#nagelfar#Handle(buffer, lines) abort + " Matches patterns like the following: + " Line 5: W Found constant "bepa" which is also a variable. + " Line 13: E Wrong number of arguments (3) to "set" + " Line 93: N Close brace not aligned with line 90 (4 0) + let l:pattern = '^Line\s\+\([0-9]\+\): \([NEW]\) \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'type': l:match[2] is# 'N' ? 'W' : l:match[2], + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('tcl', { +\ 'name': 'nagelfar', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'tcl_nagelfar_executable')}, +\ 'command': function('ale_linters#tcl#nagelfar#GetCommand'), +\ 'callback': 'ale_linters#tcl#nagelfar#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/checkov.vim b/sources_non_forked/ale/ale_linters/terraform/checkov.vim new file mode 100644 index 00000000..568b46e1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/checkov.vim @@ -0,0 +1,41 @@ +" Author: Thyme-87 +" Description: use checkov for providing warnings via ale + +call ale#Set('terraform_checkov_executable', 'checkov') +call ale#Set('terraform_checkov_options', '') + +function! ale_linters#terraform#checkov#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'terraform_checkov_executable') +endfunction + +function! ale_linters#terraform#checkov#GetCommand(buffer) abort + return '%e ' . '-f %t -o json --quiet ' . ale#Var(a:buffer, 'terraform_checkov_options') +endfunction + +function! ale_linters#terraform#checkov#Handle(buffer, lines) abort + let l:output = [] + + let l:results = get(get(ale#util#FuzzyJSONDecode(a:lines, {}), 'results', []), 'failed_checks', []) + + for l:violation in l:results + call add(l:output, { + \ 'filename': l:violation['file_path'], + \ 'lnum': l:violation['file_line_range'][0], + \ 'end_lnum': l:violation['file_line_range'][1], + \ 'text': l:violation['check_name'] . ' [' . l:violation['check_id'] . ']', + \ 'detail': l:violation['check_id'] . ': ' . l:violation['check_name'] . "\n" . + \ 'For more information, see: '. l:violation['guideline'], + \ 'type': 'W', + \ }) + endfor + + return l:output +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'checkov', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#terraform#checkov#GetExecutable'), +\ 'command': function('ale_linters#terraform#checkov#GetCommand'), +\ 'callback': 'ale_linters#terraform#checkov#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform.vim b/sources_non_forked/ale/ale_linters/terraform/terraform.vim new file mode 100644 index 00000000..1beb8501 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform.vim @@ -0,0 +1,69 @@ +" Author: Keith Maxwell +" Description: terraform fmt to check for errors + +call ale#Set('terraform_terraform_executable', 'terraform') + +function! ale_linters#terraform#terraform#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'terraform_terraform_executable') +endfunction + +function! ale_linters#terraform#terraform#GetCommand(buffer) abort + return ale#Escape(ale_linters#terraform#terraform#GetExecutable(a:buffer)) + \ . ' validate -no-color -json ' +endfunction + +function! ale_linters#terraform#terraform#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale_linters#terraform#terraform#GetDetail(error) abort + let l:detail = get(a:error, 'detail', '') + + if strlen(l:detail) > 0 + return l:detail + else + return get(a:error, 'summary', '') + endif +endfunction + +function! ale_linters#terraform#terraform#Handle(buffer, lines) abort + let l:output = [] + + let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'diagnostics': []}) + let l:dir = expand('#' . a:buffer . ':p:h') + let l:file = expand('#' . a:buffer . ':p') + + for l:error in l:errors['diagnostics'] + if has_key(l:error, 'range') + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']), + \ 'lnum': l:error['range']['start']['line'], + \ 'col': l:error['range']['start']['column'], + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), + \}) + else + call add(l:output, { + \ 'filename': l:file, + \ 'lnum': 0, + \ 'col': 0, + \ 'text': ale_linters#terraform#terraform#GetDetail(l:error), + \ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']), + \}) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#terraform#terraform#GetExecutable'), +\ 'command': function('ale_linters#terraform#terraform#GetCommand'), +\ 'callback': 'ale_linters#terraform#terraform#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim new file mode 100644 index 00000000..ab35126e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_ls.vim @@ -0,0 +1,38 @@ +" Author: Horacio Sanson +" Description: terraform-ls integration for ALE (cf. https://github.com/hashicorp/terraform-ls) + +call ale#Set('terraform_terraform_executable', 'terraform') +call ale#Set('terraform_ls_executable', 'terraform-ls') +call ale#Set('terraform_ls_options', '') + +function! ale_linters#terraform#terraform_ls#GetTerraformExecutable(buffer) abort + let l:terraform_executable = ale#Var(a:buffer, 'terraform_terraform_executable') + + if(ale#path#IsAbsolute(l:terraform_executable)) + return '-tf-exec ' . l:terraform_executable + endif + + return '' +endfunction + +function! ale_linters#terraform#terraform_ls#GetCommand(buffer) abort + return '%e' + \ . ale#Pad('serve') + \ . ale#Pad(ale_linters#terraform#terraform_ls#GetTerraformExecutable(a:buffer)) + \ . ale#Pad(ale#Var(a:buffer, 'terraform_ls_options')) +endfunction + +function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_ls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_ls_executable')}, +\ 'command': function('ale_linters#terraform#terraform_ls#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_ls#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim new file mode 100644 index 00000000..e2408c15 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/terraform_lsp.vim @@ -0,0 +1,25 @@ +" Author: OJFord +" Description: terraform-lsp integration for ALE (cf. https://github.com/juliosueiras/terraform-lsp) + +call ale#Set('terraform_langserver_executable', 'terraform-lsp') +call ale#Set('terraform_langserver_options', '') + +function! ale_linters#terraform#terraform_lsp#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'terraform_langserver_options')) +endfunction + +function! ale_linters#terraform#terraform_lsp#GetProjectRoot(buffer) abort + let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform') + + return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'terraform_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'terraform_langserver_executable')}, +\ 'command': function('ale_linters#terraform#terraform_lsp#GetCommand'), +\ 'project_root': function('ale_linters#terraform#terraform_lsp#GetProjectRoot'), +\ 'language': 'terraform', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tflint.vim b/sources_non_forked/ale/ale_linters/terraform/tflint.vim new file mode 100644 index 00000000..86b5b74a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/tflint.vim @@ -0,0 +1,105 @@ +" Author: Nat Williams +" Description: tflint for Terraform files +" +" See: https://www.terraform.io/ +" https://github.com/wata727/tflint + +call ale#Set('terraform_tflint_options', '') +call ale#Set('terraform_tflint_executable', 'tflint') + +function! ale_linters#terraform#tflint#Handle(buffer, lines) abort + let l:output = [] + let l:pattern = '\v^(.*):(\d+),(\d+)-(\d+)?,?(\d+): (.{-1,}); (.+)$' + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + " This is a rough test for tflint's output format + " On versions prior to 0.11 it outputs all errors as a single level list + if type(l:json) is v:t_list + for l:error in l:json + if l:error.type is# 'ERROR' + let l:type = 'E' + elseif l:error.type is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:error.line, + \ 'text': l:error.message, + \ 'type': l:type, + \ 'code': l:error.detector, + \}) + endfor + else + for l:error in get(l:json, 'errors', []) + for l:match in ale#util#GetMatches(l:error.message, [l:pattern]) + if l:match[4] is# '' + let l:match[4] = l:match[2] + endif + + call add(l:output, { + \ 'filename': l:match[1], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'end_lnum': str2nr(l:match[4]), + \ 'end_col': str2nr(l:match[5]), + \ 'text': l:match[7], + \ 'code': l:match[6], + \ 'type': 'E', + \}) + endfor + endfor + + for l:error in get(l:json, 'issues', []) + if l:error.rule.severity is# 'ERROR' + let l:type = 'E' + elseif l:error.rule.severity is# 'NOTICE' + let l:type = 'I' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:error.range.filename, + \ 'lnum': l:error.range.start.line, + \ 'col': l:error.range.start.column, + \ 'end_lnum': l:error.range.end.line, + \ 'end_col': l:error.range.end.column, + \ 'text': l:error.message, + \ 'code': l:error.rule.name, + \ 'type': l:type, + \}) + endfor + endif + + return l:output +endfunction + +function! ale_linters#terraform#tflint#GetCommand(buffer) abort + let l:cmd = '%e' + + let l:config_file = ale#path#FindNearestFile(a:buffer, '.tflint.hcl') + + if !empty(l:config_file) + let l:cmd .= ' --config ' . ale#Escape(l:config_file) + endif + + let l:opts = ale#Var(a:buffer, 'terraform_tflint_options') + + if !empty(l:opts) + let l:cmd .= ' ' . l:opts + endif + + let l:cmd .= ' -f json' + + return l:cmd +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'tflint', +\ 'executable': {b -> ale#Var(b, 'terraform_tflint_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#terraform#tflint#GetCommand'), +\ 'callback': 'ale_linters#terraform#tflint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/terraform/tfsec.vim b/sources_non_forked/ale/ale_linters/terraform/tfsec.vim new file mode 100644 index 00000000..d29cdd13 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/terraform/tfsec.vim @@ -0,0 +1,87 @@ +" Description: tfsec for Terraform files +" +" See: https://www.terraform.io/ +" https://github.com/aquasecurity/tfsec + +call ale#Set('terraform_tfsec_options', '') +call ale#Set('terraform_tfsec_executable', 'tfsec') + +let s:separator = has('win32') ? '\' : '/' + +function! ale_linters#terraform#tfsec#Handle(buffer, lines) abort + let l:output = [] + let l:json = ale#util#FuzzyJSONDecode(a:lines, {}) + + " if there's no warning, 'result' is `null`. + if empty(get(l:json, 'results')) + return l:output + endif + + for l:result in get(l:json, 'results', []) + if l:result.severity is# 'LOW' + let l:type = 'I' + elseif l:result.severity is# 'CRITICAL' + let l:type = 'E' + else + let l:type = 'W' + endif + + call add(l:output, { + \ 'filename': l:result.location.filename, + \ 'lnum': l:result.location.start_line, + \ 'end_lnum': l:result.location.end_line, + \ 'text': l:result.description, + \ 'code': l:result.long_id, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +" Construct command arguments to tfsec with `terraform_tfsec_options`. +function! ale_linters#terraform#tfsec#GetCommand(buffer) abort + let l:cmd = '%e' + + let l:config = ale_linters#terraform#tfsec#FindConfig(a:buffer) + + if !empty(l:config) + let l:cmd .= ' --config-file ' . l:config + endif + + let l:opts = ale#Var(a:buffer, 'terraform_tfsec_options') + + if !empty(l:opts) + let l:cmd .= ' ' . l:opts + endif + + let l:cmd .= ' --format json' + + return l:cmd +endfunction + +" Find the nearest configuration file of tfsec. +function! ale_linters#terraform#tfsec#FindConfig(buffer) abort + let l:config_dir = ale#path#FindNearestDirectory(a:buffer, '.tfsec') + + if !empty(l:config_dir) + " https://aquasecurity.github.io/tfsec/v1.28.0/guides/configuration/config/ + for l:basename in ['config.yml', 'config.json'] + let l:config = ale#path#Simplify(join([l:config_dir, l:basename], s:separator)) + + if filereadable(l:config) + return ale#Escape(l:config) + endif + endfor + endif + + return '' +endfunction + +call ale#linter#Define('terraform', { +\ 'name': 'tfsec', +\ 'executable': {b -> ale#Var(b, 'terraform_tfsec_executable')}, +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#terraform#tfsec#GetCommand'), +\ 'callback': 'ale_linters#terraform#tfsec#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/testft/testlinter.vim b/sources_non_forked/ale/ale_linters/testft/testlinter.vim new file mode 100644 index 00000000..65e0b205 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/testft/testlinter.vim @@ -0,0 +1,10 @@ +" Author: neersighted +" Description: dummy linter to use in tests + +call ale#linter#Define('testft', { +\ 'name': 'testlinter', +\ 'output_stream': 'stdout', +\ 'executable': 'testlinter', +\ 'command': 'testlinter', +\ 'callback': 'testCB', +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/alex.vim b/sources_non_forked/ale/ale_linters/tex/alex.vim new file mode 100644 index 00000000..5d9aec66 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for TeX files + +call ale#handlers#alex#DefineLinter('tex', '--text') diff --git a/sources_non_forked/ale/ale_linters/tex/chktex.vim b/sources_non_forked/ale/ale_linters/tex/chktex.vim new file mode 100644 index 00000000..160baf0d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/chktex.vim @@ -0,0 +1,54 @@ +" Author: Andrew Balmos - +" Description: chktex for LaTeX files + +let g:ale_tex_chktex_executable = +\ get(g:, 'ale_tex_chktex_executable', 'chktex') + +let g:ale_tex_chktex_options = +\ get(g:, 'ale_tex_chktex_options', '-I') + +function! ale_linters#tex#chktex#GetCommand(buffer) abort + " Check for optional .chktexrc + let l:chktex_config = ale#path#FindNearestFile( + \ a:buffer, + \ '.chktexrc') + + let l:command = ale#Var(a:buffer, 'tex_chktex_executable') + " Avoid bug when used without -p (last warning has gibberish for a filename) + let l:command .= ' -v0 -p stdin -q' + + if !empty(l:chktex_config) + let l:command .= ' -l ' . ale#Escape(l:chktex_config) + endif + + let l:command .= ' ' . ale#Var(a:buffer, 'tex_chktex_options') + + return l:command +endfunction + +function! ale_linters#tex#chktex#Handle(buffer, lines) abort + " Mattes lines like: + " + " stdin:499:2:24:Delete this space to maintain correct pagereferences. + " stdin:507:81:3:You should enclose the previous parenthesis with `{}'. + let l:pattern = '^stdin:\(\d\+\):\(\d\+\):\(\d\+\):\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')', + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('tex', { +\ 'name': 'chktex', +\ 'executable': 'chktex', +\ 'command': function('ale_linters#tex#chktex#GetCommand'), +\ 'callback': 'ale_linters#tex#chktex#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/cspell.vim b/sources_non_forked/ale/ale_linters/tex/cspell.vim new file mode 100644 index 00000000..4cf2b08e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TeX files. + +call ale#handlers#cspell#DefineLinter('tex') diff --git a/sources_non_forked/ale/ale_linters/tex/lacheck.vim b/sources_non_forked/ale/ale_linters/tex/lacheck.vim new file mode 100644 index 00000000..35aad083 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/lacheck.vim @@ -0,0 +1,43 @@ +" Author: Andrew Balmos - +" Description: lacheck for LaTeX files + +call ale#Set('tex_lacheck_executable', 'lacheck') + +function! ale_linters#tex#lacheck#Handle(buffer, lines) abort + " Mattes lines like: + " + " "book.tex", line 37: possible unwanted space at "{" + " "book.tex", line 38: missing `\ ' after "etc." + let l:pattern = '^"\(.\+\)", line \(\d\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " lacheck follows `\input{}` commands. If the cwd is not the same as the + " file in the buffer then it will fail to find the inputted items. We do not + " want warnings from those items anyway + if !empty(matchstr(l:match[3], '^Could not open ".\+"$')) + continue + endif + + " lacheck follows `\input{}` commands. We are only interested in + " reporting errors for the current buffer only. + if empty(matchstr(fnamemodify(l:match[1], ':t'), fnamemodify(bufname(a:buffer), ':t'))) + continue + endif + + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('tex', { +\ 'name': 'lacheck', +\ 'executable': {b -> ale#Var(b, 'tex_lacheck_executable')}, +\ 'command': '%e %t', +\ 'callback': 'ale_linters#tex#lacheck#Handle' +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/proselint.vim b/sources_non_forked/ale/ale_linters/tex/proselint.vim new file mode 100644 index 00000000..35e764e2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/proselint.vim @@ -0,0 +1,9 @@ +" Author: poohzrn https://github.com/poohzrn +" Description: proselint for TeX files + +call ale#linter#Define('tex', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/redpen.vim b/sources_non_forked/ale/ale_linters/tex/redpen.vim new file mode 100644 index 00000000..952a6004 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('tex', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f latex -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/texlab.vim b/sources_non_forked/ale/ale_linters/tex/texlab.vim new file mode 100644 index 00000000..8e96b80b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/texlab.vim @@ -0,0 +1,26 @@ +" Author: Ricardo Liang +" Author: ourigen +" Description: Texlab language server (Rust rewrite) + +call ale#Set('tex_texlab_executable', 'texlab') +call ale#Set('tex_texlab_options', '') +call ale#Set('tex_texlab_config', {}) + +function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort + let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') + + return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' +endfunction + +function! ale_linters#tex#texlab#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'tex_texlab_options')) +endfunction + +call ale#linter#Define('tex', { +\ 'name': 'texlab', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'tex_texlab_executable')}, +\ 'command': function('ale_linters#tex#texlab#GetCommand'), +\ 'project_root': function('ale_linters#tex#texlab#GetProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'tex_texlab_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/textlint.vim b/sources_non_forked/ale/ale_linters/tex/textlint.vim new file mode 100644 index 00000000..5edac46d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/textlint.vim @@ -0,0 +1,9 @@ +" Author: TANIGUCHI Masaya +" Description: textlint for LaTeX files + +call ale#linter#Define('tex', { +\ 'name': 'textlint', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/vale.vim b/sources_non_forked/ale/ale_linters/tex/vale.vim new file mode 100644 index 00000000..f64e72ac --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/vale.vim @@ -0,0 +1,9 @@ +" Author: chew-z https://github.com/chew-z +" Description: vale for LaTeX files + +call ale#linter#Define('tex', { +\ 'name': 'vale', +\ 'executable': 'vale', +\ 'command': 'vale --output=JSON %t', +\ 'callback': 'ale#handlers#vale#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/tex/writegood.vim b/sources_non_forked/ale/ale_linters/tex/writegood.vim new file mode 100644 index 00000000..c1aeace9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/tex/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for TeX files + +call ale#handlers#writegood#DefineLinter('tex') diff --git a/sources_non_forked/ale/ale_linters/texinfo/alex.vim b/sources_non_forked/ale/ale_linters/texinfo/alex.vim new file mode 100644 index 00000000..4d245524 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/texinfo/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for texinfo files + +call ale#handlers#alex#DefineLinter('texinfo', '--text') diff --git a/sources_non_forked/ale/ale_linters/texinfo/cspell.vim b/sources_non_forked/ale/ale_linters/texinfo/cspell.vim new file mode 100644 index 00000000..d691b3a7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/texinfo/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TeXInfo files. + +call ale#handlers#cspell#DefineLinter('texinfo') diff --git a/sources_non_forked/ale/ale_linters/texinfo/proselint.vim b/sources_non_forked/ale/ale_linters/texinfo/proselint.vim new file mode 100644 index 00000000..003e3a0f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/texinfo/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for Texinfo files + +call ale#linter#Define('texinfo', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/texinfo/writegood.vim b/sources_non_forked/ale/ale_linters/texinfo/writegood.vim new file mode 100644 index 00000000..4427f056 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/texinfo/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for Texinfo files + +call ale#handlers#writegood#DefineLinter('texinfo') diff --git a/sources_non_forked/ale/ale_linters/text/alex.vim b/sources_non_forked/ale/ale_linters/text/alex.vim new file mode 100644 index 00000000..d87ed915 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for text files + +call ale#handlers#alex#DefineLinter('text', '--text') diff --git a/sources_non_forked/ale/ale_linters/text/cspell.vim b/sources_non_forked/ale/ale_linters/text/cspell.vim new file mode 100644 index 00000000..813ef3b8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for general text files. + +call ale#handlers#cspell#DefineLinter('text') diff --git a/sources_non_forked/ale/ale_linters/text/languagetool.vim b/sources_non_forked/ale/ale_linters/text/languagetool.vim new file mode 100644 index 00000000..58c99ba2 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/languagetool.vim @@ -0,0 +1,4 @@ +" Author: Vincent (wahrwolf [ät] wolfpit.net) +" Description: languagetool for text files + +call ale#handlers#languagetool#DefineLinter('text') diff --git a/sources_non_forked/ale/ale_linters/text/proselint.vim b/sources_non_forked/ale/ale_linters/text/proselint.vim new file mode 100644 index 00000000..281b4ffa --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/proselint.vim @@ -0,0 +1,9 @@ +" Author: poohzrn https://github.com/poohzrn +" Description: proselint for text files + +call ale#linter#Define('text', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/text/redpen.vim b/sources_non_forked/ale/ale_linters/text/redpen.vim new file mode 100644 index 00000000..ec4433b9 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/redpen.vim @@ -0,0 +1,9 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +call ale#linter#Define('text', { +\ 'name': 'redpen', +\ 'executable': 'redpen', +\ 'command': 'redpen -f plain -r json %t', +\ 'callback': 'ale#handlers#redpen#HandleRedpenOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/text/textlint.vim b/sources_non_forked/ale/ale_linters/text/textlint.vim new file mode 100644 index 00000000..67c4e378 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/textlint.vim @@ -0,0 +1,9 @@ +" Author: Yasuhiro Kiyota +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#linter#Define('text', { +\ 'name': 'textlint', +\ 'executable': function('ale#handlers#textlint#GetExecutable'), +\ 'command': function('ale#handlers#textlint#GetCommand'), +\ 'callback': 'ale#handlers#textlint#HandleTextlintOutput', +\}) diff --git a/sources_non_forked/ale/ale_linters/text/vale.vim b/sources_non_forked/ale/ale_linters/text/vale.vim new file mode 100644 index 00000000..cf37c2f8 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/vale.vim @@ -0,0 +1,9 @@ +" Author: chew-z https://github.com/chew-z +" Description: vale for text files + +call ale#linter#Define('text', { +\ 'name': 'vale', +\ 'executable': 'vale', +\ 'command': 'vale --output=JSON %t', +\ 'callback': 'ale#handlers#vale#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/text/writegood.vim b/sources_non_forked/ale/ale_linters/text/writegood.vim new file mode 100644 index 00000000..81b935d4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/text/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for text files + +call ale#handlers#writegood#DefineLinter('text') diff --git a/sources_non_forked/ale/ale_linters/thrift/thrift.vim b/sources_non_forked/ale/ale_linters/thrift/thrift.vim new file mode 100644 index 00000000..345c7abe --- /dev/null +++ b/sources_non_forked/ale/ale_linters/thrift/thrift.vim @@ -0,0 +1,87 @@ +" Author: Jon Parise + +call ale#Set('thrift_thrift_executable', 'thrift') +call ale#Set('thrift_thrift_generators', ['cpp']) +call ale#Set('thrift_thrift_includes', ['.']) +call ale#Set('thrift_thrift_options', '-strict') + +function! ale_linters#thrift#thrift#GetCommand(buffer) abort + let l:generators = ale#Var(a:buffer, 'thrift_thrift_generators') + let l:includes = ale#Var(a:buffer, 'thrift_thrift_includes') + + " The thrift compiler requires at least one generator. If none are set, + " fall back to our default value to avoid silently failing. We could also + " `throw` here, but that seems even less helpful. + if empty(l:generators) + let l:generators = ['cpp'] + endif + + let l:output_dir = ale#command#CreateDirectory(a:buffer) + + return '%e' + \ . ale#Pad(join(map(copy(l:generators), "'--gen ' . v:val"))) + \ . ale#Pad(join(map(copy(l:includes), "'-I ' . v:val"))) + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thrift_options')) + \ . ' -out ' . ale#Escape(l:output_dir) + \ . ' %t' +endfunction + +function! ale_linters#thrift#thrift#Handle(buffer, lines) abort + " Matches lines like the following: + " + " [SEVERITY:/path/filename.thrift:31] Message text + " [ERROR:/path/filename.thrift:31] (last token was ';') + let l:pattern = '\v^\[(\u+):(.*):(\d+)\] (.*)$' + + let l:index = 0 + let l:output = [] + + " Roll our own output-matching loop instead of using ale#util#GetMatches + " because we need to support error messages that span multiple lines. + while l:index < len(a:lines) + let l:line = a:lines[l:index] + + let l:match = matchlist(l:line, l:pattern) + + if empty(l:match) + let l:index += 1 + continue + endif + + let l:severity = l:match[1] + + if l:severity is# 'WARNING' + let l:type = 'W' + else + let l:type = 'E' + endif + + " If our text looks like "(last token was ';')", the *next* line + " should contain a more descriptive error message. + let l:text = l:match[4] + + if l:text =~# '\(last token was .*\)' + let l:index += 1 + let l:text = get(a:lines, l:index, 'Unknown error ' . l:text) + endif + + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'col': 0, + \ 'type': l:type, + \ 'text': l:text, + \}) + + let l:index += 1 + endwhile + + return l:output +endfunction + +call ale#linter#Define('thrift', { +\ 'name': 'thrift', +\ 'output_stream': 'both', +\ 'executable': {b -> ale#Var(b, 'thrift_thrift_executable')}, +\ 'command': function('ale_linters#thrift#thrift#GetCommand'), +\ 'callback': 'ale_linters#thrift#thrift#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim new file mode 100644 index 00000000..bf929d10 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/thrift/thriftcheck.vim @@ -0,0 +1,46 @@ +" Author: Jon Parise + +call ale#Set('thrift_thriftcheck_executable', 'thriftcheck') +call ale#Set('thrift_thriftcheck_options', '') + +function! ale_linters#thrift#thriftcheck#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'thrift_thriftcheck_options')) + \ . ' --stdin-filename %s' + \ . ' %t' +endfunction + +function! ale_linters#thrift#thriftcheck#Handle(buffer, lines) abort + " Matches lines like the following: + " + " file.thrift:1:1: error: "py" namespace must match "^idl\\." (namespace.pattern) + " file.thrift:3:5: warning: 64-bit integer constant -2147483649 may not work in all languages (int.64bit) + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+): ?([^:]+): (.+) \(([^\)]+)\)$' + + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[3] is# 'warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:type, + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('thrift', { +\ 'name': 'thriftcheck', +\ 'executable': {b -> ale#Var(b, 'thrift_thriftcheck_executable')}, +\ 'command': function('ale_linters#thrift#thriftcheck#GetCommand'), +\ 'callback': 'ale_linters#thrift#thriftcheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/cspell.vim b/sources_non_forked/ale/ale_linters/typescript/cspell.vim new file mode 100644 index 00000000..6061b75c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for TypeScript files. + +call ale#handlers#cspell#DefineLinter('typescript') diff --git a/sources_non_forked/ale/ale_linters/typescript/deno.vim b/sources_non_forked/ale/ale_linters/typescript/deno.vim new file mode 100644 index 00000000..f47fac7a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/deno.vim @@ -0,0 +1,12 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Deno lsp linter for TypeScript files. + +call ale#linter#Define('typescript', { +\ 'name': 'deno', +\ 'lsp': 'stdio', +\ 'executable': function('ale#handlers#deno#GetExecutable'), +\ 'command': '%e lsp', +\ 'project_root': function('ale#handlers#deno#GetProjectRoot'), +\ 'initialization_options': function('ale#handlers#deno#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/eslint.vim b/sources_non_forked/ale/ale_linters/typescript/eslint.vim new file mode 100644 index 00000000..eaeac307 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/eslint.vim @@ -0,0 +1,10 @@ +" Author: w0rp +" Description: eslint for JavaScript files + +call ale#linter#Define('typescript', { +\ 'name': 'eslint', +\ 'executable': function('ale#handlers#eslint#GetExecutable'), +\ 'cwd': function('ale#handlers#eslint#GetCwd'), +\ 'command': function('ale#handlers#eslint#GetCommand'), +\ 'callback': 'ale#handlers#eslint#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/standard.vim b/sources_non_forked/ale/ale_linters/typescript/standard.vim new file mode 100644 index 00000000..1d524a10 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/standard.vim @@ -0,0 +1,31 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: standardjs for typescript files + +call ale#Set('typescript_standard_executable', 'standard') +call ale#Set('typescript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_standard_options', '') + +function! ale_linters#typescript#standard#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'typescript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale_linters#typescript#standard#GetCommand(buffer) abort + let l:executable = ale_linters#typescript#standard#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'typescript_standard_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin %s' +endfunction + +" standard uses eslint and the output format is the same +call ale#linter#Define('typescript', { +\ 'name': 'standard', +\ 'executable': function('ale_linters#typescript#standard#GetExecutable'), +\ 'command': function('ale_linters#typescript#standard#GetCommand'), +\ 'callback': 'ale#handlers#eslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tslint.vim b/sources_non_forked/ale/ale_linters/typescript/tslint.vim new file mode 100644 index 00000000..886a3cd4 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/tslint.vim @@ -0,0 +1,75 @@ +" Author: Prashanth Chandra , Jonathan Clem +" Description: tslint for TypeScript files + +call ale#handlers#tslint#InitVariables() + +function! ale_linters#typescript#tslint#Handle(buffer, lines) abort + " Do not output any errors for empty files if the option is on. + if ale#Var(a:buffer, 'typescript_tslint_ignore_empty_files') + \&& getbufline(a:buffer, 1, '$') == [''] + return [] + endif + + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + for l:error in ale#util#FuzzyJSONDecode(a:lines, []) + if get(l:error, 'ruleName', '') is# 'no-implicit-dependencies' + continue + endif + + let l:item = { + \ 'type': (get(l:error, 'ruleSeverity', '') is# 'WARNING' ? 'W' : 'E'), + \ 'text': l:error.failure, + \ 'lnum': l:error.startPosition.line + 1, + \ 'col': l:error.startPosition.character + 1, + \ 'end_lnum': l:error.endPosition.line + 1, + \ 'end_col': l:error.endPosition.character + 1, + \} + + let l:filename = ale#path#GetAbsPath(l:dir, l:error.name) + + " Assume temporary files are this file. + if !ale#path#IsTempName(l:filename) + let l:item.filename = l:filename + endif + + if has_key(l:error, 'ruleName') + let l:item.code = l:error.ruleName + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +function! ale_linters#typescript#tslint#GetCommand(buffer) abort + let l:tslint_config_path = ale#path#ResolveLocalPath( + \ a:buffer, + \ 'tslint.json', + \ ale#Var(a:buffer, 'typescript_tslint_config_path') + \) + let l:tslint_config_option = !empty(l:tslint_config_path) + \ ? ' -c ' . ale#Escape(l:tslint_config_path) + \ : '' + + let l:tslint_rules_dir = ale#Var(a:buffer, 'typescript_tslint_rules_dir') + let l:tslint_rules_option = !empty(l:tslint_rules_dir) + \ ? ' -r ' . ale#Escape(l:tslint_rules_dir) + \ : '' + + return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer)) + \ . ' --format json' + \ . l:tslint_config_option + \ . l:tslint_rules_option + \ . ' %t' +endfunction + +call ale#linter#Define('typescript', { +\ 'name': 'tslint', +\ 'executable': function('ale#handlers#tslint#GetExecutable'), +\ 'cwd': '%s:h', +\ 'command': function('ale_linters#typescript#tslint#GetCommand'), +\ 'callback': 'ale_linters#typescript#tslint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/tsserver.vim b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim new file mode 100644 index 00000000..d97becca --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/tsserver.vim @@ -0,0 +1,18 @@ +" Author: w0rp +" Description: tsserver integration for ALE + +call ale#Set('typescript_tsserver_executable', 'tsserver') +call ale#Set('typescript_tsserver_config_path', '') +call ale#Set('typescript_tsserver_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('typescript', { +\ 'name': 'tsserver', +\ 'lsp': 'tsserver', +\ 'executable': {b -> ale#path#FindExecutable(b, 'typescript_tsserver', [ +\ '.yarn/sdks/typescript/bin/tsserver', +\ 'node_modules/.bin/tsserver', +\ ])}, +\ 'command': '%e', +\ 'project_root': function('ale#handlers#tsserver#GetProjectRoot'), +\ 'language': '', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/typecheck.vim b/sources_non_forked/ale/ale_linters/typescript/typecheck.vim new file mode 100644 index 00000000..2f18691b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/typecheck.vim @@ -0,0 +1,33 @@ +" Author: Prashanth Chandra https://github.com/prashcr, Aleh Kashnikau https://github.com/mkusher +" Description: type checker for TypeScript files + +function! ale_linters#typescript#typecheck#Handle(buffer, lines) abort + " Matches patterns like the following: + " + " hello.ts[7, 41]: Property 'a' does not exist on type 'A' + " hello.ts[16, 7]: Type 'A' is not assignable to type 'B' + " + let l:pattern = '.\+\.ts\[\(\d\+\), \(\d\+\)\]: \(.\+\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:line = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:text = l:match[3] + + call add(l:output, { + \ 'lnum': l:line, + \ 'col': l:column, + \ 'text': l:text, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('typescript', { +\ 'name': 'typecheck', +\ 'executable': 'typecheck', +\ 'command': 'typecheck %s', +\ 'callback': 'ale_linters#typescript#typecheck#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/typescript/xo.vim b/sources_non_forked/ale/ale_linters/typescript/xo.vim new file mode 100644 index 00000000..6f4ee50c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/typescript/xo.vim @@ -0,0 +1,6 @@ +call ale#linter#Define('typescript', { +\ 'name': 'xo', +\ 'executable': function('ale#handlers#xo#GetExecutable'), +\ 'command': function('ale#handlers#xo#GetLintCommand'), +\ 'callback': 'ale#handlers#xo#HandleJSON', +\}) diff --git a/sources_non_forked/ale/ale_linters/v/v.vim b/sources_non_forked/ale/ale_linters/v/v.vim new file mode 100644 index 00000000..afa98c56 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/v/v.vim @@ -0,0 +1,82 @@ +" Author: fiatjaf +" Description: v build for V files + +call ale#Set('v_v_executable', 'v') +call ale#Set('v_v_options', '') + +function! ale_linters#v#v#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'v_v_options') + + " Run v in local directory with relative path + let l:command = ale#Var(a:buffer, 'v_v_executable') + \ . ale#Pad(l:options) + \ . ' .' . ' -o /tmp/vim-ale-v' + + return l:command +endfunction + +function! ale_linters#v#v#Handler(buffer, lines) abort + let l:dir = expand('#' . a:buffer . ':p:h') + let l:output = [] + + " Matches patterns like the following: + " + " ./const.v:4:3: warning: const names cannot contain uppercase letters, use snake_case instead + " 2 | + " 3 | const ( + " 4 | BUTTON_TEXT = 'OK' + " | ~~~~~~~~~~~ + " 5 | ) + " ./main.v:4:8: warning: module 'os' is imported but never used + " 2 | + " 3 | import ui + " 4 | import os + " | ~~ + " 5 | + " 6 | const ( + " ./main.v:20:10: error: undefined ident: `win_widt` + " 18 | mut app := &App{} + " 19 | app.window = ui.window({ + " 20 | width: win_widt + " | ~~~~~~~~ + " 21 | height: win_height + " 22 | title: 'Counter' + let l:current = {} + + for l:line in a:lines + " matches basic error description + let l:match = matchlist(l:line, + \ '\([^:]\+\):\([^:]\+\):\([^:]\+\): \([^:]\+\): \(.*\)') + + if !empty(l:match) + let l:current = { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[5], + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \} + call add(l:output, l:current) + continue + endif + + " try to get information about the ending column + let l:tildematch = matchstr(l:line, '\~\+') + + if !empty(l:tildematch) + let l:current['end_col'] = l:current['col'] + len(l:tildematch) + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('v', { +\ 'name': 'v', +\ 'aliases': [], +\ 'executable': {b -> ale#Var(b, 'v_v_executable')}, +\ 'command': function('ale_linters#v#v#GetCommand'), +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#v#v#Handler', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vala/vala_lint.vim b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim new file mode 100644 index 00000000..7f8a566a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vala/vala_lint.vim @@ -0,0 +1,66 @@ +" Author: Atsuya Takagi +" Description: A linter for Vala using Vala-Lint. + +call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf') +call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint') + +function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'vala_vala_lint_executable') +endfunction + +function! ale_linters#vala#vala_lint#GetCommand(buffer) abort + let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer) + + let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename') + let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename) + + if !empty(l:config_path) + let l:command .= ' -c ' . l:config_path + endif + + return l:command . ' %s' +endfunction + +function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort + let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)' + let l:output = [] + + for l:line in a:lines + " remove color escape sequences since vala-lint doesn't support + " output without colors + let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g') + let l:match = matchlist(l:cleaned_line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E' + let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '') + + let l:lnum = l:match[1] + 0 + let l:column = l:match[2] + 0 + let l:type = l:refined_type + let l:text = l:cleaned_text + let l:code = l:match[5] + + call add(l:output, { + \ 'lnum': l:lnum, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type, + \ 'code': l:code, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vala', { +\ 'name': 'vala_lint', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'), +\ 'command': function('ale_linters#vala#vala_lint#GetCommand'), +\ 'callback': 'ale_linters#vala#vala_lint#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim new file mode 100644 index 00000000..b05d8565 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('verilog') diff --git a/sources_non_forked/ale/ale_linters/verilog/iverilog.vim b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim new file mode 100644 index 00000000..e081f33f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/iverilog.vim @@ -0,0 +1,43 @@ +" Author: Masahiro H https://github.com/mshr-h +" Description: iverilog for verilog files + +call ale#Set('verilog_iverilog_options', '') + +function! ale_linters#verilog#iverilog#GetCommand(buffer) abort + return 'iverilog -t null -Wall ' + \ . ale#Var(a:buffer, 'verilog_iverilog_options') + \ . ' %t' +endfunction + +function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort + " Look for lines like the following. + " + " tb_me_top.v:37: warning: Instantiating module me_top with dangling input port 1 (rst_n) floating. + " tb_me_top.v:17: syntax error + " memory_single_port.v:2: syntax error + " tb_me_top.v:17: error: Invalid module instantiation + let l:pattern = '^[^:]\+:\(\d\+\): \(warning\|error\|syntax error\)\(: \(.\+\)\)\?' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:line = l:match[1] + 0 + let l:type = l:match[2] =~# 'error' ? 'E' : 'W' + let l:text = l:match[2] is# 'syntax error' ? 'syntax error' : l:match[4] + + call add(l:output, { + \ 'lnum': l:line, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'iverilog', +\ 'output_stream': 'stderr', +\ 'executable': 'iverilog', +\ 'command': function('ale_linters#verilog#iverilog#GetCommand'), +\ 'callback': 'ale_linters#verilog#iverilog#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/verilator.vim b/sources_non_forked/ale/ale_linters/verilog/verilator.vim new file mode 100644 index 00000000..006e310d --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/verilator.vim @@ -0,0 +1,60 @@ +" Author: Masahiro H https://github.com/mshr-h +" Description: verilator for verilog files + +" Set this option to change Verilator lint options +if !exists('g:ale_verilog_verilator_options') + let g:ale_verilog_verilator_options = '' +endif + +function! ale_linters#verilog#verilator#GetCommand(buffer) abort + " the path to the current file is systematically added to the search path + return 'verilator --lint-only -Wall -Wno-DECLFILENAME ' + \ . '-I%s:h ' + \ . ale#Var(a:buffer, 'verilog_verilator_options') .' ' + \ . '%t' +endfunction + +function! ale_linters#verilog#verilator#Handle(buffer, lines) abort + " Look for lines like the following. + " + " %Error: addr_gen.v:3: syntax error, unexpected IDENTIFIER + " %Warning-WIDTH: addr_gen.v:26: Operator ASSIGNDLY expects 12 bits on the Assign RHS, but Assign RHS's CONST '20'h0' generates 20 bits. + " %Warning-UNUSED: test.v:3: Signal is not used: a + " %Warning-UNDRIVEN: test.v:3: Signal is not driven: clk + " %Warning-UNUSED: test.v:4: Signal is not used: dout + " %Warning-BLKSEQ: test.v:10: Blocking assignments (=) in sequential (flop or latch) block; suggest delayed assignments (<=). + " Since version 4.032 (04/2020) verilator linter messages also contain the column number, + " and look like: + " %Error: /tmp/test.sv:3:1: syntax error, unexpected endmodule, expecting ';' + " + " to stay compatible with old versions of the tool, the column number is + " optional in the researched pattern + let l:pattern = '^%\(Warning\|Error\)[^:]*:\s*\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': str2nr(l:match[3]), + \ 'text': l:match[5], + \ 'type': l:match[1] is# 'Error' ? 'E' : 'W', + \ 'filename': l:match[2], + \} + + if !empty(l:match[4]) + let l:item.col = str2nr(l:match[4]) + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'verilator', +\ 'output_stream': 'stderr', +\ 'executable': 'verilator', +\ 'command': function('ale_linters#verilog#verilator#GetCommand'), +\ 'callback': 'ale_linters#verilog#verilator#Handle', +\ 'read_buffer': 0, +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/vlog.vim b/sources_non_forked/ale/ale_linters/verilog/vlog.vim new file mode 100644 index 00000000..45e1977c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/vlog.vim @@ -0,0 +1,52 @@ +" Author: John Gentile +" Description: Adds support for Mentor Graphics Questa/ModelSim `vlog` Verilog compiler/checker + +call ale#Set('verilog_vlog_executable', 'vlog') +" See `$ vlog -h` for more options +call ale#Set('verilog_vlog_options', '-quiet -lint') + +function! ale_linters#verilog#vlog#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'verilog_vlog_options')) . ' %t' +endfunction + +function! ale_linters#verilog#vlog#Handle(buffer, lines) abort + "Matches patterns like the following: + "** Warning: add.v(7): (vlog-2623) Undefined variable: C. + "** Error: file.v(1): (vlog-13294) Identifier must be declared with a port mode: C. + let l:pattern = '^**\s\(\w*\): \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[3] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[4], + \ 'filename': l:match[2], + \}) + endfor + + "Matches patterns like the following: + "** Warning: (vlog-2623) add.v(7): Undefined variable: C. + "** Error: (vlog-13294) file.v(1): Identifier must be declared with a port mode: C. + " let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:pattern = '^**\s\(\w*\):\s\([^)]*)\) \([a-zA-Z0-9\-\.\_\/ ]\+\)(\(\d\+\)):\s\+\(.*\)' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[4] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[2] . ' ' . l:match[5], + \ 'filename': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'vlog', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'verilog_vlog_executable')}, +\ 'command': function('ale_linters#verilog#vlog#GetCommand'), +\ 'callback': 'ale_linters#verilog#vlog#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/xvlog.vim b/sources_non_forked/ale/ale_linters/verilog/xvlog.vim new file mode 100644 index 00000000..98b5aae7 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/xvlog.vim @@ -0,0 +1,35 @@ +" Author: John Gentile +" Description: Adds support for Xilinx Vivado `xvlog` Verilog compiler/checker + +call ale#Set('verilog_xvlog_executable', 'xvlog') +call ale#Set('verilog_xvlog_options', '') + +function! ale_linters#verilog#xvlog#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'verilog_xvlog_options')) . ' %t' +endfunction + +function! ale_linters#verilog#xvlog#Handle(buffer, lines) abort + "Matches patterns like the following: + " ERROR: [VRFC 10-1412] syntax error near output [/path/to/file.v:5] + let l:pattern = '^ERROR:\s\+\(\[.*\)\[.*:\([0-9]\+\)\]' + let l:output = [] + + " NOTE: `xvlog` only prints 'INFO' and 'ERROR' messages + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'E', + \ 'text': l:match[1], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'xvlog', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'verilog_xvlog_executable')}, +\ 'command': function('ale_linters#verilog#xvlog#GetCommand'), +\ 'callback': 'ale_linters#verilog#xvlog#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/verilog/yosys.vim b/sources_non_forked/ale/ale_linters/verilog/yosys.vim new file mode 100644 index 00000000..29657755 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/verilog/yosys.vim @@ -0,0 +1,42 @@ +" Author: Nathan Sharp +" Description: Yosys for Verilog files + +call ale#Set('verilog_yosys_executable', 'yosys') +call ale#Set('verilog_yosys_options', '-Q -T -p ''read_verilog %s''') + +function! ale_linters#verilog#yosys#GetCommand(buffer) abort + return '%e ' . ale#Var(a:buffer, 'verilog_yosys_options') . ' 2>&1' +endfunction + +function! ale_linters#verilog#yosys#Handle(buffer, lines) abort + let l:output = [] + let l:path = fnamemodify(bufname(a:buffer), ':p') + + for l:match in ale#util#GetMatches(a:lines, '^\([^:]\+\):\(\d\+\): \(WARNING\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:match[4], + \ 'type': l:match[3][0], + \ 'filename': l:match[1], + \}) + endfor + + for l:match in ale#util#GetMatches(a:lines, '^\(Warning\|ERROR\): \(.\+\)$') + call add(l:output, { + \ 'lnum': 1, + \ 'text': l:match[2], + \ 'type': l:match[1][0], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('verilog', { +\ 'name': 'yosys', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'verilog_yosys_executable')}, +\ 'command': function('ale_linters#verilog#yosys#GetCommand'), +\ 'callback': 'ale_linters#verilog#yosys#Handle', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/vhdl/ghdl.vim b/sources_non_forked/ale/ale_linters/vhdl/ghdl.vim new file mode 100644 index 00000000..b09e620b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/ghdl.vim @@ -0,0 +1,37 @@ +" Author: John Gentile +" Description: Adds support for `ghdl` VHDL compiler/checker + +call ale#Set('vhdl_ghdl_executable', 'ghdl') +" Compile w/VHDL-2008 support +call ale#Set('vhdl_ghdl_options', '--std=08') + +function! ale_linters#vhdl#ghdl#GetCommand(buffer) abort + return '%e -s ' . ale#Pad(ale#Var(a:buffer, 'vhdl_ghdl_options')) . ' %t' +endfunction + +function! ale_linters#vhdl#ghdl#Handle(buffer, lines) abort + " Look for 'error' lines like the following: + " dff_en.vhd:41:5:error: 'begin' is expected instead of 'if' + " /path/to/file.vhdl:12:8: no declaration for "i0" + let l:pattern = '^[a-zA-Z0-9\-\.\_\/ ]\+:\(\d\+\):\(\d\+\):\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col' : l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vhdl', { +\ 'name': 'ghdl', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'vhdl_ghdl_executable')}, +\ 'command': function('ale_linters#vhdl#ghdl#GetCommand'), +\ 'callback': 'ale_linters#vhdl#ghdl#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim new file mode 100644 index 00000000..c9d306b3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/hdl_checker.vim @@ -0,0 +1,5 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#handlers#hdl_checker#DefineLinter('vhdl') diff --git a/sources_non_forked/ale/ale_linters/vhdl/vcom.vim b/sources_non_forked/ale/ale_linters/vhdl/vcom.vim new file mode 100644 index 00000000..1914fd33 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/vcom.vim @@ -0,0 +1,38 @@ +" Author: John Gentile +" Description: Adds support for Mentor Graphics Questa/ModelSim `vcom` VHDL compiler/checker + +call ale#Set('vhdl_vcom_executable', 'vcom') +" Use VHDL-2008. See `$ vcom -h` for more options +call ale#Set('vhdl_vcom_options', '-2008 -quiet -lint') + +function! ale_linters#vhdl#vcom#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'vhdl_vcom_options')) . ' %t' +endfunction + +function! ale_linters#vhdl#vcom#Handle(buffer, lines) abort + "Matches patterns like the following: + "** Warning: ../path/to/file.vhd(218): (vcom-1236) Shared variables must be of a protected type. + "** Error: tb_file.vhd(73): (vcom-1136) Unknown identifier "aresetn". + "** Error: tb_file.vhd(73): Bad resolution function (STD_LOGIC) for type (error). + "** Error: tb_file.vhd(73): near ":": (vcom-1576) expecting ';' or ')'. + let l:pattern = '^**\s\(\w*\):[a-zA-Z0-9\-\.\_\/ ]\+(\(\d\+\)):\s\+\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': l:match[1] is? 'Error' ? 'E' : 'W', + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vhdl', { +\ 'name': 'vcom', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'vhdl_vcom_executable')}, +\ 'command': function('ale_linters#vhdl#vcom#GetCommand'), +\ 'callback': 'ale_linters#vhdl#vcom#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/vhdl/xvhdl.vim b/sources_non_forked/ale/ale_linters/vhdl/xvhdl.vim new file mode 100644 index 00000000..8010ff14 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vhdl/xvhdl.vim @@ -0,0 +1,37 @@ +" Author: John Gentile +" Description: Adds support for Xilinx Vivado `xvhdl` VHDL compiler/checker + +call ale#Set('vhdl_xvhdl_executable', 'xvhdl') +" Use VHDL-2008. See `$ xvhdl -h` for more options +call ale#Set('vhdl_xvhdl_options', '--2008') + +function! ale_linters#vhdl#xvhdl#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'vhdl_xvhdl_options')) . ' %t' +endfunction + +function! ale_linters#vhdl#xvhdl#Handle(buffer, lines) abort + "Matches patterns like the following: + " ERROR: [VRFC 10-91] aresetn is not declared [/path/to/file.vhd:17] + " ERROR: [VRFC 10-91] m_axis_tx_tdata is not declared [/home/user/tx_data.vhd:128] + let l:pattern = '^ERROR:\s\+\(\[.*\)\[.*:\([0-9]\+\)\]' + let l:output = [] + + " NOTE: `xvhdl` only prints 'INFO' and 'ERROR' messages + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[2] + 0, + \ 'type': 'E', + \ 'text': l:match[1], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vhdl', { +\ 'name': 'xvhdl', +\ 'output_stream': 'stdout', +\ 'executable': {b -> ale#Var(b, 'vhdl_xvhdl_executable')}, +\ 'command': function('ale_linters#vhdl#xvhdl#GetCommand'), +\ 'callback': 'ale_linters#vhdl#xvhdl#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim new file mode 100644 index 00000000..5ca2f149 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/ale_custom_linting_rules.vim @@ -0,0 +1,70 @@ +" Author: w0rp +" Description: A linter for checking ALE project code itself. + +function! ale_linters#vim#ale_custom_linting_rules#GetExecutable(buffer) abort + let l:filename = expand('#' . a:buffer . ':p') + let l:dir_list = [] + + for l:dir in split(&runtimepath, ',') + if l:filename[:len(l:dir) - 1] is# l:dir + call add(l:dir_list, l:dir) + endif + endfor + + return !empty(l:dir_list) + \ ? findfile('test/script/custom-linting-rules', join(l:dir_list, ',')) + \ : '' +endfunction + +function! s:GetALEProjectDir(buffer) abort + let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer) + + return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort + let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer) + + return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable))) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort + let l:temp_dir = ale#command#CreateDirectory(a:buffer) + let l:temp_file = l:temp_dir . '/example.vim' + + let l:lines = getbufline(a:buffer, 1, '$') + call ale#util#Writefile(a:buffer, l:lines, l:temp_file) + + return '%e ' . ale#Escape(l:temp_dir) +endfunction + +function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort + let l:dir = s:GetALEProjectDir(a:buffer) + let l:output = [] + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+) (.+)$' + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " Ignore trailing whitespace errors if we've turned them off. + if !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + \&& l:match[3] is# 'Trailing whitespace' + continue + endif + + call add(l:output, { + \ 'lnum': l:match[2], + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'ale_custom_linting_rules', +\ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'), +\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'), +\ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'), +\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle', +\ 'read_buffer': 0, +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/vimls.vim b/sources_non_forked/ale/ale_linters/vim/vimls.vim new file mode 100644 index 00000000..7003eb04 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/vimls.vim @@ -0,0 +1,61 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: Vim Language Server integration for ALE + +call ale#Set('vim_vimls_executable', 'vim-language-server') +call ale#Set('vim_vimls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vim_vimls_config', {}) + +function! ale_linters#vim#vimls#GetProjectRoot(buffer) abort + let l:trigger_file_candidates = [ + \ '.vimrc', + \ 'init.vim', + \] + + for l:candidate in l:trigger_file_candidates + let l:trigger_file = fnamemodify(bufname(a:buffer), ':t') + + if l:trigger_file is# l:candidate + return fnamemodify( + \ bufname(a:buffer), + \ ':h', + \) + endif + endfor + + let l:trigger_dir_candidates = [ + \ 'autoload', + \ 'plugin', + \ '.git', + \] + + let l:path_upwards = ale#path#Upwards(fnamemodify(bufname(a:buffer), ':p:h')) + + for l:path in l:path_upwards + for l:candidate in l:trigger_dir_candidates + let l:trigger_dir = ale#path#Simplify( + \ l:path . '/' . l:candidate, + \) + + if isdirectory(l:trigger_dir) + return fnamemodify( + \ l:trigger_dir, + \ ':p:h:h', + \) + endif + endfor + endfor + + return '' +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vimls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'vim_vimls_config')}, +\ 'executable': {b -> ale#path#FindExecutable(b, 'vim_vimls', [ +\ 'node_modules/.bin/vim-language-server', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vim', +\ 'project_root': function('ale_linters#vim#vimls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/vim/vint.vim b/sources_non_forked/ale/ale_linters/vim/vint.vim new file mode 100644 index 00000000..f7054ffb --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vim/vint.vim @@ -0,0 +1,65 @@ +" Author: w0rp , KabbAmine +" Description: This file adds support for checking Vim code with Vint. + +" This flag can be used to change enable/disable style issues. +call ale#Set('vim_vint_show_style_issues', 1) +call ale#Set('vim_vint_executable', 'vint') +let s:enable_neovim = has('nvim') ? ' --enable-neovim' : '' +let s:format = '-f "{file_path}:{line_number}:{column_number}: {severity}: {policy_name} - {description} (see {reference})"' + +function! ale_linters#vim#vint#GetCommand(buffer, version) abort + let l:can_use_no_color_flag = empty(a:version) + \ || ale#semver#GTE(a:version, [0, 3, 7]) + + let l:warning_flag = ale#Var(a:buffer, 'vim_vint_show_style_issues') ? '-s' : '-w' + + " Use the --stdin-display-name argument if supported, temp file otherwise. + let l:stdin_or_temp = ale#semver#GTE(a:version, [0, 4, 0]) + \ ? ' --stdin-display-name %s -' + \ : ' %t' + + return '%e' + \ . ' ' . l:warning_flag + \ . (l:can_use_no_color_flag ? ' --no-color' : '') + \ . s:enable_neovim + \ . ' ' . s:format + \ . l:stdin_or_temp +endfunction + +let s:word_regex_list = [ +\ '\v^Undefined variable: ([^ ]+)', +\ '\v^Make the scope explicit like ...([^ ]+). ', +\ '\v^.*start with a capital or contain a colon: ([^ ]+)', +\ '\v.*instead of .(\=[=~]).', +\] + +function! ale_linters#vim#vint#Handle(buffer, lines) abort + let l:loclist = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines) + + for l:item in l:loclist + let l:match = [] + + for l:regex in s:word_regex_list + let l:match = matchlist(l:item.text, l:regex) + + if !empty(l:match) + let l:item.end_col = l:item.col + len(l:match[1]) - 1 + break + endif + endfor + endfor + + return l:loclist +endfunction + +call ale#linter#Define('vim', { +\ 'name': 'vint', +\ 'executable': {buffer -> ale#Var(buffer, 'vim_vint_executable')}, +\ 'command': {buffer -> ale#semver#RunWithVersionCheck( +\ buffer, +\ ale#Var(buffer, 'vim_vint_executable'), +\ '%e --version', +\ function('ale_linters#vim#vint#GetCommand'), +\ )}, +\ 'callback': 'ale_linters#vim#vint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/vue/cspell.vim b/sources_non_forked/ale/ale_linters/vue/cspell.vim new file mode 100644 index 00000000..2d8bfdc3 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vue/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for Vue files. + +call ale#handlers#cspell#DefineLinter('vue') diff --git a/sources_non_forked/ale/ale_linters/vue/vls.vim b/sources_non_forked/ale/ale_linters/vue/vls.vim new file mode 100644 index 00000000..4bd75286 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vue/vls.vim @@ -0,0 +1,22 @@ +" Author: Alexander Olofsson +" Description: Vue vls Language Server integration for ALE + +call ale#Set('vue_vls_executable', 'vls') +call ale#Set('vue_vls_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#vue#vls#GetProjectRoot(buffer) abort + let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json') + + return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : '' +endfunction + +call ale#linter#Define('vue', { +\ 'name': 'vls', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_vls', [ +\ 'node_modules/.bin/vls', +\ ])}, +\ 'command': '%e --stdio', +\ 'language': 'vue', +\ 'project_root': function('ale_linters#vue#vls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/ale_linters/vue/volar.vim b/sources_non_forked/ale/ale_linters/vue/volar.vim new file mode 100644 index 00000000..bb41b883 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/vue/volar.vim @@ -0,0 +1,80 @@ +" Author: Arnold Chand +" Description: Volar Language Server integration for ALE adopted from +" nvim-lspconfig and volar/packages/shared/src/types.ts + +call ale#Set('vue_volar_executable', 'vue-language-server') +call ale#Set('vue_volar_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('vue_volar_init_options', { +\ 'documentFeatures': { +\ 'documentColor': v:false, +\ 'documentFormatting': { +\ 'defaultPrintWidth': 100, +\ }, +\ 'documentSymbol': v:true, +\ 'foldingRange': v:true, +\ 'linkedEditingRange': v:true, +\ 'selectionRange': v:true, +\ }, +\ 'languageFeatures': { +\ 'callHierarchy': v:true, +\ 'codeAction': v:true, +\ 'codeLens': v:true, +\ 'completion': { +\ 'defaultAttrNameCase': 'kebabCase', +\ 'defaultTagNameCase': 'both', +\ 'getDocumentNameCaseRequest': v:false, +\ 'getDocumentSelectionRequest': v:false, +\ }, +\ 'definition': v:true, +\ 'diagnostics': v:true, +\ 'documentHighlight': v:true, +\ 'documentLink': v:true, +\ 'hover': v:true, +\ 'references': v:true, +\ 'rename': v:true, +\ 'renameFileRefactoring': v:true, +\ 'schemaRequestService': v:true, +\ 'semanticTokens': v:false, +\ 'signatureHelp': v:true, +\ 'typeDefinition': v:true, +\ 'workspaceSymbol': v:false, +\ }, +\ 'typescript': { +\ 'serverPath': '', +\ 'localizedPath': v:null, +\ }, +\}) + +function! ale_linters#vue#volar#GetProjectRoot(buffer) abort + let l:project_roots = ['package.json', 'vite.config.js', '.git', bufname(a:buffer)] + + for l:project_root in l:project_roots + let l:nearest_filepath = ale#path#FindNearestFile(a:buffer, l:project_root) + + if !empty(l:nearest_filepath) + return fnamemodify(l:nearest_filepath, ':h') + endif + endfor + + return '' +endfunction + +function! ale_linters#vue#volar#GetInitializationOptions(buffer) abort + let l:tsserver_path = ale#path#FindNearestExecutable(a:buffer, [ + \ 'node_modules/typescript/lib/tsserverlibrary.js' + \ ]) + let l:init_options = ale#Var(a:buffer, 'vue_volar_init_options') + let l:init_options.typescript.serverPath = l:tsserver_path + + return l:init_options +endfunction + +call ale#linter#Define('vue', { +\ 'name': 'volar', +\ 'language': 'vue', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#path#FindExecutable(b, 'vue_volar', ['node_modules/.bin/vue-language-server'])}, +\ 'command': '%e --stdio', +\ 'project_root': function('ale_linters#vue#volar#GetProjectRoot'), +\ 'initialization_options': function('ale_linters#vue#volar#GetInitializationOptions'), +\}) diff --git a/sources_non_forked/ale/ale_linters/wgsl/naga.vim b/sources_non_forked/ale/ale_linters/wgsl/naga.vim new file mode 100644 index 00000000..2816751b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/wgsl/naga.vim @@ -0,0 +1,12 @@ +" Author: rhysd +" Description: naga-cli linter for WGSL syntax. + +call ale#Set('wgsl_naga_executable', 'naga') + +call ale#linter#Define('wgsl', { +\ 'name': 'naga', +\ 'executable': {b -> ale#Var(b, 'wgsl_naga_executable')}, +\ 'output_stream': 'stderr', +\ 'command': {b -> '%e --stdin-file-path %s'}, +\ 'callback': 'ale#handlers#naga#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/xhtml/alex.vim b/sources_non_forked/ale/ale_linters/xhtml/alex.vim new file mode 100644 index 00000000..97f3b59a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xhtml/alex.vim @@ -0,0 +1,4 @@ +" Author: Johannes Wienke +" Description: alex for XHTML files + +call ale#handlers#alex#DefineLinter('xhtml', '--text') diff --git a/sources_non_forked/ale/ale_linters/xhtml/cspell.vim b/sources_non_forked/ale/ale_linters/xhtml/cspell.vim new file mode 100644 index 00000000..c465b41b --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xhtml/cspell.vim @@ -0,0 +1,5 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: cspell support for XHTML files. + +call ale#handlers#cspell#DefineLinter('xhtml') diff --git a/sources_non_forked/ale/ale_linters/xhtml/proselint.vim b/sources_non_forked/ale/ale_linters/xhtml/proselint.vim new file mode 100644 index 00000000..dfad921f --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xhtml/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for XHTML files + +call ale#linter#Define('xhtml', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/sources_non_forked/ale/ale_linters/xhtml/writegood.vim b/sources_non_forked/ale/ale_linters/xhtml/writegood.vim new file mode 100644 index 00000000..1fcba182 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xhtml/writegood.vim @@ -0,0 +1,4 @@ +" Author: Sumner Evans +" Description: write-good for XHTML files + +call ale#handlers#writegood#DefineLinter('xhtml') diff --git a/sources_non_forked/ale/ale_linters/xml/xmllint.vim b/sources_non_forked/ale/ale_linters/xml/xmllint.vim new file mode 100644 index 00000000..553d0883 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/xml/xmllint.vim @@ -0,0 +1,65 @@ +" Author: q12321q +" Description: This file adds support for checking XML code with xmllint. + +" CLI options +let g:ale_xml_xmllint_executable = get(g:, 'ale_xml_xmllint_executable', 'xmllint') +let g:ale_xml_xmllint_options = get(g:, 'ale_xml_xmllint_options', '') + +function! ale_linters#xml#xmllint#GetCommand(buffer) abort + return '%e' + \ . ale#Pad(ale#Var(a:buffer, 'xml_xmllint_options')) + \ . ' --noout -' +endfunction + +function! ale_linters#xml#xmllint#Handle(buffer, lines) abort + " Matches patterns lines like the following: + " file/path:123: error level : error message + let l:pattern_message = '\v^([^:]+):(\d+):\s*(([^:]+)\s*:\s+.*)$' + + " parse column token line like that: + " file/path:123: parser error : Opening and ending tag mismatch: foo line 1 and bar + " + " ^ + let l:pattern_column_token = '\v^\s*\^$' + + let l:output = [] + + for l:line in a:lines + " Parse error/warning lines + let l:match_message = matchlist(l:line, l:pattern_message) + + if !empty(l:match_message) + let l:line = l:match_message[2] + 0 + let l:type = l:match_message[4] =~? 'warning' ? 'W' : 'E' + let l:text = l:match_message[3] + + call add(l:output, { + \ 'lnum': l:line, + \ 'text': l:text, + \ 'type': l:type, + \}) + + continue + endif + + " Parse column position + let l:match_column_token = matchlist(l:line, l:pattern_column_token) + + if !empty(l:output) && !empty(l:match_column_token) + let l:previous = l:output[len(l:output) - 1] + let l:previous['col'] = len(l:match_column_token[0]) + + continue + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('xml', { +\ 'name': 'xmllint', +\ 'output_stream': 'stderr', +\ 'executable': {b -> ale#Var(b, 'xml_xmllint_executable')}, +\ 'command': function('ale_linters#xml#xmllint#GetCommand'), +\ 'callback': 'ale_linters#xml#xmllint#Handle', +\ }) diff --git a/sources_non_forked/ale/ale_linters/yaml/actionlint.vim b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim new file mode 100644 index 00000000..1e2fda49 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/actionlint.vim @@ -0,0 +1,11 @@ +" Author: bretello + +call ale#Set('yaml_actionlint_executable', 'actionlint') +call ale#Set('yaml_actionlint_options', '') + +call ale#linter#Define('yaml', { +\ 'name': 'actionlint', +\ 'executable': {b -> ale#Var(b, 'yaml_actionlint_executable')}, +\ 'command': function('ale#handlers#actionlint#GetCommand'), +\ 'callback': 'ale#handlers#actionlint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/circleci.vim b/sources_non_forked/ale/ale_linters/yaml/circleci.vim new file mode 100644 index 00000000..20835454 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/circleci.vim @@ -0,0 +1,35 @@ +function! ale_linters#yaml#circleci#Handle(buffer, lines) abort + let l:match_index = -1 + let l:output = [] + + for l:index in range(len(a:lines)) + let l:line = a:lines[l:index] + + if l:line =~? 'Error: ERROR IN CONFIG FILE:' + let l:match_index = l:index + 1 + break + endif + endfor + + if l:match_index > 0 + return [{ + \ 'type': 'E', + \ 'lnum': 1, + \ 'text': a:lines[l:match_index], + \ 'detail': join(a:lines[l:match_index :], "\n"), + \}] + endif + + return [] +endfunction + +" The circleci validate requires network requests, so we'll only run it when +" files are saved to prevent the server from being hammered. +call ale#linter#Define('yaml', { +\ 'name': 'circleci', +\ 'executable': {b -> expand('#' . b . ':p') =~? '\.circleci' ? 'circleci' : ''}, +\ 'command': 'circleci --skip-update-check config validate - < %s', +\ 'callback': 'ale_linters#yaml#circleci#Handle', +\ 'output_stream': 'stderr', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim new file mode 100644 index 00000000..ec48115a --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/gitlablint.vim @@ -0,0 +1,49 @@ +call ale#Set('yaml_gitlablint_executable', 'gll') +call ale#Set('yaml_gitlablint_options', '') + +function! ale_linters#yaml#gitlablint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_gitlablint_options')) + \ . ' -p %t' +endfunction + +function! ale_linters#yaml#gitlablint#Handle(buffer, lines) abort + " Matches patterns line the following: + " (): mapping values are not allowed in this context at line 68 column 8 + " jobs:build:dev config contains unknown keys: ony + let l:pattern = '^\(.*\) at line \(\d\+\) column \(\d\+\)$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[1], + \ 'type': 'E', + \} + call add(l:output, l:item) + else + if l:line isnot# 'GitLab CI configuration is invalid' + let l:item = { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': l:line, + \ 'type': 'E', + \} + call add(l:output, l:item) + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'gitlablint', +\ 'executable': {b -> ale#Var(b, 'yaml_gitlablint_executable')}, +\ 'command': function('ale_linters#yaml#gitlablint#GetCommand'), +\ 'callback': 'ale_linters#yaml#gitlablint#Handle', +\ 'output_stream': 'stderr', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/ls.vim b/sources_non_forked/ale/ale_linters/yaml/ls.vim new file mode 100644 index 00000000..8e3f6d00 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/ls.vim @@ -0,0 +1,34 @@ +" Author: Jeffrey Lau - https://github.com/zoonfafer +" Description: YAML Language Server https://github.com/redhat-developer/yaml-language-server + +call ale#Set('yaml_ls_executable', 'yaml-language-server') +call ale#Set('yaml_ls_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('yaml_ls_config', {}) + +function! ale_linters#yaml#ls#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'yaml_ls', [ + \ 'node_modules/.bin/yaml-language-server', + \]) +endfunction + +function! ale_linters#yaml#ls#GetCommand(buffer) abort + let l:executable = ale_linters#yaml#ls#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' --stdio' +endfunction + +" Just use the current file +function! ale_linters#yaml#ls#FindProjectRoot(buffer) abort + let l:project_file = expand('#' . a:buffer . ':p') + + return fnamemodify(l:project_file, ':h') +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'yaml-language-server', +\ 'lsp': 'stdio', +\ 'executable': function('ale_linters#yaml#ls#GetExecutable'), +\ 'command': function('ale_linters#yaml#ls#GetCommand'), +\ 'project_root': function('ale_linters#yaml#ls#FindProjectRoot'), +\ 'lsp_config': {b -> ale#Var(b, 'yaml_ls_config')}, +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/spectral.vim b/sources_non_forked/ale/ale_linters/yaml/spectral.vim new file mode 100644 index 00000000..13654f06 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/spectral.vim @@ -0,0 +1,14 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +call ale#Set('yaml_spectral_executable', 'spectral') +call ale#Set('yaml_spectral_use_global', get(g:, 'ale_use_global_executables', 0)) + +call ale#linter#Define('yaml', { +\ 'name': 'spectral', +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_spectral', [ +\ 'node_modules/.bin/spectral', +\ ])}, +\ 'command': '%e lint --ignore-unknown-format -q -f text %t', +\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput' +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/swaglint.vim b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim new file mode 100644 index 00000000..7fc2b430 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/swaglint.vim @@ -0,0 +1,40 @@ +" Author: Matthew Turland +" Description: This file adds support for linting Swagger / OpenAPI documents using swaglint + +call ale#Set('yaml_swaglint_executable', 'swaglint') +call ale#Set('yaml_swaglint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#yaml#swaglint#Handle(buffer, lines) abort + let l:pattern = ': \([^\s]\+\) @ \(\d\+\):\(\d\+\) - \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'type': l:match[1] is# 'error' ? 'E' : 'W', + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \} + + " Parse the code if it's there. + let l:code_match = matchlist(l:obj.text, '\v^(.+) \(([^ (]+)\)$') + + if !empty(l:code_match) + let l:obj.text = l:code_match[1] + let l:obj.code = l:code_match[2] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'swaglint', +\ 'executable': {b -> ale#path#FindExecutable(b, 'yaml_swaglint', [ +\ 'node_modules/.bin/swaglint', +\ ])}, +\ 'command': '%e -r compact --stdin', +\ 'callback': 'ale_linters#yaml#swaglint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/yaml/yamllint.vim b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim new file mode 100644 index 00000000..39011df1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yaml/yamllint.vim @@ -0,0 +1,11 @@ +" Author: KabbAmine + +call ale#Set('yaml_yamllint_executable', 'yamllint') +call ale#Set('yaml_yamllint_options', '') + +call ale#linter#Define('yaml', { +\ 'name': 'yamllint', +\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')}, +\ 'command': function('ale#handlers#yamllint#GetCommand'), +\ 'callback': 'ale#handlers#yamllint#Handle', +\}) diff --git a/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim b/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim new file mode 100644 index 00000000..81fcaa0e --- /dev/null +++ b/sources_non_forked/ale/ale_linters/yang/yang_lsp.vim @@ -0,0 +1,15 @@ +call ale#Set('yang_lsp_executable', 'yang-language-server') + +function! ale_linters#yang#yang_lsp#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile(a:buffer, 'yang.settings') + + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' +endfunction + +call ale#linter#Define('yang', { +\ 'name': 'yang_lsp', +\ 'lsp': 'stdio', +\ 'executable': {b -> ale#Var(b, 'yang_lsp_executable')}, +\ 'project_root': function('ale_linters#yang#yang_lsp#GetProjectRoot'), +\ 'command': '%e', +\}) diff --git a/sources_non_forked/ale/ale_linters/zeek/zeek.vim b/sources_non_forked/ale/ale_linters/zeek/zeek.vim new file mode 100644 index 00000000..e976d75c --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zeek/zeek.vim @@ -0,0 +1,22 @@ +" Author: Benjamin Bannier +" Description: Support for checking Zeek files. +" +call ale#Set('zeek_zeek_executable', 'zeek') + +function! ale_linters#zeek#zeek#HandleErrors(buffer, lines) abort + let l:pattern = 'error in \v.*, line (\d+): (.*)$' + + return map(ale#util#GetMatches(a:lines, l:pattern), "{ + \ 'lnum': str2nr(v:val[1]), + \ 'text': v:val[2], + \}") +endfunction + +call ale#linter#Define('zeek', { +\ 'name': 'zeek', +\ 'executable': {b -> ale#Var(b, 'zeek_zeek_executable')}, +\ 'output_stream': 'stderr', +\ 'command': {-> '%e --parse-only %s'}, +\ 'callback': 'ale_linters#zeek#zeek#HandleErrors', +\ 'lint_file': 1, +\}) diff --git a/sources_non_forked/ale/ale_linters/zig/zls.vim b/sources_non_forked/ale/ale_linters/zig/zls.vim new file mode 100644 index 00000000..1390f6b1 --- /dev/null +++ b/sources_non_forked/ale/ale_linters/zig/zls.vim @@ -0,0 +1,20 @@ +" Author: CherryMan +" Description: A language server for Zig + +call ale#Set('zig_zls_executable', 'zls') +call ale#Set('zig_zls_config', {}) + +function! ale_linters#zig#zls#GetProjectRoot(buffer) abort + let l:build_rs = ale#path#FindNearestFile(a:buffer, 'build.zig') + + return !empty(l:build_rs) ? fnamemodify(l:build_rs, ':h') : '' +endfunction + +call ale#linter#Define('zig', { +\ 'name': 'zls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'zig_zls_config')}, +\ 'executable': {b -> ale#Var(b, 'zig_zls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#zig#zls#GetProjectRoot'), +\}) diff --git a/sources_non_forked/ale/autoload/ale.vim b/sources_non_forked/ale/autoload/ale.vim new file mode 100644 index 00000000..029472ad --- /dev/null +++ b/sources_non_forked/ale/autoload/ale.vim @@ -0,0 +1,284 @@ +" Author: w0rp , David Alexander +" Description: Primary code path for the plugin +" Manages execution of linters when requested by autocommands + +" Strings used for severity in the echoed message +let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error') +let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info') +let g:ale_echo_msg_log_str = get(g:, 'ale_echo_msg_log_str', 'Log') +let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning') +" Ignoring linters, for disabling some, or ignoring LSP diagnostics. +let g:ale_linters_ignore = get(g:, 'ale_linters_ignore', {}) +let g:ale_disable_lsp = get(g:, 'ale_disable_lsp', 0) + +" LSP window/showMessage format +let g:ale_lsp_show_message_format = get(g:, 'ale_lsp_show_message_format', '%severity%:%linter%: %s') +" Valid values mimic LSP definitions (error, warning and information; log is +" never shown) +let g:ale_lsp_show_message_severity = get(g:, 'ale_lsp_show_message_severity', 'error') + +let s:lint_timer = -1 +let s:getcmdwintype_exists = exists('*getcmdwintype') + +" Return 1 if a file is too large for ALE to handle. +function! ale#FileTooLarge(buffer) abort + let l:max = getbufvar(a:buffer, 'ale_maximum_file_size', get(g:, 'ale_maximum_file_size', 0)) + + return l:max > 0 ? (line2byte(line('$') + 1) > l:max) : 0 +endfunction + +" A function for checking various conditions whereby ALE just shouldn't +" attempt to do anything, say if particular buffer types are open in Vim. +function! ale#ShouldDoNothing(buffer) abort + " The checks are split into separate if statements to make it possible to + " profile each check individually with Vim's profiling tools. + " + " Do nothing if ALE is disabled. + if !getbufvar(a:buffer, 'ale_enabled', get(g:, 'ale_enabled', 0)) + return 1 + endif + + " Don't perform any checks when newer NeoVim versions are exiting. + if get(v:, 'exiting', v:null) isnot v:null + return 1 + endif + + let l:filetype = getbufvar(a:buffer, '&filetype') + + " Do nothing when there's no filetype. + if l:filetype is# '' + return 1 + endif + + " Do nothing for diff buffers. + if getbufvar(a:buffer, '&diff') + return 1 + endif + + " Do nothing for blacklisted files. + if index(get(g:, 'ale_filetype_blacklist', []), l:filetype) >= 0 + return 1 + endif + + " Do nothing if running from command mode. + if s:getcmdwintype_exists && !empty(getcmdwintype()) + return 1 + endif + + let l:filename = fnamemodify(bufname(a:buffer), ':t') + + " Do nothing for directories. + if l:filename is# '.' + return 1 + endif + + " Don't start linting and so on when an operator is pending. + if ale#util#Mode(1) is# 'no' + return 1 + endif + + " Do nothing if running in the sandbox. + if ale#util#InSandbox() + return 1 + endif + + " Do nothing if the file is too large. + if ale#FileTooLarge(a:buffer) + return 1 + endif + + " Do nothing from CtrlP buffers with CtrlP-funky. + if exists(':CtrlPFunky') is 2 + \&& getbufvar(a:buffer, '&l:statusline') =~# 'CtrlPMode.*funky' + return 1 + endif + + return 0 +endfunction + +function! s:Lint(buffer, should_lint_file, timer_id) abort + " Use the filetype from the buffer + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:linters = ale#linter#Get(l:filetype) + let l:linters = ale#linter#RemoveIgnored(a:buffer, l:filetype, l:linters) + + " Tell other sources that they can start checking the buffer now. + let g:ale_want_results_buffer = a:buffer + silent doautocmd User ALEWantResults + unlet! g:ale_want_results_buffer + + " Don't set up buffer data and so on if there are no linters to run. + if !has_key(g:ale_buffer_info, a:buffer) && empty(l:linters) + return + endif + + " Clear lint_file linters, or only run them if the file exists. + let l:lint_file = empty(l:linters) + \ || (a:should_lint_file && filereadable(expand('#' . a:buffer . ':p'))) + + call ale#engine#RunLinters(a:buffer, l:linters, l:lint_file) +endfunction + +" (delay, [linting_flag, buffer_number]) +function! ale#Queue(delay, ...) abort + if a:0 > 2 + throw 'too many arguments!' + endif + + let l:buffer = get(a:000, 1, v:null) + + if l:buffer is v:null + let l:buffer = bufnr('') + endif + + if type(l:buffer) isnot v:t_number + throw 'buffer_number must be a Number' + endif + + if ale#ShouldDoNothing(l:buffer) + return + endif + + " Default linting_flag to '' + let l:should_lint_file = get(a:000, 0) is# 'lint_file' + + if s:lint_timer != -1 + call timer_stop(s:lint_timer) + let s:lint_timer = -1 + endif + + if a:delay > 0 + let s:lint_timer = timer_start( + \ a:delay, + \ function('s:Lint', [l:buffer, l:should_lint_file]) + \) + else + call s:Lint(l:buffer, l:should_lint_file, 0) + endif +endfunction + +let s:current_ale_version = [3, 2, 0] + +" A function used to check for ALE features in files outside of the project. +function! ale#Has(feature) abort + let l:match = matchlist(a:feature, '\c\v^ale-(\d+)\.(\d+)(\.(\d+))?$') + + if !empty(l:match) + let l:version = [l:match[1] + 0, l:match[2] + 0, l:match[4] + 0] + + return ale#semver#GTE(s:current_ale_version, l:version) + endif + + return 0 +endfunction + +" Given a buffer number and a variable name, look for that variable in the +" buffer scope, then in global scope. If the name does not exist in the global +" scope, an exception will be thrown. +" +" Every variable name will be prefixed with 'ale_'. +function! ale#Var(buffer, variable_name) abort + let l:full_name = 'ale_' . a:variable_name + let l:vars = getbufvar(str2nr(a:buffer), '', {}) + + return get(l:vars, l:full_name, g:[l:full_name]) +endfunction + +" Initialize a variable with a default value, if it isn't already set. +" +" Every variable name will be prefixed with 'ale_'. +function! ale#Set(variable_name, default) abort + let l:full_name = 'ale_' . a:variable_name + + if !has_key(g:, l:full_name) + let g:[l:full_name] = a:default + endif +endfunction + +" Given a string for adding to a command, return the string padded with a +" space on the left if it is not empty. Otherwise return an empty string. +" +" This can be used for making command strings cleaner and easier to test. +function! ale#Pad(string) abort + return !empty(a:string) ? ' ' . a:string : '' +endfunction + +" Given a environment variable name and a value, produce part of a command for +" setting an environment variable before running a command. The syntax will be +" valid for cmd on Windows, or most shells on Unix. +function! ale#Env(variable_name, value) abort + if has('win32') + return 'set ' . a:variable_name . '=' . ale#Escape(a:value) . ' && ' + endif + + return a:variable_name . '=' . ale#Escape(a:value) . ' ' +endfunction + +" Escape a string suitably for each platform. +" shellescape does not work on Windows. +function! ale#Escape(str) abort + if fnamemodify(&shell, ':t') is? 'cmd.exe' + " If the string contains spaces, it will be surrounded by quotes. + " Otherwise, special characters will be escaped with carets (^). + return substitute( + \ a:str =~# ' ' + \ ? '"' . substitute(a:str, '"', '""', 'g') . '"' + \ : substitute(a:str, '\v([&|<>^])', '^\1', 'g'), + \ '%', + \ '%%', + \ 'g', + \) + endif + + return shellescape (a:str) +endfunction + +" Get the loclist item message according to a given format string. +" +" See `:help g:ale_loclist_msg_format` and `:help g:ale_echo_msg_format` +function! ale#GetLocItemMessage(item, format_string) abort + let l:msg = a:format_string + let l:severity = g:ale_echo_msg_warning_str + let l:code = get(a:item, 'code', '') + let l:type = get(a:item, 'type', 'E') + let l:linter_name = get(a:item, 'linter_name', '') + let l:code_repl = !empty(l:code) ? '\=submatch(1) . l:code . submatch(2)' : '' + + if l:type is# 'E' + let l:severity = g:ale_echo_msg_error_str + elseif l:type is# 'I' + let l:severity = g:ale_echo_msg_info_str + endif + + " Replace special markers with certain information. + " \=l:variable is used to avoid escaping issues. + let l:msg = substitute(l:msg, '\v\%([^\%]*)code([^\%]*)\%', l:code_repl, 'g') + let l:msg = substitute(l:msg, '\V%severity%', '\=l:severity', 'g') + let l:msg = substitute(l:msg, '\V%linter%', '\=l:linter_name', 'g') + " Replace %s with the text. + let l:msg = substitute(l:msg, '\V%s', '\=a:item.text', 'g') + " Windows may insert carriage return line endings (^M), strip these characters. + let l:msg = substitute(l:msg, '\r', '', 'g') + + return l:msg +endfunction + +" Given a buffer and a linter or fixer name, return an Array of two-item +" Arrays describing how to map filenames to and from the local to foreign file +" systems. +function! ale#GetFilenameMappings(buffer, name) abort + let l:linter_mappings = ale#Var(a:buffer, 'filename_mappings') + + if type(l:linter_mappings) is v:t_list + return l:linter_mappings + endif + + let l:name = a:name + + if !has_key(l:linter_mappings, l:name) + " Use * as a default setting for all tools. + let l:name = '*' + endif + + return get(l:linter_mappings, l:name, []) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ant.vim b/sources_non_forked/ale/autoload/ale/ant.vim new file mode 100644 index 00000000..b6d4217f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/ant.vim @@ -0,0 +1,45 @@ +" Author: Andrew Lee . +" Inspired by ale/gradle.vim by Michael Pardo +" Description: Functions for working with Ant projects. + +" Given a buffer number, find an Ant project root +function! ale#ant#FindProjectRoot(buffer) abort + let l:build_xml_path = ale#path#FindNearestFile(a:buffer, 'build.xml') + + if !empty(l:build_xml_path) + return fnamemodify(l:build_xml_path, ':h') + endif + + return '' +endfunction + +" Given a buffer number, find the path to the `ant` executable. Returns an empty +" string if cannot find the executable. +function! ale#ant#FindExecutable(buffer) abort + if executable('ant') + return 'ant' + endif + + return '' +endfunction + +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Ant is not detected. +function! ale#ant#BuildClasspathCommand(buffer) abort + let l:executable = ale#ant#FindExecutable(a:buffer) + + if !empty(l:executable) + let l:project_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) .' classpath -S -q' + \] + endif + endif + + return ['', ''] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/args.vim b/sources_non_forked/ale/autoload/ale/args.vim new file mode 100644 index 00000000..70afb2e5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/args.vim @@ -0,0 +1,43 @@ +" Author: w0rp +" Description: This module implements a function for parsing arguments for +" commands. + +" Given a list of valid arguments like ['foo', 'bar'] and a string to parse, +" parse the arguments from the string and return [parsed_args, remainder]. +" +" Arguments must be prefixed in the string with a single minus (-), and a +" double minus (--) denotes the end of arguments. +function! ale#args#Parse(arg_list, string) abort + let l:parsed = {} + let l:end_of_args = 0 + let l:word_list = split(a:string, ' ') + let l:index = 0 + + while l:index < len(l:word_list) + let l:word = l:word_list[l:index] + + if l:word[:0] is# '-' + let l:index += 1 + + if l:word is# '--' + break + endif + + let l:arg = l:word[1:] + + if index(a:arg_list, l:arg) >= 0 + let l:parsed[l:arg] = '' + else + throw 'Invalid argument: ' . l:word + endif + elseif l:word is# '' + let l:index += 1 + else + break + endif + endwhile + + let l:new_string = join(l:word_list[l:index :], ' ') + + return [l:parsed, l:new_string] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/assert.vim b/sources_non_forked/ale/autoload/ale/assert.vim new file mode 100644 index 00000000..141cd0f2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/assert.vim @@ -0,0 +1,424 @@ +let s:command_output = [] + +function! ale#assert#GivenCommandOutput(...) abort + let s:command_output = a:000 +endfunction + +function! s:GetLinter() abort + let l:linters = ale#linter#GetLintersLoaded() + let l:filetype_linters = get(values(l:linters), 0, []) + + if len(l:linters) is 0 || len(l:filetype_linters) is 0 + throw 'No linters were loaded' + endif + + if len(l:linters) > 1 || len(l:filetype_linters) > 1 + throw 'More than one linter was loaded' + endif + + return l:filetype_linters[0] +endfunction + +function! s:FormatExe(command, executable) abort + return substitute(a:command, '%e', '\=ale#Escape(a:executable)', 'g') +endfunction + +function! s:ProcessDeferredCommands(initial_result) abort + let l:result = a:initial_result + let l:command_index = 0 + let l:command = [] + + while ale#command#IsDeferred(l:result) + call add(l:command, s:FormatExe(l:result.command, l:result.executable)) + + if get(g:, 'ale_run_synchronously_emulate_commands') + " Don't run commands, but simulate the results. + let l:Callback = g:ale_run_synchronously_callbacks[0] + let l:output = get(s:command_output, l:command_index, []) + call l:Callback(0, l:output) + unlet g:ale_run_synchronously_callbacks + + let l:command_index += 1 + else + " Run the commands in the shell, synchronously. + call ale#test#FlushJobs() + endif + + let l:result = l:result.value + endwhile + + call add(l:command, l:result) + + return l:command +endfunction + +function! s:ProcessDeferredCwds(initial_command, initial_cwd) abort + let l:result = a:initial_command + let l:last_cwd = v:null + let l:command_index = 0 + let l:cwd_list = [] + + while ale#command#IsDeferred(l:result) + call add(l:cwd_list, l:result.cwd) + + if get(g:, 'ale_run_synchronously_emulate_commands') + " Don't run commands, but simulate the results. + let l:Callback = g:ale_run_synchronously_callbacks[0] + let l:output = get(s:command_output, l:command_index, []) + call l:Callback(0, l:output) + unlet g:ale_run_synchronously_callbacks + + let l:command_index += 1 + else + " Run the commands in the shell, synchronously. + call ale#test#FlushJobs() + endif + + let l:result = l:result.value + endwhile + + call add(l:cwd_list, a:initial_cwd is v:null ? l:last_cwd : a:initial_cwd) + + return l:cwd_list +endfunction + +" Load the currently loaded linter for a test case, and check that the command +" matches the given string. +function! ale#assert#Linter(expected_executable, expected_command) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) + + while ale#command#IsDeferred(l:executable) + call ale#test#FlushJobs() + let l:executable = l:executable.value + endwhile + + let l:command = s:ProcessDeferredCommands( + \ ale#linter#GetCommand(l:buffer, l:linter), + \) + + if type(a:expected_command) isnot v:t_list + let l:command = l:command[-1] + endif + + if type(l:command) is v:t_string + " Replace %e with the escaped executable, so tests keep passing after + " linters are changed to use %e. + let l:command = s:FormatExe(l:command, l:executable) + elseif type(l:command) is v:t_list + call map(l:command, 's:FormatExe(v:val, l:executable)') + endif + + AssertEqual + \ [a:expected_executable, a:expected_command], + \ [l:executable, l:command] +endfunction + +function! ale#assert#LinterCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + + let l:initial_cwd = ale#linter#GetCwd(l:buffer, l:linter) + call ale#command#SetCwd(l:buffer, l:initial_cwd) + + let l:cwd = s:ProcessDeferredCwds( + \ ale#linter#GetCommand(l:buffer, l:linter), + \ l:initial_cwd, + \) + + call ale#command#ResetCwd(l:buffer) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + +function! ale#assert#FixerCwd(expected_cwd) abort + let l:buffer = bufnr('') + let l:cwd = s:ProcessDeferredCwds(s:FixerFunction(l:buffer), v:null) + + if type(a:expected_cwd) isnot v:t_list + let l:cwd = l:cwd[-1] + endif + + AssertEqual a:expected_cwd, l:cwd +endfunction + +function! ale#assert#Fixer(expected_result) abort + let l:buffer = bufnr('') + let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer)) + + if type(a:expected_result) isnot v:t_list + let l:result = l:result[-1] + endif + + AssertEqual a:expected_result, l:result +endfunction + +function! ale#assert#FixerNotExecuted() abort + let l:buffer = bufnr('') + let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer))[-1] + + Assert empty(l:result), "The fixer will be executed when it shouldn't be" +endfunction + +function! ale#assert#LinterNotExecuted() abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:executable = ale#linter#GetExecutable(l:buffer, l:linter) + let l:executed = 1 + + if !empty(l:executable) + let l:command = ale#linter#GetCommand(l:buffer, l:linter) + + if type(l:command) is v:t_list + let l:command = l:command[-1] + endif + + let l:executed = !empty(l:command) + else + let l:executed = 0 + endif + + Assert !l:executed, "The linter will be executed when it shouldn't be" +endfunction + +function! ale#assert#LSPOptions(expected_options) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:initialization_options = ale#lsp_linter#GetOptions(l:buffer, l:linter) + + AssertEqual a:expected_options, l:initialization_options +endfunction + +function! ale#assert#LSPConfig(expected_config) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:config = ale#lsp_linter#GetConfig(l:buffer, l:linter) + + AssertEqual a:expected_config, l:config +endfunction + +function! ale#assert#LSPLanguage(expected_language) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:language = ale#linter#GetLanguage(l:buffer, l:linter) + + AssertEqual a:expected_language, l:language +endfunction + +function! ale#assert#LSPProject(expected_root) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:root = ale#lsp_linter#FindProjectRoot(l:buffer, l:linter) + + AssertEqual a:expected_root, l:root +endfunction + +function! ale#assert#LSPAddress(expected_address) abort + let l:buffer = bufnr('') + let l:linter = s:GetLinter() + let l:address = ale#linter#GetAddress(l:buffer, l:linter) + + AssertEqual a:expected_address, l:address +endfunction + +function! ale#assert#SetUpLinterTestCommands() abort + command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertLinterCwd :call ale#assert#LinterCwd() + command! -nargs=+ AssertLinter :call ale#assert#Linter() + command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted() + command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions() + command! -nargs=+ AssertLSPConfig :call ale#assert#LSPConfig() + command! -nargs=+ AssertLSPLanguage :call ale#assert#LSPLanguage() + command! -nargs=+ AssertLSPProject :call ale#assert#LSPProject() + command! -nargs=+ AssertLSPAddress :call ale#assert#LSPAddress() +endfunction + +function! ale#assert#SetUpFixerTestCommands() abort + command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput() + command! -nargs=+ AssertFixerCwd :call ale#assert#FixerCwd() + command! -nargs=+ AssertFixer :call ale#assert#Fixer() + command! -nargs=0 AssertFixerNotExecuted :call ale#assert#FixerNotExecuted() +endfunction + +function! ale#assert#ResetVariables(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:option_suffix = get(a:000, 0, a:name) + let l:prefix = 'ale_' . a:filetype . '_' + \ . substitute(l:option_suffix, '-', '_', 'g') + let l:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix' + + " Save and clear linter variables. + " We'll load the runtime file to reset them to defaults. + for l:key in filter(keys(g:), l:filter_expr) + execute 'Save g:' . l:key + unlet g:[l:key] + endfor + + for l:key in filter(keys(b:), l:filter_expr) + unlet b:[l:key] + endfor +endfunction + +" A dummy function for making sure this module is loaded. +function! ale#assert#SetUpLinterTest(filetype, name) abort + " Set up a marker so ALE doesn't create real random temporary filenames. + let g:ale_create_dummy_temporary_file = 1 + + " Remove current linters. + call ale#linter#Reset() + call ale#linter#PreventLoading(a:filetype) + + Save g:ale_root + let g:ale_root = {} + + Save b:ale_root + unlet! b:ale_root + + call ale#assert#ResetVariables(a:filetype, a:name) + + Save g:ale_c_build_dir + unlet! g:ale_c_build_dir + unlet! b:ale_c_build_dir + + execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim' + + if !exists('g:dir') + call ale#test#SetDirectory('/testplugin/test/linter') + endif + + call ale#assert#SetUpLinterTestCommands() + + let g:ale_run_synchronously = 1 + let g:ale_run_synchronously_emulate_commands = 1 +endfunction + +function! ale#assert#TearDownLinterTest() abort + unlet! g:ale_create_dummy_temporary_file + unlet! g:ale_run_synchronously + unlet! g:ale_run_synchronously_callbacks + unlet! g:ale_run_synchronously_emulate_commands + unlet! g:ale_run_synchronously_command_results + let s:command_output = [] + + if exists(':GivenCommandOutput') + delcommand GivenCommandOutput + endif + + if exists(':AssertLinterCwd') + delcommand AssertLinterCwd + endif + + if exists(':AssertLinter') + delcommand AssertLinter + endif + + if exists(':AssertLinterNotExecuted') + delcommand AssertLinterNotExecuted + endif + + if exists(':AssertLSPOptions') + delcommand AssertLSPOptions + endif + + if exists(':AssertLSPConfig') + delcommand AssertLSPConfig + endif + + if exists(':AssertLSPLanguage') + delcommand AssertLSPLanguage + endif + + if exists(':AssertLSPProject') + delcommand AssertLSPProject + endif + + if exists(':AssertLSPAddress') + delcommand AssertLSPAddress + endif + + if exists('g:dir') + call ale#test#RestoreDirectory() + endif + + Restore + + call ale#linter#Reset() + + if exists('*ale#semver#ResetVersionCache') + call ale#semver#ResetVersionCache() + endif +endfunction + +function! ale#assert#SetUpFixerTest(filetype, name, ...) abort + " If the suffix of the option names format is different, an additional + " argument can be used for that instead. + if a:0 > 1 + throw 'Too many arguments' + endif + + " Set up a marker so ALE doesn't create real random temporary filenames. + let g:ale_create_dummy_temporary_file = 1 + + let l:function_name = ale#fix#registry#GetFunc(a:name) + let s:FixerFunction = function(l:function_name) + + let l:option_suffix = get(a:000, 0, a:name) + call ale#assert#ResetVariables(a:filetype, a:name, l:option_suffix) + + execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim' + + if !exists('g:dir') + call ale#test#SetDirectory('/testplugin/test/fixers') + endif + + call ale#assert#SetUpFixerTestCommands() + + let g:ale_run_synchronously = 1 + let g:ale_run_synchronously_emulate_commands = 1 +endfunction + +function! ale#assert#TearDownFixerTest() abort + unlet! g:ale_create_dummy_temporary_file + unlet! g:ale_run_synchronously + unlet! g:ale_run_synchronously_callbacks + unlet! g:ale_run_synchronously_emulate_commands + unlet! g:ale_run_synchronously_command_results + let s:command_output = [] + unlet! s:FixerFunction + + if exists('g:dir') + call ale#test#RestoreDirectory() + endif + + Restore + + if exists('*ale#semver#ResetVersionCache') + call ale#semver#ResetVersionCache() + endif + + if exists(':GivenCommandOutput') + delcommand GivenCommandOutput + endif + + if exists(':AssertFixerCwd') + delcommand AssertFixerCwd + endif + + if exists(':AssertFixer') + delcommand AssertFixer + endif + + if exists(':AssertFixerNotExecuted') + delcommand AssertFixerNotExecuted + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/balloon.vim b/sources_non_forked/ale/autoload/ale/balloon.vim new file mode 100644 index 00000000..8678376f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/balloon.vim @@ -0,0 +1,74 @@ +" Author: w0rp +" Description: balloonexpr support for ALE. + +function! ale#balloon#MessageForPos(bufnr, lnum, col) abort + let l:set_balloons = ale#Var(a:bufnr, 'set_balloons') + let l:show_problems = 0 + let l:show_hover = 0 + + if l:set_balloons is 1 + let l:show_problems = 1 + let l:show_hover = 1 + elseif l:set_balloons is# 'hover' + let l:show_hover = 1 + endif + + " Don't show balloons if they are disabled, or linting is disabled. + if !(l:show_problems || l:show_hover) + \|| !g:ale_enabled + \|| !getbufvar(a:bufnr, 'ale_enabled', 1) + return '' + endif + + if l:show_problems + let l:loclist = get(g:ale_buffer_info, a:bufnr, {'loclist': []}).loclist + let l:index = ale#util#BinarySearch(l:loclist, a:bufnr, a:lnum, a:col) + endif + + " Show the diagnostics message if found, 'Hover' output otherwise + if l:show_problems && l:index >= 0 + return l:loclist[l:index].text + elseif l:show_hover && ( + \ exists('*balloon_show') + \ || getbufvar( + \ a:bufnr, + \ 'ale_set_balloons_legacy_echo', + \ get(g:, 'ale_set_balloons_legacy_echo', 0) + \ ) + \) + " Request LSP/tsserver hover information, but only if this version of + " Vim supports the balloon_show function, or if we turned a legacy + " setting on. + call ale#hover#Show(a:bufnr, a:lnum, a:col, {'called_from_balloonexpr': 1}) + endif + + return '' +endfunction + +function! ale#balloon#Expr() abort + return ale#balloon#MessageForPos(v:beval_bufnr, v:beval_lnum, v:beval_col) +endfunction + +function! ale#balloon#Disable() abort + if has('balloon_eval') + set noballooneval + set balloonexpr= + endif + + if has('balloon_eval_term') + set noballoonevalterm + set balloonexpr= + endif +endfunction + +function! ale#balloon#Enable() abort + if has('balloon_eval') + set ballooneval + set balloonexpr=ale#balloon#Expr() + endif + + if has('balloon_eval_term') + set balloonevalterm + set balloonexpr=ale#balloon#Expr() + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/c.vim b/sources_non_forked/ale/autoload/ale/c.vim new file mode 100644 index 00000000..4a22c6fe --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/c.vim @@ -0,0 +1,622 @@ +" Author: gagbo , w0rp , roel0 +" Description: Functions for integrating with C-family linters. + +call ale#Set('c_parse_makefile', 0) +call ale#Set('c_always_make', has('unix') && !has('macunix')) +call ale#Set('c_parse_compile_commands', 1) + +let s:sep = has('win32') ? '\' : '/' + +" Set just so tests can override it. +let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt'] + +let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [ +\ 'build', +\ 'bin', +\]) + +function! s:CanParseMakefile(buffer) abort + " Something somewhere seems to delete this setting in tests, so ensure we + " always have a default value. + call ale#Set('c_parse_makefile', 0) + + return ale#Var(a:buffer, 'c_parse_makefile') +endfunction + +function! ale#c#GetBuildDirectory(buffer) abort + let l:build_dir = ale#Var(a:buffer, 'c_build_dir') + + " c_build_dir has the priority if defined + if !empty(l:build_dir) + return l:build_dir + endif + + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + + return ale#path#Dirname(l:json_file) +endfunction + +function! ale#c#ShellSplit(line) abort + let l:stack = [] + let l:args = [''] + let l:prev = '' + + for l:char in split(a:line, '\zs') + if l:char is# '''' + if len(l:stack) > 0 && get(l:stack, -1) is# '''' + call remove(l:stack, -1) + elseif (len(l:stack) == 0 || get(l:stack, -1) isnot# '"') && l:prev isnot# '\' + call add(l:stack, l:char) + endif + elseif (l:char is# '"' || l:char is# '`') && l:prev isnot# '\' + if len(l:stack) > 0 && get(l:stack, -1) is# l:char + call remove(l:stack, -1) + elseif len(l:stack) == 0 || get(l:stack, -1) isnot# '''' + call add(l:stack, l:char) + endif + elseif (l:char is# '(' || l:char is# '[' || l:char is# '{') && l:prev isnot# '\' + if len(l:stack) == 0 || get(l:stack, -1) isnot# '''' + call add(l:stack, l:char) + endif + elseif (l:char is# ')' || l:char is# ']' || l:char is# '}') && l:prev isnot# '\' + if len(l:stack) > 0 && get(l:stack, -1) is# {')': '(', ']': '[', '}': '{'}[l:char] + call remove(l:stack, -1) + endif + elseif l:char is# ' ' && len(l:stack) == 0 + if len(get(l:args, -1)) > 0 + call add(l:args, '') + endif + + continue + endif + + let l:args[-1] = get(l:args, -1) . l:char + endfor + + return l:args +endfunction + +" Takes the path prefix and a list of cflags and expands @file arguments to +" the contents of the file. +" +" @file arguments are command line arguments recognised by gcc and clang. For +" instance, if @./path/to/file was given to gcc, it would load .path/to/file +" and use the contents of that file as arguments. +function! ale#c#ExpandAtArgs(path_prefix, raw_split_lines) abort + let l:out_lines = [] + + for l:option in a:raw_split_lines + if stridx(l:option, '@') == 0 + " This is an argument specifying a location of a file containing other arguments + let l:path = join(split(l:option, '\zs')[1:], '') + + " Make path absolute + if !ale#path#IsAbsolute(l:path) + let l:rel_path = substitute(l:path, '"', '', 'g') + let l:rel_path = substitute(l:rel_path, '''', '', 'g') + let l:path = ale#path#GetAbsPath(a:path_prefix, l:rel_path) + endif + + " Read the file and add all the arguments + try + let l:additional_args = readfile(l:path) + catch + continue " All we can really do is skip this argument + endtry + + let l:file_lines = [] + + for l:line in l:additional_args + let l:file_lines += ale#c#ShellSplit(l:line) + endfor + + " @file arguments can include other @file arguments, so we must + " recurse. + let l:out_lines += ale#c#ExpandAtArgs(a:path_prefix, l:file_lines) + else + " This is not an @file argument, so don't touch it. + let l:out_lines += [l:option] + endif + endfor + + return l:out_lines +endfunction + +" Quote C/C++ a compiler argument, if needed. +" +" Quoting arguments might cause issues with some systems/compilers, so we only +" quote them if we need to. +function! ale#c#QuoteArg(arg) abort + if a:arg !~# '\v[#$&*()\\|[\]{};''"<>/?! ^%]' + return a:arg + endif + + return ale#Escape(a:arg) +endfunction + +function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort + " Expand @file arguments now before parsing + let l:arguments = ale#c#ExpandAtArgs(a:path_prefix, a:raw_arguments) + " A list of [already_quoted, argument] + let l:items = [] + let l:option_index = 0 + + while l:option_index < len(l:arguments) + let l:option = l:arguments[l:option_index] + let l:option_index = l:option_index + 1 + + " Include options, that may need relative path fix + if stridx(l:option, '-I') == 0 + \ || stridx(l:option, '-iquote') == 0 + \ || stridx(l:option, '-isystem') == 0 + \ || stridx(l:option, '-idirafter') == 0 + \ || stridx(l:option, '-iframework') == 0 + if stridx(l:option, '-I') == 0 && l:option isnot# '-I' + let l:arg = join(split(l:option, '\zs')[2:], '') + let l:option = '-I' + else + let l:arg = l:arguments[l:option_index] + let l:option_index = l:option_index + 1 + endif + + " Fix relative paths if needed + if !ale#path#IsAbsolute(l:arg) + let l:rel_path = substitute(l:arg, '"', '', 'g') + let l:rel_path = substitute(l:rel_path, '''', '', 'g') + let l:arg = ale#path#GetAbsPath(a:path_prefix, l:rel_path) + endif + + call add(l:items, [1, l:option]) + call add(l:items, [1, ale#Escape(l:arg)]) + " Options with arg that can be grouped with the option or separate + elseif stridx(l:option, '-D') == 0 || stridx(l:option, '-B') == 0 + if l:option is# '-D' || l:option is# '-B' + call add(l:items, [1, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) + let l:option_index = l:option_index + 1 + else + call add(l:items, [0, l:option]) + endif + " Options that have an argument (always separate) + elseif l:option is# '-iprefix' || stridx(l:option, '-iwithprefix') == 0 + \ || l:option is# '-isysroot' || l:option is# '-imultilib' + \ || l:option is# '-include' || l:option is# '-imacros' + call add(l:items, [0, l:option]) + call add(l:items, [0, l:arguments[l:option_index]]) + let l:option_index = l:option_index + 1 + " Options without argument + elseif (stridx(l:option, '-W') == 0 && stridx(l:option, '-Wa,') != 0 && stridx(l:option, '-Wl,') != 0 && stridx(l:option, '-Wp,') != 0) + \ || l:option is# '-w' || stridx(l:option, '-pedantic') == 0 + \ || l:option is# '-ansi' || stridx(l:option, '-std=') == 0 + \ || stridx(l:option, '-f') == 0 && l:option !~# '\v^-f(dump|diagnostics|no-show-column|stack-usage)' + \ || stridx(l:option, '-O') == 0 + \ || l:option is# '-C' || l:option is# '-CC' || l:option is# '-trigraphs' + \ || stridx(l:option, '-nostdinc') == 0 || stridx(l:option, '-iplugindir=') == 0 + \ || stridx(l:option, '--sysroot=') == 0 || l:option is# '--no-sysroot-suffix' + \ || stridx(l:option, '-m') == 0 + call add(l:items, [0, l:option]) + endif + endwhile + + if a:should_quote + " Quote C arguments that haven't already been quoted above. + " If and only if we've been asked to quote them. + call map(l:items, 'v:val[0] ? v:val[1] : ale#c#QuoteArg(v:val[1])') + else + call map(l:items, 'v:val[1]') + endif + + return join(l:items, ' ') +endfunction + +function! ale#c#ParseCFlagsFromMakeOutput(buffer, make_output) abort + if !s:CanParseMakefile(a:buffer) + return v:null + endif + + let l:buffer_filename = expand('#' . a:buffer . ':t') + let l:cflag_line = '' + + " Find a line matching this buffer's filename in the make output. + for l:line in a:make_output + if stridx(l:line, l:buffer_filename) >= 0 + let l:cflag_line = l:line + break + endif + endfor + + let l:makefile_path = ale#path#FindNearestFile(a:buffer, 'Makefile') + let l:makefile_dir = fnamemodify(l:makefile_path, ':p:h') + + return ale#c#ParseCFlags(l:makefile_dir, 0, ale#c#ShellSplit(l:cflag_line)) +endfunction + +" Given a buffer number, find the project directory containing +" compile_commands.json, and the path to the compile_commands.json file. +" +" If compile_commands.json cannot be found, two empty strings will be +" returned. +function! ale#c#FindCompileCommands(buffer) abort + " Look above the current source file to find compile_commands.json + let l:json_file = ale#path#FindNearestFile(a:buffer, 'compile_commands.json') + + if !empty(l:json_file) + return [fnamemodify(l:json_file, ':h'), l:json_file] + endif + + " Search in build directories if we can't find it in the project. + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:dirname in ale#Var(a:buffer, 'c_build_dir_names') + let l:c_build_dir = l:path . s:sep . l:dirname + let l:json_file = l:c_build_dir . s:sep . 'compile_commands.json' + + if filereadable(l:json_file) + return [l:path, l:json_file] + endif + endfor + endfor + + return ['', ''] +endfunction + +" Find the project root for C/C++ projects. +" +" The location of compile_commands.json will be used to find project roots. +" +" If compile_commands.json cannot be found, other common configuration files +" will be used to detect the project root. +function! ale#c#FindProjectRoot(buffer) abort + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + + " Fall back on detecting the project root based on other filenames. + if empty(l:root) + for l:project_filename in g:__ale_c_project_filenames + let l:full_path = ale#path#FindNearestFile(a:buffer, l:project_filename) + + if !empty(l:full_path) + let l:path = fnamemodify(l:full_path, ':h') + + " Correct .git path detection. + if fnamemodify(l:path, ':t') is# '.git' + let l:path = fnamemodify(l:path, ':h') + endif + + return l:path + endif + endfor + endif + + return l:root +endfunction + +" Cache compile_commands.json data in a Dictionary, so we don't need to read +" the same files over and over again. The key in the dictionary will include +" the last modified time of the file. +if !exists('s:compile_commands_cache') + let s:compile_commands_cache = {} +endif + +function! ale#c#ResetCompileCommandsCache() abort + let s:compile_commands_cache = {} +endfunction + +function! s:GetLookupFromCompileCommandsFile(compile_commands_file) abort + let l:empty = [{}, {}] + + if empty(a:compile_commands_file) + return l:empty + endif + + let l:time = getftime(a:compile_commands_file) + + if l:time < 0 + return l:empty + endif + + let l:key = a:compile_commands_file . ':' . l:time + + if has_key(s:compile_commands_cache, l:key) + return s:compile_commands_cache[l:key] + endif + + let l:raw_data = [] + silent! let l:raw_data = json_decode(join(readfile(a:compile_commands_file), '')) + + if type(l:raw_data) isnot v:t_list + let l:raw_data = [] + endif + + let l:file_lookup = {} + let l:dir_lookup = {} + + for l:entry in (type(l:raw_data) is v:t_list ? l:raw_data : []) + let l:filename = ale#path#GetAbsPath(l:entry.directory, l:entry.file) + + " Store a key for lookups by the absolute path to the filename. + let l:file_lookup[l:filename] = get(l:file_lookup, l:filename, []) + [l:entry] + + " Store a key for fuzzy lookups by the absolute path to the directory. + let l:dirname = fnamemodify(l:filename, ':h') + let l:dir_lookup[l:dirname] = get(l:dir_lookup, l:dirname, []) + [l:entry] + + " Store a key for fuzzy lookups by just the basename of the file. + let l:basename = tolower(fnamemodify(l:entry.file, ':t')) + let l:file_lookup[l:basename] = get(l:file_lookup, l:basename, []) + [l:entry] + + " Store a key for fuzzy lookups by just the basename of the directory. + let l:dirbasename = tolower(fnamemodify(l:entry.directory, ':p:h:t')) + let l:dir_lookup[l:dirbasename] = get(l:dir_lookup, l:dirbasename, []) + [l:entry] + endfor + + if !empty(l:file_lookup) && !empty(l:dir_lookup) + let l:result = [l:file_lookup, l:dir_lookup] + let s:compile_commands_cache[l:key] = l:result + + return l:result + endif + + return l:empty +endfunction + +" Get [should_quote, arguments] from either 'command' or 'arguments' +" 'arguments' should be quoted later, the split 'command' strings should not. +function! s:GetArguments(json_item) abort + if has_key(a:json_item, 'arguments') + return [1, a:json_item.arguments] + elseif has_key(a:json_item, 'command') + return [0, ale#c#ShellSplit(a:json_item.command)] + endif + + return [0, []] +endfunction + +function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort + let l:buffer_filename = ale#path#Simplify(expand('#' . a:buffer . ':p')) + let l:basename = tolower(fnamemodify(l:buffer_filename, ':t')) + " Look for any file in the same directory if we can't find an exact match. + let l:dir = fnamemodify(l:buffer_filename, ':h') + + " Search for an exact file match first. + let l:file_list = get(a:file_lookup, l:buffer_filename, []) + + " We may have to look for /foo/bar instead of C:\foo\bar + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:buffer_filename), + \ [] + \) + endif + + " Try the absolute path to the directory second. + let l:dir_list = get(a:dir_lookup, l:dir, []) + + if empty(l:dir_list) && has('win32') + let l:dir_list = get( + \ a:dir_lookup, + \ ale#path#RemoveDriveLetter(l:dir), + \ [] + \) + endif + + if empty(l:file_list) && empty(l:dir_list) + " If we can't find matches with the path to the file, try a + " case-insensitive match for any similarly-named file. + let l:file_list = get(a:file_lookup, l:basename, []) + + " If we can't find matches with the path to the directory, try a + " case-insensitive match for anything in similarly-named directory. + let l:dir_list = get(a:dir_lookup, tolower(fnamemodify(l:dir, ':t')), []) + endif + + " A source file matching the header filename. + let l:source_file = '' + + if empty(l:file_list) && l:basename =~? '\.h$\|\.hpp$' + for l:suffix in ['.c', '.cpp'] + " Try to find a source file by an absolute path first. + let l:key = fnamemodify(l:buffer_filename, ':r') . l:suffix + let l:file_list = get(a:file_lookup, l:key, []) + + if empty(l:file_list) && has('win32') + let l:file_list = get( + \ a:file_lookup, + \ ale#path#RemoveDriveLetter(l:key), + \ [] + \) + endif + + if empty(l:file_list) + " Look fuzzy matches on the basename second. + let l:key = fnamemodify(l:basename, ':r') . l:suffix + let l:file_list = get(a:file_lookup, l:key, []) + endif + + if !empty(l:file_list) + let l:source_file = l:key + break + endif + endfor + endif + + for l:item in l:file_list + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + + " Load the flags for this file, or for a source file matching the + " header file. + if ( + \ bufnr(l:filename) is a:buffer + \ || ( + \ !empty(l:source_file) + \ && l:filename[-len(l:source_file):] is? l:source_file + \ ) + \) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) + endif + endfor + + for l:item in l:dir_list + let l:filename = ale#path#GetAbsPath(l:item.directory, l:item.file) + + if ale#path#RemoveDriveLetter(fnamemodify(l:filename, ':h')) + \ is? ale#path#RemoveDriveLetter(l:dir) + let [l:should_quote, l:args] = s:GetArguments(l:item) + + return ale#c#ParseCFlags(l:item.directory, l:should_quote, l:args) + endif + endfor + + return '' +endfunction + +function! ale#c#FlagsFromCompileCommands(buffer, compile_commands_file) abort + let l:lookups = s:GetLookupFromCompileCommandsFile(a:compile_commands_file) + let l:file_lookup = l:lookups[0] + let l:dir_lookup = l:lookups[1] + + return ale#c#ParseCompileCommandsFlags(a:buffer, l:file_lookup, l:dir_lookup) +endfunction + +function! ale#c#GetCFlags(buffer, output) abort + let l:cflags = v:null + + if ale#Var(a:buffer, 'c_parse_compile_commands') + let [l:root, l:json_file] = ale#c#FindCompileCommands(a:buffer) + + if !empty(l:json_file) + let l:cflags = ale#c#FlagsFromCompileCommands(a:buffer, l:json_file) + endif + endif + + if empty(l:cflags) && s:CanParseMakefile(a:buffer) && !empty(a:output) + let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output) + endif + + if l:cflags is v:null + let l:cflags = ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer)) + endif + + return l:cflags isnot v:null ? l:cflags : '' +endfunction + +function! ale#c#GetMakeCommand(buffer) abort + if s:CanParseMakefile(a:buffer) + let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile') + + if empty(l:path) + let l:path = ale#path#FindNearestFile(a:buffer, 'GNUmakefile') + endif + + if !empty(l:path) + let l:always_make = ale#Var(a:buffer, 'c_always_make') + + return [ + \ fnamemodify(l:path, ':h'), + \ 'make -n' . (l:always_make ? ' --always-make' : ''), + \] + endif + endif + + return ['', ''] +endfunction + +function! ale#c#RunMakeCommand(buffer, Callback) abort + let [l:cwd, l:command] = ale#c#GetMakeCommand(a:buffer) + + if empty(l:command) + return a:Callback(a:buffer, []) + endif + + return ale#command#Run( + \ a:buffer, + \ l:command, + \ {b, output -> a:Callback(a:buffer, output)}, + \ {'cwd': l:cwd}, + \) +endfunction + +" Given a buffer number, search for a project root, and output a List +" of directories to include based on some heuristics. +" +" For projects with headers in the project root, the project root will +" be returned. +" +" For projects with an 'include' directory, that directory will be returned. +function! ale#c#FindLocalHeaderPaths(buffer) abort + let l:project_root = ale#c#FindProjectRoot(a:buffer) + + if empty(l:project_root) + return [] + endif + + " See if we can find .h files directory in the project root. + " If we can, that's our include directory. + if !empty(globpath(l:project_root, '*.h', 0)) + return [l:project_root] + endif + + " Look for .hpp files too. + if !empty(globpath(l:project_root, '*.hpp', 0)) + return [l:project_root] + endif + + " If we find an 'include' directory in the project root, then use that. + if isdirectory(l:project_root . '/include') + return [ale#path#Simplify(l:project_root . s:sep . 'include')] + endif + + return [] +endfunction + +" Given a List of include paths, create a string containing the -I include +" options for those paths, with the paths escaped for use in the shell. +function! ale#c#IncludeOptions(include_paths) abort + let l:option_list = [] + + for l:path in a:include_paths + call add(l:option_list, '-I' . ale#Escape(l:path)) + endfor + + if empty(l:option_list) + return '' + endif + + return join(l:option_list) +endfunction + +" Get the language flag depending on on the executable, options and +" file extension +function! ale#c#GetLanguageFlag( +\ buffer, +\ executable, +\ use_header_lang_flag, +\ header_exts, +\ linter_lang_flag +\) abort + " Use only '-header' if the executable is 'clang' by default + if a:use_header_lang_flag == -1 + let l:use_header_lang_flag = a:executable =~# 'clang' + else + let l:use_header_lang_flag = a:use_header_lang_flag + endif + + " If we don't use the header language flag, return the default linter + " language flag + if !l:use_header_lang_flag + return a:linter_lang_flag + endif + + " Get the buffer file extension + let l:buf_ext = expand('#' . a:buffer . ':e') + + " If the buffer file is an header according to its extension, use + " the linter language flag + '-header', ex: 'c-header' + if index(a:header_exts, l:buf_ext) >= 0 + return a:linter_lang_flag . '-header' + endif + + " Else, use the default linter language flag + return a:linter_lang_flag +endfunction diff --git a/sources_non_forked/ale/autoload/ale/code_action.vim b/sources_non_forked/ale/autoload/ale/code_action.vim new file mode 100644 index 00000000..db31aad5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/code_action.vim @@ -0,0 +1,389 @@ +" Author: Jerko Steiner +" Description: Code action support for LSP / tsserver + +function! ale#code_action#ReloadBuffer() abort + let l:buffer = bufnr('') + + execute 'augroup ALECodeActionReloadGroup' . l:buffer + autocmd! + augroup END + + silent! execute 'augroup! ALECodeActionReloadGroup' . l:buffer + + call ale#util#Execute(':e!') +endfunction + +function! ale#code_action#HandleCodeAction(code_action, options) abort + let l:current_buffer = bufnr('') + let l:changes = a:code_action.changes + + for l:file_code_edit in l:changes + call ale#code_action#ApplyChanges( + \ l:file_code_edit.fileName, + \ l:file_code_edit.textChanges, + \ a:options, + \) + endfor +endfunction + +function! s:ChangeCmp(left, right) abort + if a:left.start.line < a:right.start.line + return -1 + endif + + if a:left.start.line > a:right.start.line + return 1 + endif + + if a:left.start.offset < a:right.start.offset + return -1 + endif + + if a:left.start.offset > a:right.start.offset + return 1 + endif + + if a:left.end.line < a:right.end.line + return -1 + endif + + if a:left.end.line > a:right.end.line + return 1 + endif + + if a:left.end.offset < a:right.end.offset + return -1 + endif + + if a:left.end.offset > a:right.end.offset + return 1 + endif + + return 0 +endfunction + +function! ale#code_action#ApplyChanges(filename, changes, options) abort + let l:should_save = get(a:options, 'should_save') + let l:conn_id = get(a:options, 'conn_id') + + let l:orig_buffer = bufnr('') + + " The buffer is used to determine the fileformat, if available. + let l:buffer = bufnr(a:filename) + + if l:buffer != l:orig_buffer + call ale#util#Execute('silent edit ' . a:filename) + let l:buffer = bufnr('') + endif + + let l:lines = getbufline(l:buffer, 1, '$') + + " Add empty line if there's trailing newline, like readfile() does. + if getbufvar(l:buffer, '&eol') + let l:lines += [''] + endif + + let l:pos = getpos('.')[1:2] + + " Changes have to be sorted so we apply them from bottom-to-top + for l:code_edit in reverse(sort(copy(a:changes), function('s:ChangeCmp'))) + let l:line = l:code_edit.start.line + let l:column = l:code_edit.start.offset + let l:end_line = l:code_edit.end.line + let l:end_column = l:code_edit.end.offset + let l:text = l:code_edit.newText + + let l:insertions = split(l:text, '\n', 1) + + " Fix invalid columns + let l:column = l:column > 0 ? l:column : 1 + let l:end_column = l:end_column > 0 ? l:end_column : 1 + + " Clamp start to BOF + if l:line < 1 + let [l:line, l:column] = [1, 1] + endif + + " Clamp start to EOF + if l:line > len(l:lines) || l:line == len(l:lines) && l:column > len(l:lines[-1]) + 1 + let [l:line, l:column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when start is after EOL + elseif l:line < len(l:lines) && l:column > len(l:lines[l:line - 1]) + 1 + let [l:line, l:column] = [l:line + 1, 1] + endif + + " Adjust end: clamp if invalid and/or adjust if we moved start + if l:end_line < l:line || l:end_line == l:line && l:end_column < l:column + let [l:end_line, l:end_column] = [l:line, l:column] + endif + + " Clamp end to EOF + if l:end_line > len(l:lines) || l:end_line == len(l:lines) && l:end_column > len(l:lines[-1]) + 1 + let [l:end_line, l:end_column] = [len(l:lines), len(l:lines[-1]) + 1] + " Special case when end is after EOL + elseif l:end_line < len(l:lines) && l:end_column > len(l:lines[l:end_line - 1]) + 1 + let [l:end_line, l:end_column] = [l:end_line + 1, 1] + endif + + " Careful, [:-1] is not an empty list + let l:start = l:line is 1 ? [] : l:lines[: l:line - 2] + let l:middle = l:column is 1 ? [''] : [l:lines[l:line - 1][: l:column - 2]] + + let l:middle[-1] .= l:insertions[0] + let l:middle += l:insertions[1:] + let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :] + + let l:end_line_len = len(l:lines[l:end_line - 1]) + let l:lines_before_change = len(l:lines) + let l:lines = l:start + l:middle + l:lines[l:end_line :] + + let l:current_line_offset = len(l:lines) - l:lines_before_change + let l:column_offset = len(l:middle[-1]) - l:end_line_len + + " Keep cursor where it was (if outside of changes) or move it after + " the changed text (if inside), but don't touch it when the change + " spans the entire buffer, in which case we have no clue and it's + " better to not do anything. + if l:line isnot 1 || l:column isnot 1 + \|| l:end_line < l:lines_before_change + \|| l:end_line == l:lines_before_change && l:end_column <= l:end_line_len + let l:pos = s:UpdateCursor(l:pos, + \ [l:line, l:column], + \ [l:end_line, l:end_column], + \ [l:current_line_offset, l:column_offset]) + endif + endfor + + " Make sure to add a trailing newline if and only if it should be added. + if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol') + call remove(l:lines, -1) + else + call setbufvar(l:buffer, '&eol', 0) + endif + + call ale#util#SetBufferContents(l:buffer, l:lines) + + call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) + + if l:should_save + call ale#util#Execute('silent w!') + endif + + call setpos('.', [0, l:pos[0], l:pos[1], 0]) + + if l:orig_buffer != l:buffer && bufexists(l:orig_buffer) + call ale#util#Execute('silent buf ' . string(l:orig_buffer)) + endif +endfunction + +function! s:UpdateCursor(cursor, start, end, offset) abort + let l:cur_line = a:cursor[0] + let l:cur_column = a:cursor[1] + let l:line = a:start[0] + let l:column = a:start[1] + let l:end_line = a:end[0] + let l:end_column = a:end[1] + let l:line_offset = a:offset[0] + let l:column_offset = a:offset[1] + + if l:end_line < l:cur_line + " both start and end lines are before the cursor. only line offset + " needs to be updated + let l:cur_line += l:line_offset + elseif l:end_line == l:cur_line + " end line is at the same location as cursor, which means + " l:line <= l:cur_line + if l:line < l:cur_line || l:column <= l:cur_column + " updates are happening either before or around the cursor + if l:end_column < l:cur_column + " updates are happening before the cursor, update the + " column offset for cursor + let l:cur_line += l:line_offset + let l:cur_column += l:column_offset + else + " updates are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line += l:line_offset + let l:cur_column = l:end_column + l:column_offset + endif + " else is not necessary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + else + " end line is after the cursor + if l:line < l:cur_line || l:line == l:cur_line && l:column <= l:cur_column + " changes are happening around the cursor, move the cursor + " to the end of the changes + let l:cur_line = l:end_line + l:line_offset + let l:cur_column = l:end_column + l:column_offset + " else is not necessary, it means modifications are happening + " after the cursor so no cursor updates need to be done + endif + endif + + return [l:cur_line, l:cur_column] +endfunction + +function! ale#code_action#GetChanges(workspace_edit) abort + if a:workspace_edit is v:null + return {} + endif + + let l:changes = {} + + if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes) + return a:workspace_edit.changes + elseif has_key(a:workspace_edit, 'documentChanges') + let l:document_changes = [] + + if type(a:workspace_edit.documentChanges) is v:t_dict + \ && has_key(a:workspace_edit.documentChanges, 'edits') + call add(l:document_changes, a:workspace_edit.documentChanges) + elseif type(a:workspace_edit.documentChanges) is v:t_list + let l:document_changes = a:workspace_edit.documentChanges + endif + + for l:text_document_edit in l:document_changes + let l:filename = l:text_document_edit.textDocument.uri + let l:edits = l:text_document_edit.edits + let l:changes[l:filename] = l:edits + endfor + endif + + return l:changes +endfunction + +function! ale#code_action#BuildChangesList(changes_map) abort + let l:changes = [] + + for l:file_name in keys(a:changes_map) + let l:text_edits = a:changes_map[l:file_name] + let l:text_changes = [] + + for l:edit in l:text_edits + let l:range = l:edit.range + let l:new_text = l:edit.newText + + call add(l:text_changes, { + \ 'start': { + \ 'line': l:range.start.line + 1, + \ 'offset': l:range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:range.end.line + 1, + \ 'offset': l:range.end.character + 1, + \ }, + \ 'newText': l:new_text, + \}) + endfor + + call add(l:changes, { + \ 'fileName': ale#util#ToResource(l:file_name), + \ 'textChanges': l:text_changes, + \}) + endfor + + return l:changes +endfunction + +function! s:EscapeMenuName(text) abort + return substitute(a:text, '\\\| \|\.\|&', '\\\0', 'g') +endfunction + +function! s:UpdateMenu(data, menu_items) abort + silent! aunmenu PopUp.Refactor\.\.\. + + if empty(a:data) + return + endif + + for [l:type, l:item] in a:menu_items + let l:name = l:type is# 'tsserver' ? l:item.name : l:item.title + let l:func_name = l:type is# 'tsserver' + \ ? 'ale#codefix#ApplyTSServerCodeAction' + \ : 'ale#codefix#ApplyLSPCodeAction' + + execute printf( + \ 'anoremenu PopUp.&Refactor\.\.\..%s' + \ . ' :call %s(%s, %s)', + \ s:EscapeMenuName(l:name), + \ l:func_name, + \ string(a:data), + \ string(l:item), + \) + endfor + + if empty(a:menu_items) + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + endif +endfunction + +function! s:GetCodeActions(linter, options) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + + let l:location = { + \ 'buffer': l:buffer, + \ 'line': l:line, + \ 'column': l:column, + \ 'end_line': l:line, + \ 'end_column': l:column, + \} + let l:Callback = function('s:OnReady', [l:location, a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#code_action#GetCodeActions(options) abort + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + + " Only display the menu items if there's an LSP server. + let l:has_lsp = 0 + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + let l:has_lsp = 1 + + break + endif + endfor + + if l:has_lsp + if !empty(expand('')) + silent! anoremenu PopUp.Rename :ALERename + endif + + silent! anoremenu PopUp.Refactor\.\.\..(None) :silent + + call ale#codefix#Execute( + \ mode() is# 'v' || mode() is# "\", + \ function('s:UpdateMenu') + \) + endif +endfunction + +function! s:Setup(enabled) abort + augroup ALECodeActionsGroup + autocmd! + + if a:enabled + autocmd MenuPopup * :call ale#code_action#GetCodeActions({}) + endif + augroup END + + if !a:enabled + silent! augroup! ALECodeActionsGroup + + silent! aunmenu PopUp.Rename + silent! aunmenu PopUp.Refactor\.\.\. + endif +endfunction + +function! ale#code_action#EnablePopUpMenu() abort + call s:Setup(1) +endfunction + +function! ale#code_action#DisablePopUpMenu() abort + call s:Setup(0) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/codefix.vim b/sources_non_forked/ale/autoload/ale/codefix.vim new file mode 100644 index 00000000..34ce3e15 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/codefix.vim @@ -0,0 +1,497 @@ +" Author: Dalius Dobravolskas +" Description: Code Fix support for tsserver and LSP servers + +let s:codefix_map = {} + +" Used to get the codefix map in tests. +function! ale#codefix#GetMap() abort + return deepcopy(s:codefix_map) +endfunction + +" Used to set the codefix map in tests. +function! ale#codefix#SetMap(map) abort + let s:codefix_map = a:map +endfunction + +function! ale#codefix#ClearLSPData() abort + let s:codefix_map = {} +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#codefix#ApplyTSServerCodeAction(data, item) abort + if has_key(a:item, 'changes') + let l:changes = a:item.changes + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codefix', + \ 'changes': l:changes, + \ }, + \ {}, + \) + else + let l:message = ale#lsp#tsserver_message#GetEditsForRefactor( + \ a:data.buffer, + \ a:data.line, + \ a:data.column, + \ a:data.end_line, + \ a:data.end_column, + \ a:item.id[0], + \ a:item.id[1], + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + + let s:codefix_map[l:request_id] = a:data + endif +endfunction + +function! ale#codefix#HandleTSServerResponse(conn_id, response) abort + if !has_key(a:response, 'request_seq') + \ || !has_key(s:codefix_map, a:response.request_seq) + return + endif + + let l:data = remove(s:codefix_map, a:response.request_seq) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + if get(a:response, 'command', '') is# 'getCodeFixes' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting code fixes. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + call filter(l:result, 'has_key(v:val, ''changes'')') + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''tsserver'', v:val]') + \) + + return + endif + + if len(l:result) == 0 + call s:message('No code fixes available.') + + return + endif + + let l:code_fix_to_apply = 0 + + if len(l:result) == 1 + let l:code_fix_to_apply = 1 + else + let l:codefix_no = 1 + let l:codefixstring = "Code Fixes:\n" + + for l:codefix in l:result + let l:codefixstring .= l:codefix_no . ') ' + \ . l:codefix.description . "\n" + let l:codefix_no += 1 + endfor + + let l:codefixstring .= 'Type number and (empty cancels): ' + + let l:code_fix_to_apply = ale#util#Input(l:codefixstring, '') + let l:code_fix_to_apply = str2nr(l:code_fix_to_apply) + + if l:code_fix_to_apply == 0 + return + endif + endif + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:result[l:code_fix_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getApplicableRefactors' + if get(a:response, 'success', v:false) is v:false + \&& l:MenuCallback is v:null + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting applicable refactors. Reason: ' . l:message) + + return + endif + + let l:result = get(a:response, 'body', []) + + if len(l:result) == 0 + call s:message('No applicable refactors available.') + + return + endif + + let l:refactors = [] + + for l:item in l:result + for l:action in l:item.actions + call add(l:refactors, { + \ 'name': l:action.description, + \ 'id': [l:item.name, l:action.name], + \}) + endfor + endfor + + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:refactors), '[''tsserver'', v:val]') + \) + + return + endif + + let l:refactor_no = 1 + let l:refactorstring = "Applicable refactors:\n" + + for l:refactor in l:refactors + let l:refactorstring .= l:refactor_no . ') ' + \ . l:refactor.name . "\n" + let l:refactor_no += 1 + endfor + + let l:refactorstring .= 'Type number and (empty cancels): ' + + let l:refactor_to_apply = ale#util#Input(l:refactorstring, '') + let l:refactor_to_apply = str2nr(l:refactor_to_apply) + + if l:refactor_to_apply == 0 + return + endif + + let l:id = l:refactors[l:refactor_to_apply - 1].id + + call ale#codefix#ApplyTSServerCodeAction( + \ l:data, + \ l:refactors[l:refactor_to_apply - 1], + \) + elseif get(a:response, 'command', '') is# 'getEditsForRefactor' + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error while getting edits for refactor. Reason: ' . l:message) + + return + endif + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'editsForRefactor', + \ 'changes': a:response.body.edits, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#ApplyLSPCodeAction(data, item) abort + if has_key(a:item, 'command') + \&& type(a:item.command) == v:t_dict + let l:command = a:item.command + let l:message = ale#lsp#message#ExecuteCommand( + \ l:command.command, + \ l:command.arguments, + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + elseif has_key(a:item, 'command') && has_key(a:item, 'arguments') + \&& type(a:item.command) == v:t_string + let l:message = ale#lsp#message#ExecuteCommand( + \ a:item.command, + \ a:item.arguments, + \) + + let l:request_id = ale#lsp#Send(a:data.connection_id, l:message) + elseif has_key(a:item, 'edit') || has_key(a:item, 'arguments') + if has_key(a:item, 'edit') + let l:topass = a:item.edit + else + let l:topass = a:item.arguments[0] + endif + + let l:changes_map = ale#code_action#GetChanges(l:topass) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'codeaction', + \ 'changes': l:changes, + \ }, + \ {}, + \) + endif +endfunction + +function! ale#codefix#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'method') + \ && a:response.method is# 'workspace/applyEdit' + \ && has_key(a:response, 'params') + let l:params = a:response.params + + let l:changes_map = ale#code_action#GetChanges(l:params.edit) + + if empty(l:changes_map) + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'applyEdit', + \ 'changes': l:changes, + \ }, + \ {} + \) + elseif has_key(a:response, 'id') + \&& has_key(s:codefix_map, a:response.id) + let l:data = remove(s:codefix_map, a:response.id) + let l:MenuCallback = get(l:data, 'menu_callback', v:null) + + let l:result = get(a:response, 'result') + + if type(l:result) != v:t_list + let l:result = [] + endif + + " Send the results to the menu callback, if set. + if l:MenuCallback isnot v:null + call l:MenuCallback( + \ l:data, + \ map(copy(l:result), '[''lsp'', v:val]') + \) + + return + endif + + if len(l:result) == 0 + call s:message('No code actions received from server') + + return + endif + + let l:codeaction_no = 1 + let l:codeactionstring = "Code Fixes:\n" + + for l:codeaction in l:result + let l:codeactionstring .= l:codeaction_no . ') ' + \ . l:codeaction.title . "\n" + let l:codeaction_no += 1 + endfor + + let l:codeactionstring .= 'Type number and (empty cancels): ' + + let l:codeaction_to_apply = ale#util#Input(l:codeactionstring, '') + let l:codeaction_to_apply = str2nr(l:codeaction_to_apply) + + if l:codeaction_to_apply == 0 + return + endif + + let l:item = l:result[l:codeaction_to_apply - 1] + + call ale#codefix#ApplyLSPCodeAction(l:data, l:item) + endif +endfunction + +function! s:FindError(buffer, line, column, end_line, end_column, linter_name) abort + let l:nearest_error = v:null + + if a:line == a:end_line + \&& a:column == a:end_column + \&& has_key(g:ale_buffer_info, a:buffer) + let l:nearest_error_diff = -1 + + for l:error in get(g:ale_buffer_info[a:buffer], 'loclist', []) + if has_key(l:error, 'code') + \ && (a:linter_name is v:null || l:error.linter_name is# a:linter_name) + \ && l:error.lnum == a:line + let l:diff = abs(l:error.col - a:column) + + if l:nearest_error_diff == -1 || l:diff < l:nearest_error_diff + let l:nearest_error_diff = l:diff + let l:nearest_error = l:error + endif + endif + endfor + endif + + return l:nearest_error +endfunction + +function! s:OnReady( +\ line, +\ column, +\ end_line, +\ end_column, +\ MenuCallback, +\ linter, +\ lsp_details, +\) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'code_actions') + return + endif + + let l:buffer = a:lsp_details.buffer + + if a:linter.lsp is# 'tsserver' + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, a:linter.lsp) + + if l:nearest_error isnot v:null + let l:message = ale#lsp#tsserver_message#GetCodeFixes( + \ l:buffer, + \ a:line, + \ a:column, + \ a:line, + \ a:column, + \ [l:nearest_error.code], + \) + else + let l:message = ale#lsp#tsserver_message#GetApplicableRefactors( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \) + endif + else + " Send a message saying the buffer has changed first, otherwise + " completions won't know what text is nearby. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:diagnostics = [] + let l:nearest_error = + \ s:FindError(l:buffer, a:line, a:column, a:end_line, a:end_column, v:null) + + if l:nearest_error isnot v:null + let l:diagnostics = [ + \ { + \ 'code': l:nearest_error.code, + \ 'message': l:nearest_error.text, + \ 'range': { + \ 'start': { + \ 'line': l:nearest_error.lnum - 1, + \ 'character': l:nearest_error.col - 1, + \ }, + \ 'end': { + \ 'line': get(l:nearest_error, 'end_lnum', 1) - 1, + \ 'character': get(l:nearest_error, 'end_col', 0) + \ }, + \ }, + \ }, + \] + endif + + let l:message = ale#lsp#message#CodeAction( + \ l:buffer, + \ a:line, + \ a:column, + \ a:end_line, + \ a:end_column, + \ l:diagnostics, + \) + endif + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#codefix#HandleTSServerResponse') + \ : function('ale#codefix#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:codefix_map[l:request_id] = { + \ 'connection_id': l:id, + \ 'buffer': l:buffer, + \ 'line': a:line, + \ 'column': a:column, + \ 'end_line': a:end_line, + \ 'end_column': a:end_column, + \ 'menu_callback': a:MenuCallback, + \} +endfunction + +function! s:ExecuteGetCodeFix(linter, range, MenuCallback) abort + let l:buffer = bufnr('') + + if a:range == 0 + let [l:line, l:column] = getpos('.')[1:2] + let l:end_line = l:line + let l:end_column = l:column + + " Expand the range to cover the current word, if there is one. + let l:cword = expand('') + + if !empty(l:cword) + let l:search_pos = searchpos('\V' . l:cword, 'bn', l:line) + + if l:search_pos != [0, 0] + let l:column = l:search_pos[1] + let l:end_column = l:column + len(l:cword) - 1 + endif + endif + elseif mode() is# 'v' || mode() is# "\" + " You need to get the start and end in a different way when you're in + " visual mode. + let [l:line, l:column] = getpos('v')[1:2] + let [l:end_line, l:end_column] = getpos('.')[1:2] + else + let [l:line, l:column] = getpos("'<")[1:2] + let [l:end_line, l:end_column] = getpos("'>")[1:2] + endif + + let l:column = max([min([l:column, len(getline(l:line))]), 1]) + let l:end_column = min([l:end_column, len(getline(l:end_line))]) + + let l:Callback = function( + \ 's:OnReady', [l:line, l:column, l:end_line, l:end_column, a:MenuCallback] + \) + + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#codefix#Execute(range, ...) abort + if a:0 > 1 + throw 'Too many arguments' + endif + + let l:MenuCallback = get(a:000, 0, v:null) + let l:lsp_linters = [] + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + if l:MenuCallback is v:null + call s:message('No active LSPs') + else + call l:MenuCallback({}, []) + endif + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteGetCodeFix(l:lsp_linter, a:range, l:MenuCallback) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/command.vim b/sources_non_forked/ale/autoload/ale/command.vim new file mode 100644 index 00000000..c9dc8d94 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/command.vim @@ -0,0 +1,473 @@ +" Author: w0rp +" Description: Functions for formatting command strings, running commands, and +" managing files during linting and fixing cycles. + +" This dictionary holds lists of files and directories to remove later. +if !exists('s:buffer_data') + let s:buffer_data = {} +endif + +" The regular expression used for formatting filenames with modifiers. +let s:path_format_regex = '\v\%s(%(:h|:t|:r|:e)*)' + +" Used to get the data in tests. +function! ale#command#GetData() abort + return deepcopy(s:buffer_data) +endfunction + +function! ale#command#ClearData() abort + let s:buffer_data = {} +endfunction + +function! ale#command#InitData(buffer) abort + if !has_key(s:buffer_data, a:buffer) + let s:buffer_data[a:buffer] = { + \ 'jobs': {}, + \ 'file_list': [], + \ 'directory_list': [], + \} + endif +endfunction + +" Set the cwd for commands that are about to run. +" Used internally. +function! ale#command#SetCwd(buffer, cwd) abort + call ale#command#InitData(a:buffer) + let s:buffer_data[a:buffer].cwd = a:cwd +endfunction + +function! ale#command#ResetCwd(buffer) abort + if has_key(s:buffer_data, a:buffer) + let s:buffer_data[a:buffer].cwd = v:null + endif +endfunction + +function! ale#command#ManageFile(buffer, file) abort + call ale#command#InitData(a:buffer) + call add(s:buffer_data[a:buffer].file_list, a:file) +endfunction + +function! ale#command#ManageDirectory(buffer, directory) abort + call ale#command#InitData(a:buffer) + call add(s:buffer_data[a:buffer].directory_list, a:directory) +endfunction + +function! ale#command#CreateFile(buffer) abort + " This variable can be set to 1 in tests to stub this out. + if get(g:, 'ale_create_dummy_temporary_file') + return 'TEMP' + endif + + let l:temporary_file = ale#util#Tempname() + call ale#command#ManageFile(a:buffer, l:temporary_file) + + return l:temporary_file +endfunction + +" Create a new temporary directory and manage it in one go. +function! ale#command#CreateDirectory(buffer) abort + " This variable can be set to 1 in tests to stub this out. + if get(g:, 'ale_create_dummy_temporary_file') + return 'TEMP_DIR' + endif + + let l:temporary_directory = ale#util#Tempname() + " Create the temporary directory for the file, unreadable by 'other' + " users. + call mkdir(l:temporary_directory, '', 0750) + call ale#command#ManageDirectory(a:buffer, l:temporary_directory) + + return l:temporary_directory +endfunction + +function! ale#command#RemoveManagedFiles(buffer) abort + let l:info = get(s:buffer_data, a:buffer, {}) + + if !empty(l:info) && empty(l:info.jobs) + " We can't delete anything in a sandbox, so wait until we escape from + " it to delete temporary files and directories. + if ale#util#InSandbox() + return + endif + + " Delete files with a call akin to a plan `rm` command. + for l:filename in l:info.file_list + call delete(l:filename) + endfor + + " Delete directories like `rm -rf`. + " Directories are handled differently from files, so paths that are + " intended to be single files can be set up for automatic deletion + " without accidentally deleting entire directories. + for l:directory in l:info.directory_list + call delete(l:directory, 'rf') + endfor + + call remove(s:buffer_data, a:buffer) + endif +endfunction + +function! ale#command#CreateTempFile(buffer, temporary_file, input) abort + if empty(a:temporary_file) + " There is no file, so we didn't create anything. + return 0 + endif + + " Use an existing list of lines of input if we have it, or get the lines + " from the file. + let l:lines = a:input isnot v:null ? a:input : getbufline(a:buffer, 1, '$') + + let l:temporary_directory = fnamemodify(a:temporary_file, ':h') + " Create the temporary directory for the file, unreadable by 'other' + " users. + call mkdir(l:temporary_directory, '', 0750) + " Automatically delete the directory later. + call ale#command#ManageDirectory(a:buffer, l:temporary_directory) + " Write the buffer out to a file. + call ale#util#Writefile(a:buffer, l:lines, a:temporary_file) + + return 1 +endfunction + +function! s:TemporaryFilename(buffer) abort + let l:filename = fnamemodify(bufname(a:buffer), ':t') + + if empty(l:filename) + " If the buffer's filename is empty, create a dummy filename. + let l:ft = getbufvar(a:buffer, '&filetype') + let l:filename = 'file' . ale#filetypes#GuessExtension(l:ft) + endif + + " Create a temporary filename, / + " The file itself will not be created by this function. + return ale#util#Tempname() . (has('win32') ? '\' : '/') . l:filename +endfunction + +" Given part of a command, replace any % with %%, so that no characters in +" the string will be replaced with filenames, etc. +function! ale#command#EscapeCommandPart(command_part) abort + return substitute(a:command_part, '%', '%%', 'g') +endfunction + +" Format a filename, converting it with filename mappings, if non-empty, +" and escaping it for putting into a command string. +" +" The filename can be modified. +function! s:FormatFilename(filename, mappings, modifiers) abort + let l:filename = a:filename + + if !empty(a:mappings) + let l:filename = ale#filename_mapping#Map(l:filename, a:mappings) + endif + + if !empty(a:modifiers) + let l:filename = fnamemodify(l:filename, a:modifiers) + endif + + return ale#Escape(l:filename) +endfunction + +" Produce a command prefix to check to a particular directory for a command. +" %s format markers with filename-modifiers can be used as the directory, and +" will be returned verbatim for formatting in paths relative to files. +function! ale#command#CdString(directory) abort + let l:match = matchstrpos(a:directory, s:path_format_regex) + " Do not escape the directory here if it's a valid format string. + " This allows us to use sequences like %s:h, %s:h:h, etc. + let l:directory = l:match[1:] == [0, len(a:directory)] + \ ? a:directory + \ : ale#Escape(a:directory) + + if has('win32') + return 'cd /d ' . l:directory . ' && ' + endif + + return 'cd ' . l:directory . ' && ' +endfunction + +" Given a command string, replace every... +" %s -> with the current filename +" %t -> with the name of an unused file in a temporary directory +" %% -> with a literal % +function! ale#command#FormatCommand( +\ buffer, +\ executable, +\ command, +\ pipe_file_if_needed, +\ input, +\ cwd, +\ mappings, +\) abort + let l:temporary_file = '' + let l:command = a:command + + if !empty(a:cwd) + let l:command = ale#command#CdString(a:cwd) . l:command + endif + + " First replace all uses of %%, used for literal percent characters, + " with an ugly string. + let l:command = substitute(l:command, '%%', '<>', 'g') + + " Replace %e with the escaped executable, if available. + if !empty(a:executable) && l:command =~# '%e' + let l:command = substitute(l:command, '%e', '\=ale#Escape(a:executable)', 'g') + endif + + " Replace all %s occurrences in the string with the name of the current + " file. + if l:command =~# '%s' + let l:filename = fnamemodify(bufname(a:buffer), ':p') + let l:command = substitute( + \ l:command, + \ s:path_format_regex, + \ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))', + \ 'g' + \) + endif + + if a:input isnot v:false && l:command =~# '%t' + " Create a temporary filename, / + " The file itself will not be created by this function. + let l:temporary_file = s:TemporaryFilename(a:buffer) + let l:command = substitute( + \ l:command, + \ '\v\%t(%(:h|:t|:r|:e)*)', + \ '\=s:FormatFilename(l:temporary_file, a:mappings, submatch(1))', + \ 'g' + \) + endif + + " Finish formatting so %% becomes %. + let l:command = substitute(l:command, '<>', '%', 'g') + + if a:pipe_file_if_needed && empty(l:temporary_file) + " If we are to send the Vim buffer to a command, we'll do it + " in the shell. We'll write out the file to a temporary file, + " and then read it back in, in the shell. + let l:temporary_file = s:TemporaryFilename(a:buffer) + let l:command = l:command . ' < ' . ale#Escape(l:temporary_file) + endif + + let l:file_created = ale#command#CreateTempFile( + \ a:buffer, + \ l:temporary_file, + \ a:input, + \) + + return [l:temporary_file, l:command, l:file_created] +endfunction + +function! ale#command#StopJobs(buffer, job_type) abort + let l:info = get(s:buffer_data, a:buffer, {}) + + if !empty(l:info) + let l:new_map = {} + + for [l:job_id, l:job_type] in items(l:info.jobs) + let l:job_id = str2nr(l:job_id) + + if a:job_type is# 'all' || a:job_type is# l:job_type + call ale#job#Stop(l:job_id) + else + let l:new_map[l:job_id] = l:job_type + endif + endfor + + let l:info.jobs = l:new_map + endif +endfunction + +function! s:GatherOutput(line_list, job_id, line) abort + call add(a:line_list, a:line) +endfunction + +function! s:ExitCallback(buffer, line_list, Callback, data) abort + if !has_key(s:buffer_data, a:buffer) + return + endif + + let l:jobs = s:buffer_data[a:buffer].jobs + + if !has_key(l:jobs, a:data.job_id) + return + endif + + let l:job_type = remove(l:jobs, a:data.job_id) + + if g:ale_history_enabled + call ale#history#SetExitCode(a:buffer, a:data.job_id, a:data.exit_code) + + " Log the output of the command for ALEInfo if we should. + if g:ale_history_log_output && a:data.log_output is 1 + call ale#history#RememberOutput( + \ a:buffer, + \ a:data.job_id, + \ a:line_list[:] + \) + endif + endif + + " If the callback starts any new jobs, use the same job type for them. + call setbufvar(a:buffer, 'ale_job_type', l:job_type) + let l:value = a:Callback(a:buffer, a:line_list, { + \ 'exit_code': a:data.exit_code, + \ 'temporary_file': a:data.temporary_file, + \}) + + let l:result = a:data.result + let l:result.value = l:value + + " Set the default cwd for this buffer in this call stack. + call ale#command#SetCwd(a:buffer, l:result.cwd) + + try + if get(l:result, 'result_callback', v:null) isnot v:null + call call(l:result.result_callback, [l:value]) + endif + finally + call ale#command#ResetCwd(a:buffer) + endtry +endfunction + +function! ale#command#Run(buffer, command, Callback, ...) abort + let l:options = get(a:000, 0, {}) + + if len(a:000) > 1 + throw 'Too many arguments!' + endif + + let l:output_stream = get(l:options, 'output_stream', 'stdout') + let l:line_list = [] + let l:cwd = get(l:options, 'cwd', v:null) + + if l:cwd is v:null + " Default the working directory to whatever it was for the last + " command run in the chain. + let l:cwd = get(get(s:buffer_data, a:buffer, {}), 'cwd', v:null) + endif + + let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand( + \ a:buffer, + \ get(l:options, 'executable', ''), + \ a:command, + \ get(l:options, 'read_buffer', 0), + \ get(l:options, 'input', v:null), + \ l:cwd, + \ get(l:options, 'filename_mappings', []), + \) + let l:command = ale#job#PrepareCommand(a:buffer, l:command) + let l:job_options = { + \ 'exit_cb': {job_id, exit_code -> s:ExitCallback( + \ a:buffer, + \ l:line_list, + \ a:Callback, + \ { + \ 'job_id': job_id, + \ 'exit_code': exit_code, + \ 'temporary_file': l:temporary_file, + \ 'log_output': get(l:options, 'log_output', 1), + \ 'result': l:result, + \ } + \ )}, + \ 'mode': 'nl', + \} + + if l:output_stream is# 'stdout' + let l:job_options.out_cb = function('s:GatherOutput', [l:line_list]) + elseif l:output_stream is# 'stderr' + let l:job_options.err_cb = function('s:GatherOutput', [l:line_list]) + elseif l:output_stream is# 'both' + let l:job_options.out_cb = function('s:GatherOutput', [l:line_list]) + let l:job_options.err_cb = function('s:GatherOutput', [l:line_list]) + endif + + let l:status = 'failed' + + if get(g:, 'ale_run_synchronously') == 1 + if get(g:, 'ale_emulate_job_failure') == 1 + let l:job_id = 0 + else + " Generate a fake job ID for tests. + let s:fake_job_id = get(s:, 'fake_job_id', 0) + 1 + let l:job_id = s:fake_job_id + endif + elseif has('win32') + let l:job_id = ale#job#StartWithCmd(l:command, l:job_options) + else + let l:job_id = ale#job#Start(l:command, l:job_options) + endif + + if l:job_id + let l:status = 'started' + let l:job_type = getbufvar(a:buffer, 'ale_job_type', 'all') + + call ale#command#InitData(a:buffer) + let s:buffer_data[a:buffer].jobs[l:job_id] = l:job_type + endif + + if g:ale_history_enabled + call ale#history#Add(a:buffer, l:status, l:job_id, l:command) + endif + + if !l:job_id + return 0 + endif + + " We'll return this Dictionary. A `result_callback` can be assigned to it + " later for capturing the result of a:Callback. + " + " The `_deferred_job_id` is used for both checking the type of object, and + " for checking the job ID and status. + " + " The cwd is kept and used as the default value for the next command in + " the chain. + " + " The original command here is used in tests. + let l:result = { + \ '_deferred_job_id': l:job_id, + \ 'executable': get(l:options, 'executable', ''), + \ 'cwd': l:cwd, + \ 'command': a:command, + \} + + if get(g:, 'ale_run_synchronously') == 1 && l:job_id + if !exists('g:ale_run_synchronously_callbacks') + let g:ale_run_synchronously_callbacks = [] + endif + + if get(g:, 'ale_run_synchronously_emulate_commands', 0) + call add( + \ g:ale_run_synchronously_callbacks, + \ {exit_code, output -> [ + \ extend(l:line_list, output), + \ l:job_options.exit_cb(l:job_id, exit_code), + \ ]} + \) + else + " Run a command synchronously if this test option is set. + call extend(l:line_list, systemlist( + \ type(l:command) is v:t_list + \ ? join(l:command[0:1]) . ' ' . ale#Escape(l:command[2]) + \ : l:command + \)) + + " Don't capture output when the callbacks aren't set. + if !has_key(l:job_options, 'out_cb') + \&& !has_key(l:job_options, 'err_cb') + let l:line_list = [] + endif + + call add( + \ g:ale_run_synchronously_callbacks, + \ {-> l:job_options.exit_cb(l:job_id, v:shell_error)} + \) + endif + endif + + return l:result +endfunction + +function! ale#command#IsDeferred(value) abort + return type(a:value) is v:t_dict && has_key(a:value, '_deferred_job_id') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion.vim b/sources_non_forked/ale/autoload/ale/completion.vim new file mode 100644 index 00000000..c05ca53d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/completion.vim @@ -0,0 +1,1070 @@ +" Author: w0rp +" Description: Completion support for LSP linters +scriptencoding utf-8 + +" The omnicompletion menu is shown through a special Plug mapping which is +" only valid in Insert mode. This way, feedkeys() won't send these keys if you +" quit Insert mode quickly enough. +inoremap (ale_show_completion_menu) +" If we hit the key sequence in normal mode, then we won't show the menu, so +" we should restore the old settings right away. +nnoremap (ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions() +cnoremap (ale_show_completion_menu) +vnoremap (ale_show_completion_menu) +onoremap (ale_show_completion_menu) + +let g:ale_completion_delay = get(g:, 'ale_completion_delay', 100) +let g:ale_completion_excluded_words = get(g:, 'ale_completion_excluded_words', []) +let g:ale_completion_max_suggestions = get(g:, 'ale_completion_max_suggestions', 50) +let g:ale_completion_autoimport = get(g:, 'ale_completion_autoimport', 1) +let g:ale_completion_tsserver_remove_warnings = get(g:, 'ale_completion_tsserver_remove_warnings', 0) + +let s:timer_id = -1 +let s:last_done_pos = [] + +" CompletionItemKind values from the LSP protocol. +let g:ale_lsp_types = { +\ 1: 'text', +\ 2: 'method', +\ 3: 'function', +\ 4: 'constructor', +\ 5: 'field', +\ 6: 'variable', +\ 7: 'class', +\ 8: 'interface', +\ 9: 'module', +\ 10: 'property', +\ 11: 'unit', +\ 12: 'value', +\ 13: 'enum', +\ 14: 'keyword', +\ 15: 'snippet', +\ 16: 'color', +\ 17: 'file', +\ 18: 'reference', +\ 19: 'folder', +\ 20: 'enum_member', +\ 21: 'constant', +\ 22: 'struct', +\ 23: 'event', +\ 24: 'operator', +\ 25: 'type_parameter', +\ } + +" from https://github.com/microsoft/TypeScript/blob/29becf05012bfa7ba20d50b0d16813971e46b8a6/lib/protocol.d.ts#L2472 +let g:ale_tsserver_types = { +\ 'warning': 'text', +\ 'keyword': 'keyword', +\ 'script': 'file', +\ 'module': 'module', +\ 'class': 'class', +\ 'local class': 'class', +\ 'interface': 'interface', +\ 'type': 'class', +\ 'enum': 'enum', +\ 'enum member': 'enum_member', +\ 'var': 'variable', +\ 'local var': 'variable', +\ 'function': 'function', +\ 'local function': 'function', +\ 'method': 'method', +\ 'getter': 'property', +\ 'setter': 'method', +\ 'property': 'property', +\ 'constructor': 'constructor', +\ 'call': 'method', +\ 'index': 'index', +\ 'construct': 'constructor', +\ 'parameter': 'parameter', +\ 'type parameter': 'type_parameter', +\ 'primitive type': 'unit', +\ 'label': 'text', +\ 'alias': 'class', +\ 'const': 'constant', +\ 'let': 'variable', +\ 'directory': 'folder', +\ 'external module name': 'text', +\ 'JSX attribute': 'parameter', +\ 'string': 'text' +\ } + +" For compatibility reasons, we only use built in VIM completion kinds +" See :help complete-items for Vim completion kinds +let g:ale_completion_symbols = get(g:, 'ale_completion_symbols', { +\ 'text': 'v', +\ 'method': 'f', +\ 'function': 'f', +\ 'constructor': 'f', +\ 'field': 'm', +\ 'variable': 'v', +\ 'class': 't', +\ 'interface': 't', +\ 'module': 'd', +\ 'property': 'm', +\ 'unit': 'v', +\ 'value': 'v', +\ 'enum': 't', +\ 'keyword': 'v', +\ 'snippet': 'v', +\ 'color': 'v', +\ 'file': 'v', +\ 'reference': 'v', +\ 'folder': 'v', +\ 'enum_member': 'm', +\ 'constant': 'm', +\ 'struct': 't', +\ 'event': 'v', +\ 'operator': 'f', +\ 'type_parameter': 'p', +\ '': 'v' +\ }) + +let s:LSP_INSERT_TEXT_FORMAT_PLAIN = 1 +let s:LSP_INSERT_TEXT_FORMAT_SNIPPET = 2 + +let s:lisp_regex = '\v[a-zA-Z_\-][a-zA-Z_\-0-9]*$' + +" Regular expressions for checking the characters in the line before where +" the insert cursor is. If one of these matches, we'll check for completions. +let s:should_complete_map = { +\ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$', +\ 'clojure': s:lisp_regex, +\ 'lisp': s:lisp_regex, +\ 'racket': '\k\+$', +\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$', +\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$', +\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$', +\ 'c': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|-\>$', +\} + +" Regular expressions for finding the start column to replace with completion. +let s:omni_start_map = { +\ '': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$', +\ 'racket': '\k\+$', +\} + +" A map of exact characters for triggering LSP completions. Do not forget to +" update self.input_patterns in ale.py in updating entries in this map. +let s:trigger_character_map = { +\ '': ['.'], +\ 'typescript': ['.', '''', '"'], +\ 'rust': ['.', '::'], +\ 'cpp': ['.', '::', '->'], +\ 'c': ['.', '->'], +\} + +function! s:GetFiletypeValue(map, filetype) abort + for l:part in reverse(split(a:filetype, '\.')) + let l:regex = get(a:map, l:part, []) + + if !empty(l:regex) + return l:regex + endif + endfor + + " Use the default regex for other files. + return a:map[''] +endfunction + +" Check if we should look for completions for a language. +function! ale#completion#GetPrefix(filetype, line, column) abort + let l:regex = s:GetFiletypeValue(s:should_complete_map, a:filetype) + + " The column we're using completions for is where we are inserting text, + " like so: + " abc + " ^ + " So we need check the text in the column before that position. + return matchstr(getline(a:line)[: a:column - 2], l:regex) +endfunction + +function! ale#completion#GetTriggerCharacter(filetype, prefix) abort + if empty(a:prefix) + return '' + endif + + let l:char_list = s:GetFiletypeValue(s:trigger_character_map, a:filetype) + + if index(l:char_list, a:prefix) >= 0 + return a:prefix + endif + + return '' +endfunction + +function! ale#completion#Filter( +\ buffer, +\ filetype, +\ suggestions, +\ prefix, +\ exact_prefix_match, +\) abort + let l:excluded_words = ale#Var(a:buffer, 'completion_excluded_words') + + if empty(a:prefix) + let l:filtered_suggestions = a:suggestions + else + let l:triggers = s:GetFiletypeValue(s:trigger_character_map, a:filetype) + + " For completing... + " foo. + " ^ + " We need to include all of the given suggestions. + if index(l:triggers, a:prefix) >= 0 || empty(a:prefix) + let l:filtered_suggestions = a:suggestions + else + let l:filtered_suggestions = [] + + " Filter suggestions down to those starting with the prefix we + " used for finding suggestions in the first place. + " + " Some completion tools will include suggestions which don't even + " start with the characters we have already typed. + for l:item in a:suggestions + " A List of String values or a List of completion item + " Dictionaries is accepted here. + let l:word = type(l:item) is v:t_string ? l:item : l:item.word + + if a:exact_prefix_match + " Add suggestions if the word is an exact match. + if l:word is# a:prefix + call add(l:filtered_suggestions, l:item) + endif + else + " Add suggestions if the suggestion starts with a + " case-insensitive match for the prefix. + if l:word[: len(a:prefix) - 1] is? a:prefix + call add(l:filtered_suggestions, l:item) + endif + endif + endfor + endif + endif + + if !empty(l:excluded_words) + " Copy the List if needed. We don't want to modify the argument. + " We shouldn't make a copy if we don't need to. + if l:filtered_suggestions is a:suggestions + let l:filtered_suggestions = copy(a:suggestions) + endif + + " Remove suggestions with words in the exclusion List. + call filter( + \ l:filtered_suggestions, + \ 'index(l:excluded_words, type(v:val) is v:t_string ? v:val : v:val.word) < 0', + \) + endif + + return l:filtered_suggestions +endfunction + +function! s:ReplaceCompletionOptions(source) abort + " Remember the old omnifunc value, if there is one. + " If we don't store an old one, we'll just never reset the option. + " This will stop some random exceptions from appearing. + if !exists('b:ale_old_omnifunc') && !empty(&l:omnifunc) + let b:ale_old_omnifunc = &l:omnifunc + endif + + let &l:omnifunc = 'ale#completion#AutomaticOmniFunc' + + if a:source is# 'ale-automatic' + if !exists('b:ale_old_completeopt') + let b:ale_old_completeopt = &l:completeopt + endif + + let l:opt_list = split(&l:completeopt, ',') + " The menu and noinsert options must be set, or automatic completion + " will be annoying. + let l:new_opt_list = ['menu', 'menuone', 'noinsert'] + + " Permit some other completion options, provided users have set them. + for l:opt in ['preview', 'popup', 'noselect'] + if index(l:opt_list, l:opt) >= 0 + call add(l:new_opt_list, l:opt) + endif + endfor + + let &l:completeopt = join(l:new_opt_list, ',') + endif +endfunction + +function! ale#completion#RestoreCompletionOptions() abort + " Reset settings when completion is done. + if exists('b:ale_old_omnifunc') + if b:ale_old_omnifunc isnot# 'pythoncomplete#Complete' + let &l:omnifunc = b:ale_old_omnifunc + endif + + unlet b:ale_old_omnifunc + endif + + if exists('b:ale_old_completeopt') + let &l:completeopt = b:ale_old_completeopt + unlet b:ale_old_completeopt + endif +endfunction + +function! ale#completion#GetCompletionPosition() abort + if !exists('b:ale_completion_info') + return 0 + endif + + let l:line = b:ale_completion_info.line + let l:column = b:ale_completion_info.column + let l:regex = s:GetFiletypeValue(s:omni_start_map, &filetype) + let l:up_to_column = getline(l:line)[: l:column - 2] + let l:match = matchstr(l:up_to_column, l:regex) + + return l:column - len(l:match) - 1 +endfunction + +function! ale#completion#GetCompletionPositionForDeoplete(input) abort + return match(a:input, '\k*$') +endfunction + +function! ale#completion#GetCompletionResult() abort + if exists('b:ale_completion_result') + return b:ale_completion_result + endif + + return v:null +endfunction + +function! ale#completion#AutomaticOmniFunc(findstart, base) abort + if a:findstart + return ale#completion#GetCompletionPosition() + else + let l:result = ale#completion#GetCompletionResult() + + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' || l:source is# 'ale-manual' + call s:ReplaceCompletionOptions(l:source) + endif + + return l:result isnot v:null ? l:result : [] + endif +endfunction + +function! s:OpenCompletionMenu(...) abort + if !&l:paste + call ale#util#FeedKeys("\(ale_show_completion_menu)") + endif +endfunction + +function! ale#completion#Show(result) abort + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if ale#util#Mode() isnot# 'i' && l:source isnot# 'ale-import' + return + endif + + " Set the list in the buffer. + let b:ale_completion_result = a:result + + " Don't try to open the completion menu if there's nothing to show. + if empty(b:ale_completion_result) + if l:source is# 'ale-import' + " If we ran completion from :ALEImport, + " tell the user that nothing is going to happen. + call s:message('No possible imports found.') + endif + + return + endif + + " Replace completion options shortly before opening the menu. + if l:source is# 'ale-automatic' || l:source is# 'ale-manual' + call s:ReplaceCompletionOptions(l:source) + + call timer_start(0, function('s:OpenCompletionMenu')) + endif + + if l:source is# 'ale-callback' + call b:CompleteCallback(b:ale_completion_result) + endif + + if l:source is# 'ale-import' + call ale#completion#HandleUserData(b:ale_completion_result[0]) + + let l:text_changed = '' . g:ale_lint_on_text_changed + + " Check the buffer again right away, if linting is enabled. + if g:ale_enabled + \&& ( + \ l:text_changed is# '1' + \ || l:text_changed is# 'always' + \ || l:text_changed is# 'normal' + \ || l:text_changed is# 'insert' + \) + call ale#Queue(0, '') + endif + endif +endfunction + +function! ale#completion#GetAllTriggers() abort + return deepcopy(s:trigger_character_map) +endfunction + +function! ale#completion#GetCompletionKind(kind) abort + let l:lsp_symbol = get(g:ale_lsp_types, a:kind, '') + + if !empty(l:lsp_symbol) + return l:lsp_symbol + endif + + return get(g:ale_tsserver_types, a:kind, '') +endfunction + +function! ale#completion#GetCompletionSymbols(kind) abort + let l:kind = ale#completion#GetCompletionKind(a:kind) + let l:symbol = get(g:ale_completion_symbols, l:kind, '') + + if !empty(l:symbol) + return l:symbol + endif + + return get(g:ale_completion_symbols, '', 'v') +endfunction + +function! s:CompletionStillValid(request_id) abort + let [l:line, l:column] = getpos('.')[1:2] + + return has_key(b:, 'ale_completion_info') + \&& ( + \ ale#util#Mode() is# 'i' + \ || b:ale_completion_info.source is# 'ale-import' + \) + \&& b:ale_completion_info.request_id == a:request_id + \&& b:ale_completion_info.line == l:line + \&& ( + \ b:ale_completion_info.column == l:column + \ || b:ale_completion_info.source is# 'ale-omnifunc' + \ || b:ale_completion_info.source is# 'ale-callback' + \ || b:ale_completion_info.source is# 'ale-import' + \) +endfunction + +function! ale#completion#ParseTSServerCompletions(response) abort + let l:names = [] + + for l:suggestion in a:response.body + let l:kind = get(l:suggestion, 'kind', '') + + if g:ale_completion_tsserver_remove_warnings == 0 || l:kind isnot# 'warning' + call add(l:names, { + \ 'word': l:suggestion.name, + \ 'source': get(l:suggestion, 'source', ''), + \}) + endif + endfor + + return l:names +endfunction + +function! ale#completion#ParseTSServerCompletionEntryDetails(response) abort + let l:buffer = bufnr('') + let l:results = [] + let l:names_with_details = [] + let l:info = get(b:, 'ale_completion_info', {}) + + for l:suggestion in a:response.body + let l:displayParts = [] + let l:local_name = v:null + + for l:action in get(l:suggestion, 'codeActions', []) + call add(l:displayParts, l:action.description . ' ') + endfor + + for l:part in l:suggestion.displayParts + " Stop on stop on line breaks for the menu. + if get(l:part, 'kind') is# 'lineBreak' + break + endif + + if get(l:part, 'kind') is# 'localName' + let l:local_name = l:part.text + endif + + call add(l:displayParts, l:part.text) + endfor + + " Each one of these parts has 'kind' properties + let l:documentationParts = [] + + for l:part in get(l:suggestion, 'documentation', []) + call add(l:documentationParts, l:part.text) + endfor + + " See :help complete-items + let l:result = { + \ 'word': ( + \ l:suggestion.name is# 'default' + \ && l:suggestion.kind is# 'alias' + \ && !empty(l:local_name) + \ ? l:local_name + \ : l:suggestion.name + \ ), + \ 'kind': ale#completion#GetCompletionSymbols(l:suggestion.kind), + \ 'icase': 1, + \ 'menu': join(l:displayParts, ''), + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, + \ 'info': join(l:documentationParts, ''), + \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} + + if has_key(l:suggestion, 'codeActions') + let l:user_data.code_actions = l:suggestion.codeActions + endif + + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif + endfor + + let l:names = getbufvar(l:buffer, 'ale_tsserver_completion_names', []) + + if !empty(l:names) && len(l:names) != len(l:results) + let l:names_with_details = map(copy(l:results), 'v:val.word') + let l:missing_names = filter( + \ copy(l:names), + \ 'index(l:names_with_details, v:val.word) < 0', + \) + + for l:name in l:missing_names + call add(l:results, { + \ 'word': l:name.word, + \ 'kind': 'v', + \ 'icase': 1, + \ 'menu': '', + \ 'info': '', + \ 'user_data': json_encode({'_ale_completion_item': 1}), + \}) + endfor + endif + + return l:results +endfunction + +function! ale#completion#NullFilter(buffer, item) abort + return 1 +endfunction + +function! ale#completion#ParseLSPCompletions(response) abort + let l:buffer = bufnr('') + let l:info = get(b:, 'ale_completion_info', {}) + let l:Filter = get(l:info, 'completion_filter', v:null) + + if l:Filter is v:null + let l:Filter = function('ale#completion#NullFilter') + else + let l:Filter = ale#util#GetFunction(l:Filter) + endif + + let l:item_list = [] + + if type(get(a:response, 'result')) is v:t_list + let l:item_list = a:response.result + elseif type(get(a:response, 'result')) is v:t_dict + \&& type(get(a:response.result, 'items')) is v:t_list + let l:item_list = a:response.result.items + endif + + let l:results = [] + + for l:item in l:item_list + if !call(l:Filter, [l:buffer, l:item]) + continue + endif + + if get(l:item, 'insertTextFormat', s:LSP_INSERT_TEXT_FORMAT_PLAIN) is s:LSP_INSERT_TEXT_FORMAT_PLAIN + \&& type(get(l:item, 'textEdit')) is v:t_dict + let l:text = l:item.textEdit.newText + elseif type(get(l:item, 'insertText')) is v:t_string + let l:text = l:item.insertText + else + let l:text = l:item.label + endif + + let l:word = matchstr(l:text, '\v^[^(]+') + + if empty(l:word) + continue + endif + + " Don't use LSP items with additional text edits when autoimport for + " completions is turned off. + if !empty(get(l:item, 'additionalTextEdits')) + \&& !( + \ get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport + \) + continue + endif + + let l:doc = get(l:item, 'documentation', '') + + if type(l:doc) is v:t_dict && has_key(l:doc, 'value') + let l:doc = l:doc.value + endif + + " Collapse whitespaces and line breaks into a single space. + let l:detail = substitute(get(l:item, 'detail', ''), '\_s\+', ' ', 'g') + + let l:result = { + \ 'word': l:word, + \ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')), + \ 'icase': 1, + \ 'menu': l:detail, + \ 'dup': get(l:info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, + \ 'info': (type(l:doc) is v:t_string ? l:doc : ''), + \} + " This flag is used to tell if this completion came from ALE or not. + let l:user_data = {'_ale_completion_item': 1} + + if has_key(l:item, 'additionalTextEdits') + \ && l:item.additionalTextEdits isnot v:null + let l:text_changes = [] + + for l:edit in l:item.additionalTextEdits + call add(l:text_changes, { + \ 'start': { + \ 'line': l:edit.range.start.line + 1, + \ 'offset': l:edit.range.start.character + 1, + \ }, + \ 'end': { + \ 'line': l:edit.range.end.line + 1, + \ 'offset': l:edit.range.end.character + 1, + \ }, + \ 'newText': l:edit.newText, + \}) + endfor + + if !empty(l:text_changes) + let l:user_data.code_actions = [{ + \ 'description': 'completion', + \ 'changes': [ + \ { + \ 'fileName': expand('#' . l:buffer . ':p'), + \ 'textChanges': l:text_changes, + \ }, + \ ], + \}] + endif + endif + + let l:result.user_data = json_encode(l:user_data) + + " Include this item if we'll accept any items, + " or if we only want items with additional edits, and this has them. + if !get(l:info, 'additional_edits_only', 0) + \|| has_key(l:user_data, 'code_actions') + call add(l:results, l:result) + endif + endfor + + if has_key(l:info, 'prefix') + let l:results = ale#completion#Filter( + \ l:buffer, + \ &filetype, + \ l:results, + \ l:info.prefix, + \ get(l:info, 'additional_edits_only', 0), + \) + endif + + return l:results[: g:ale_completion_max_suggestions - 1] +endfunction + +function! ale#completion#HandleTSServerResponse(conn_id, response) abort + if !s:CompletionStillValid(get(a:response, 'request_seq')) + return + endif + + if !has_key(a:response, 'body') + return + endif + + let l:buffer = bufnr('') + let l:command = get(a:response, 'command', '') + + if l:command is# 'completions' + let l:names = ale#completion#Filter( + \ l:buffer, + \ &filetype, + \ ale#completion#ParseTSServerCompletions(a:response), + \ b:ale_completion_info.prefix, + \ get(b:ale_completion_info, 'additional_edits_only', 0), + \)[: g:ale_completion_max_suggestions - 1] + + " We need to remember some names for tsserver, as it doesn't send + " details back for everything we send. + call setbufvar(l:buffer, 'ale_tsserver_completion_names', l:names) + + if empty(l:names) + " Response with no results now and skip making a redundant request + " for nothing. + call ale#completion#Show([]) + else + let l:identifiers = [] + + for l:name in l:names + let l:identifier = { + \ 'name': l:name.word, + \} + let l:source = get(l:name, 'source', '') + + " Empty source results in no details for the completed item + if !empty(l:source) + call extend(l:identifier, { 'source': l:source }) + endif + + call add(l:identifiers, l:identifier) + endfor + + let b:ale_completion_info.request_id = ale#lsp#Send( + \ b:ale_completion_info.conn_id, + \ ale#lsp#tsserver_message#CompletionEntryDetails( + \ l:buffer, + \ b:ale_completion_info.line, + \ b:ale_completion_info.column, + \ l:identifiers, + \ ), + \) + endif + elseif l:command is# 'completionEntryDetails' + call ale#completion#Show( + \ ale#completion#ParseTSServerCompletionEntryDetails(a:response), + \) + endif +endfunction + + +function! ale#completion#HandleLSPResponse(conn_id, response) abort + if !s:CompletionStillValid(get(a:response, 'id')) + return + endif + + call ale#completion#Show( + \ ale#completion#ParseLSPCompletions(a:response), + \) +endfunction + +function! s:OnReady(linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'completion') + return + endif + + let l:buffer = a:lsp_details.buffer + + " If we have sent a completion request already, don't send another. + if b:ale_completion_info.request_id + return + endif + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#completion#HandleTSServerResponse') + \ : function('ale#completion#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + if get(g:, 'ale_completion_tsserver_autoimport') is 1 + " no-custom-checks + echom '`g:ale_completion_tsserver_autoimport` is deprecated. Use `g:ale_completion_autoimport` instead.' + endif + + let l:message = ale#lsp#tsserver_message#Completions( + \ l:buffer, + \ b:ale_completion_info.line, + \ b:ale_completion_info.column, + \ b:ale_completion_info.prefix, + \ get(b:ale_completion_info, 'additional_edits_only', 0) + \ || g:ale_completion_autoimport, + \) + else + " Send a message saying the buffer has changed first, otherwise + " completions won't know what text is nearby. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + " For LSP completions, we need to clamp the column to the length of + " the line. python-language-server and perhaps others do not implement + " this correctly. + let l:message = ale#lsp#message#Completion( + \ l:buffer, + \ b:ale_completion_info.line, + \ b:ale_completion_info.column, + \ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix), + \) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + if l:request_id + let b:ale_completion_info.conn_id = l:id + let b:ale_completion_info.request_id = l:request_id + + if has_key(a:linter, 'completion_filter') + let b:ale_completion_info.completion_filter = a:linter.completion_filter + endif + endif +endfunction + +" This function can be called to check if ALE can provide completion data for +" the current buffer. 1 will be returned if there's a potential source of +" completion data ALE can use, and 0 will be returned otherwise. +function! ale#completion#CanProvideCompletions() abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + return 1 + endif + endfor + + return 0 +endfunction + +" This function can be used to manually trigger autocomplete, even when +" g:ale_completion_enabled is set to false +function! ale#completion#GetCompletions(...) abort + let l:source = get(a:000, 0, '') + let l:options = get(a:000, 1, {}) + + if len(a:000) > 2 + throw 'Too many arguments!' + endif + + let l:CompleteCallback = get(l:options, 'callback', v:null) + + if l:CompleteCallback isnot v:null + let b:CompleteCallback = l:CompleteCallback + endif + + if has_key(l:options, 'line') && has_key(l:options, 'column') + " Use a provided line and column, if given. + let l:line = l:options.line + let l:column = l:options.column + else + let [l:line, l:column] = getpos('.')[1:2] + endif + + if has_key(l:options, 'prefix') + let l:prefix = l:options.prefix + else + let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column) + endif + + if l:source is# 'ale-automatic' && empty(l:prefix) + return 0 + endif + + let l:line_length = len(getline('.')) + + let b:ale_completion_info = { + \ 'line': l:line, + \ 'line_length': l:line_length, + \ 'column': l:column, + \ 'prefix': l:prefix, + \ 'conn_id': 0, + \ 'request_id': 0, + \ 'source': l:source, + \} + unlet! b:ale_completion_result + + if has_key(l:options, 'additional_edits_only') + let b:ale_completion_info.additional_edits_only = + \ l:options.additional_edits_only + endif + + let l:buffer = bufnr('') + let l:Callback = function('s:OnReady') + + let l:started = 0 + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) + let l:started = 1 + endif + endif + endfor + + return l:started +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +" This function implements the :ALEImport command. +function! ale#completion#Import() abort + let l:word = expand('') + + if empty(l:word) + call s:message('Nothing to complete at cursor!') + + return + endif + + let [l:line, l:column] = getpos('.')[1:2] + let l:column = searchpos('\V' . escape(l:word, '/\'), 'bnc', l:line)[1] + let l:column = l:column + len(l:word) - 1 + + if l:column isnot 0 + let l:started = ale#completion#GetCompletions('ale-import', { + \ 'line': l:line, + \ 'column': l:column, + \ 'prefix': l:word, + \ 'additional_edits_only': 1, + \}) + + if !l:started + call s:message('No completion providers are available.') + endif + endif +endfunction + +function! ale#completion#OmniFunc(findstart, base) abort + if a:findstart + let l:started = ale#completion#GetCompletions('ale-omnifunc') + + if !l:started + " This is the special value for cancelling completions silently. + " See :help complete-functions + return -3 + endif + + return ale#completion#GetCompletionPosition() + else + let l:result = ale#completion#GetCompletionResult() + + while l:result is v:null && !complete_check() + sleep 2ms + let l:result = ale#completion#GetCompletionResult() + endwhile + + return l:result isnot v:null ? l:result : [] + endif +endfunction + +function! s:TimerHandler(...) abort + if !get(b:, 'ale_completion_enabled', g:ale_completion_enabled) + return + endif + + let s:timer_id = -1 + + let [l:line, l:column] = getpos('.')[1:2] + + " When running the timer callback, we have to be sure that the cursor + " hasn't moved from where it was when we requested completions by typing. + if s:timer_pos == [l:line, l:column] && ale#util#Mode() is# 'i' + call ale#completion#GetCompletions('ale-automatic') + endif +endfunction + +" Stop any completion timer that is queued. This is useful for tests. +function! ale#completion#StopTimer() abort + if s:timer_id != -1 + call timer_stop(s:timer_id) + endif + + let s:timer_id = -1 +endfunction + +function! ale#completion#Queue() abort + if !get(b:, 'ale_completion_enabled', g:ale_completion_enabled) + return + endif + + let s:timer_pos = getpos('.')[1:2] + + if s:timer_pos == s:last_done_pos + " Do not ask for completions if the cursor rests on the position we + " last completed on. + return + endif + + " If we changed the text again while we're still waiting for a response, + " then invalidate the requests before the timer ticks again. + if exists('b:ale_completion_info') + let b:ale_completion_info.request_id = 0 + endif + + call ale#completion#StopTimer() + + let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler')) +endfunction + +function! ale#completion#HandleUserData(completed_item) abort + let l:user_data_json = get(a:completed_item, 'user_data', '') + let l:user_data = type(l:user_data_json) is v:t_dict + \ ? l:user_data_json + \ : ale#util#FuzzyJSONDecode(l:user_data_json, {}) + + if !has_key(l:user_data, '_ale_completion_item') + return + endif + + let l:source = get(get(b:, 'ale_completion_info', {}), 'source', '') + + if l:source is# 'ale-automatic' + \|| l:source is# 'ale-manual' + \|| l:source is# 'ale-callback' + \|| l:source is# 'ale-import' + \|| l:source is# 'ale-omnifunc' + for l:code_action in get(l:user_data, 'code_actions', []) + call ale#code_action#HandleCodeAction(l:code_action, {}) + endfor + endif + + silent doautocmd User ALECompletePost +endfunction + +function! ale#completion#Done() abort + silent! pclose + + call ale#completion#RestoreCompletionOptions() + + let s:last_done_pos = getpos('.')[1:2] +endfunction + +augroup ALECompletionActions + autocmd! + + autocmd CompleteDone * call ale#completion#HandleUserData(v:completed_item) +augroup END + +function! s:Setup(enabled) abort + augroup ALECompletionGroup + autocmd! + + if a:enabled + autocmd TextChangedI * call ale#completion#Queue() + autocmd CompleteDone * call ale#completion#Done() + endif + augroup END + + if !a:enabled + augroup! ALECompletionGroup + endif +endfunction + +function! ale#completion#Enable() abort + let g:ale_completion_enabled = 1 + call s:Setup(1) +endfunction + +function! ale#completion#Disable() abort + let g:ale_completion_enabled = 0 + call s:Setup(0) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/completion/python.vim b/sources_non_forked/ale/autoload/ale/completion/python.vim new file mode 100644 index 00000000..6b65c5b5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/completion/python.vim @@ -0,0 +1,3 @@ +function! ale#completion#python#CompletionItemFilter(buffer, item) abort + return a:item.label !~# '\v^__[a-z_]+__' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/cursor.vim b/sources_non_forked/ale/autoload/ale/cursor.vim new file mode 100644 index 00000000..c83bbcb6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/cursor.vim @@ -0,0 +1,189 @@ +scriptencoding utf-8 +" Author: w0rp +" Author: João Paulo S. de Souza +" Description: Echoes lint message for the current line, if any + +" Controls the milliseconds delay before echoing a message. +let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10) +" A string format for the echoed message. +let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s') + +let s:cursor_timer = -1 + +" A wrapper for echon so we can test messages we echo in Vader tests. +function! ale#cursor#Echom(message) abort + " no-custom-checks + exec "norm! :echom a:message\n" +endfunction + +function! ale#cursor#TruncatedEcho(original_message) abort + let l:message = a:original_message + " Change tabs to spaces. + let l:message = substitute(l:message, "\t", ' ', 'g') + " Remove any newlines in the message. + let l:message = substitute(l:message, "\n", '', 'g') + " Convert indentation groups into single spaces for better legibility when + " put on a single line + let l:message = substitute(l:message, ' \+', ' ', 'g') + + " We need to remember the setting for shortmess and reset it again. + let l:shortmess_options = &l:shortmess + + try + let l:cursor_position = getpos('.') + + " The message is truncated and saved to the history. + silent! setlocal shortmess+=T + + try + call ale#cursor#Echom(l:message) + catch /^Vim\%((\a\+)\)\=:E523/ + " Fallback into manual truncate (#1987) + let l:winwidth = winwidth(0) + + if l:winwidth < strdisplaywidth(l:message) + " Truncate message longer than window width with trailing '...' + let l:message = l:message[:l:winwidth - 4] . '...' + endif + + exec 'echomsg l:message' + catch /E481/ + " Do nothing if running from a visual selection. + endtry + + " Reset the cursor position if we moved off the end of the line. + " Using :norm and :echomsg can move the cursor off the end of the + " line. + if l:cursor_position != getpos('.') + call setpos('.', l:cursor_position) + endif + finally + let &l:shortmess = l:shortmess_options + endtry +endfunction + +function! s:StopCursorTimer() abort + if s:cursor_timer != -1 + call timer_stop(s:cursor_timer) + let s:cursor_timer = -1 + endif +endfunction + +function! ale#cursor#EchoCursorWarning(...) abort + let l:buffer = bufnr('') + + if !g:ale_echo_cursor && !g:ale_cursor_detail + return + endif + + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode(1) isnot# 'n' + return + endif + + if ale#ShouldDoNothing(l:buffer) + return + endif + + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + if g:ale_echo_cursor + if !empty(l:loc) + let l:format = ale#Var(l:buffer, 'echo_msg_format') + let l:msg = ale#GetLocItemMessage(l:loc, l:format) + call ale#cursor#TruncatedEcho(l:msg) + let l:info.echoed = 1 + elseif get(l:info, 'echoed') + " We'll only clear the echoed message when moving off errors once, + " so we don't continually clear the echo line. + " + " no-custom-checks + echo + let l:info.echoed = 0 + endif + endif + + if g:ale_cursor_detail + if !empty(l:loc) + call s:ShowCursorDetailForItem(l:loc, {'stay_here': 1}) + else + call ale#preview#CloseIfTypeMatches('ale-preview') + endif + endif +endfunction + +function! ale#cursor#EchoCursorWarningWithDelay() abort + let l:buffer = bufnr('') + + if !g:ale_echo_cursor && !g:ale_cursor_detail + return + endif + + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode(1) isnot# 'n' + return + endif + + call s:StopCursorTimer() + + let l:pos = getpos('.')[0:2] + + if !exists('w:last_pos') + let w:last_pos = [0, 0, 0] + endif + + " Check the current buffer, line, and column number against the last + " recorded position. If the position has actually changed, *then* + " we should echo something. Otherwise we can end up doing processing + " the echo message far too frequently. + if l:pos != w:last_pos + let l:delay = ale#Var(l:buffer, 'echo_delay') + + let w:last_pos = l:pos + let s:cursor_timer = timer_start( + \ l:delay, + \ function('ale#cursor#EchoCursorWarning') + \) + endif +endfunction + +function! s:ShowCursorDetailForItem(loc, options) abort + let l:stay_here = get(a:options, 'stay_here', 0) + + let s:last_detailed_line = line('.') + let l:message = get(a:loc, 'detail', a:loc.text) + let l:lines = split(l:message, "\n") + + if g:ale_floating_preview || g:ale_detail_to_floating_preview + call ale#floating_preview#Show(l:lines) + else + call ale#preview#Show(l:lines, {'stay_here': l:stay_here}) + + " Clear the echo message if we manually displayed details. + if !l:stay_here + " no-custom-checks + echo + endif + endif +endfunction + +function! ale#cursor#ShowCursorDetail() abort + let l:buffer = bufnr('') + + " Only echo the warnings in normal mode, otherwise we will get problems. + if mode() isnot# 'n' + return + endif + + if ale#ShouldDoNothing(l:buffer) + return + endif + + call s:StopCursorTimer() + + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + if !empty(l:loc) + call s:ShowCursorDetailForItem(l:loc, {'stay_here': 0}) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/d.vim b/sources_non_forked/ale/autoload/ale/d.vim new file mode 100644 index 00000000..0e232203 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/d.vim @@ -0,0 +1,16 @@ +" Author: Auri +" Description: Functions for integrating with D linters. + +function! ale#d#FindDUBConfig(buffer) abort + " Find a DUB configuration file in ancestor paths. + " The most DUB-specific names will be tried first. + for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json'] + let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename) + + if !empty(l:dub_file) + return l:dub_file + endif + endfor + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/debugging.vim b/sources_non_forked/ale/autoload/ale/debugging.vim new file mode 100644 index 00000000..31f3078c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/debugging.vim @@ -0,0 +1,276 @@ +" Author: w0rp +" Description: This file implements debugging information for ALE + +let s:global_variable_list = [ +\ 'ale_cache_executable_check_failures', +\ 'ale_change_sign_column_color', +\ 'ale_command_wrapper', +\ 'ale_completion_delay', +\ 'ale_completion_enabled', +\ 'ale_completion_max_suggestions', +\ 'ale_disable_lsp', +\ 'ale_echo_cursor', +\ 'ale_echo_msg_error_str', +\ 'ale_echo_msg_format', +\ 'ale_echo_msg_info_str', +\ 'ale_echo_msg_warning_str', +\ 'ale_enabled', +\ 'ale_fix_on_save', +\ 'ale_fixers', +\ 'ale_history_enabled', +\ 'ale_history_log_output', +\ 'ale_keep_list_window_open', +\ 'ale_lint_delay', +\ 'ale_lint_on_enter', +\ 'ale_lint_on_filetype_changed', +\ 'ale_lint_on_insert_leave', +\ 'ale_lint_on_save', +\ 'ale_lint_on_text_changed', +\ 'ale_linter_aliases', +\ 'ale_linters', +\ 'ale_linters_explicit', +\ 'ale_linters_ignore', +\ 'ale_list_vertical', +\ 'ale_list_window_size', +\ 'ale_loclist_msg_format', +\ 'ale_max_buffer_history_size', +\ 'ale_max_signs', +\ 'ale_maximum_file_size', +\ 'ale_open_list', +\ 'ale_pattern_options', +\ 'ale_pattern_options_enabled', +\ 'ale_root', +\ 'ale_set_balloons', +\ 'ale_set_highlights', +\ 'ale_set_loclist', +\ 'ale_set_quickfix', +\ 'ale_set_signs', +\ 'ale_sign_column_always', +\ 'ale_sign_error', +\ 'ale_sign_info', +\ 'ale_sign_offset', +\ 'ale_sign_style_error', +\ 'ale_sign_style_warning', +\ 'ale_sign_warning', +\ 'ale_sign_highlight_linenrs', +\ 'ale_statusline_format', +\ 'ale_type_map', +\ 'ale_use_global_executables', +\ 'ale_virtualtext_cursor', +\ 'ale_warn_about_trailing_blank_lines', +\ 'ale_warn_about_trailing_whitespace', +\] + +function! s:Echo(message) abort + " no-custom-checks + echo a:message +endfunction + +function! s:GetLinterVariables(filetype, exclude_linter_names) abort + let l:variable_list = [] + let l:filetype_parts = split(a:filetype, '\.') + + for l:key in keys(g:) + " Extract variable names like: 'ale_python_flake8_executable' + let l:match = matchlist(l:key, '\v^ale_([^_]+)_([^_]+)_.+$') + + " Include matching variables. + if !empty(l:match) + \&& index(l:filetype_parts, l:match[1]) >= 0 + \&& index(a:exclude_linter_names, l:match[2]) == -1 + call add(l:variable_list, l:key) + endif + endfor + + call sort(l:variable_list) + + return l:variable_list +endfunction + +function! s:EchoLinterVariables(variable_list) abort + for l:key in a:variable_list + call s:Echo('let g:' . l:key . ' = ' . string(g:[l:key])) + + if has_key(b:, l:key) + call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key])) + endif + endfor +endfunction + +function! s:EchoGlobalVariables() abort + for l:key in s:global_variable_list + call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null))) + + if has_key(b:, l:key) + call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key])) + endif + endfor +endfunction + +" Echo a command that was run. +function! s:EchoCommand(item) abort + let l:status_message = a:item.status + + " Include the exit code in output if we have it. + if a:item.status is# 'finished' + let l:status_message .= ' - exit code ' . a:item.exit_code + endif + + call s:Echo('(' . l:status_message . ') ' . string(a:item.command)) + + if g:ale_history_log_output && has_key(a:item, 'output') + if empty(a:item.output) + call s:Echo('') + call s:Echo('<<>>') + call s:Echo('') + else + call s:Echo('') + call s:Echo('<<>>') + + for l:line in a:item.output + call s:Echo(l:line) + endfor + + call s:Echo('<<>>') + call s:Echo('') + endif + endif +endfunction + +" Echo the results of an executable check. +function! s:EchoExecutable(item) abort + call s:Echo(printf( + \ '(executable check - %s) %s', + \ a:item.status ? 'success' : 'failure', + \ a:item.command, + \)) +endfunction + +function! s:EchoCommandHistory() abort + let l:buffer = bufnr('%') + + for l:item in ale#history#Get(l:buffer) + if l:item.job_id is# 'executable' + call s:EchoExecutable(l:item) + else + call s:EchoCommand(l:item) + endif + endfor +endfunction + +function! s:EchoLinterAliases(all_linters) abort + let l:first = 1 + + for l:linter in a:all_linters + if !empty(l:linter.aliases) + if l:first + call s:Echo(' Linter Aliases:') + endif + + let l:first = 0 + + call s:Echo(string(l:linter.name) . ' -> ' . string(l:linter.aliases)) + endif + endfor +endfunction + +function! s:EchoLSPErrorMessages(all_linter_names) abort + let l:lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) + let l:header_echoed = 0 + + for l:linter_name in a:all_linter_names + let l:error_list = get(l:lsp_error_messages, l:linter_name, []) + + if !empty(l:error_list) + if !l:header_echoed + call s:Echo(' LSP Error Messages:') + call s:Echo('') + endif + + call s:Echo('(Errors for ' . l:linter_name . ')') + + for l:message in l:error_list + for l:line in split(l:message, "\n") + call s:Echo(l:line) + endfor + endfor + endif + endfor +endfunction + +function! ale#debugging#Info() abort + let l:buffer = bufnr('') + let l:filetype = &filetype + + " We get the list of enabled linters for free by the above function. + let l:enabled_linters = deepcopy(ale#linter#Get(l:filetype)) + + " But have to build the list of available linters ourselves. + let l:all_linters = [] + let l:linter_variable_list = [] + + for l:part in split(l:filetype, '\.') + let l:aliased_filetype = ale#linter#ResolveFiletype(l:part) + call extend(l:all_linters, ale#linter#GetAll(l:aliased_filetype)) + endfor + + let l:all_names = map(copy(l:all_linters), 'v:val[''name'']') + let l:enabled_names = map(copy(l:enabled_linters), 'v:val[''name'']') + let l:exclude_names = filter(copy(l:all_names), 'index(l:enabled_names, v:val) == -1') + + " Load linter variables to display + " This must be done after linters are loaded. + let l:variable_list = s:GetLinterVariables(l:filetype, l:exclude_names) + + let l:fixers = ale#fix#registry#SuggestedFixers(l:filetype) + let l:fixers = uniq(sort(l:fixers[0] + l:fixers[1])) + let l:fixers_string = join(map(copy(l:fixers), '"\n " . v:val'), '') + + let l:non_ignored_names = map( + \ copy(ale#linter#RemoveIgnored(l:buffer, l:filetype, l:enabled_linters)), + \ 'v:val[''name'']', + \) + let l:ignored_names = filter( + \ copy(l:enabled_names), + \ 'index(l:non_ignored_names, v:val) < 0' + \) + + call s:Echo(' Current Filetype: ' . l:filetype) + call s:Echo('Available Linters: ' . string(l:all_names)) + call s:EchoLinterAliases(l:all_linters) + call s:Echo(' Enabled Linters: ' . string(l:enabled_names)) + call s:Echo(' Ignored Linters: ' . string(l:ignored_names)) + call s:Echo(' Suggested Fixers: ' . l:fixers_string) + call s:Echo(' Linter Variables:') + call s:Echo('') + call s:EchoLinterVariables(l:variable_list) + call s:Echo(' Global Variables:') + call s:Echo('') + call s:EchoGlobalVariables() + call s:EchoLSPErrorMessages(l:all_names) + call s:Echo(' Command History:') + call s:Echo('') + call s:EchoCommandHistory() +endfunction + +function! ale#debugging#InfoToClipboard() abort + if !has('clipboard') + call s:Echo('clipboard not available. Try :ALEInfoToFile instead.') + + return + endif + + let l:output = execute('call ale#debugging#Info()') + + let @+ = l:output + call s:Echo('ALEInfo copied to your clipboard') +endfunction + +function! ale#debugging#InfoToFile(filename) abort + let l:expanded_filename = expand(a:filename) + + let l:output = execute('call ale#debugging#Info()') + + call writefile(split(l:output, "\n"), l:expanded_filename) + call s:Echo('ALEInfo written to ' . l:expanded_filename) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/definition.vim b/sources_non_forked/ale/autoload/ale/definition.vim new file mode 100644 index 00000000..fd6cd2e1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/definition.vim @@ -0,0 +1,224 @@ +" Author: w0rp +" Description: Go to definition support for LSP linters. + +let s:go_to_definition_map = {} + +" Enable automatic updates of the tagstack +let g:ale_update_tagstack = get(g:, 'ale_update_tagstack', 1) +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + +" Used to get the definition map in tests. +function! ale#definition#GetMap() abort + return deepcopy(s:go_to_definition_map) +endfunction + +" Used to set the definition map in tests. +function! ale#definition#SetMap(map) abort + let s:go_to_definition_map = a:map +endfunction + +function! ale#definition#ClearLSPData() abort + let s:go_to_definition_map = {} +endfunction + +function! ale#definition#UpdateTagStack() abort + let l:should_update_tagstack = exists('*gettagstack') && exists('*settagstack') && g:ale_update_tagstack + + if l:should_update_tagstack + " Grab the old location (to jump back to) and the word under the + " cursor (as a label for the tagstack) + let l:old_location = [bufnr('%'), line('.'), col('.'), 0] + let l:tagname = expand('') + let l:winid = win_getid() + call settagstack(l:winid, {'items': [{'from': l:old_location, 'tagname': l:tagname}]}, 'a') + call settagstack(l:winid, {'curidx': len(gettagstack(l:winid)['items']) + 1}) + endif +endfunction + +function! ale#definition#HandleTSServerResponse(conn_id, response) abort + if has_key(a:response, 'request_seq') + \&& has_key(s:go_to_definition_map, a:response.request_seq) + let l:options = remove(s:go_to_definition_map, a:response.request_seq) + + if get(a:response, 'success', v:false) is v:true && !empty(a:response.body) + let l:filename = a:response.body[0].file + let l:line = a:response.body[0].start.line + let l:column = a:response.body[0].start.offset + + call ale#definition#UpdateTagStack() + call ale#util#Open(l:filename, l:line, l:column, l:options) + endif + endif +endfunction + +function! ale#definition#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:go_to_definition_map, a:response.id) + let l:options = remove(s:go_to_definition_map, a:response.id) + + " The result can be a Dictionary item, a List of the same, or null. + let l:result = get(a:response, 'result', v:null) + + if type(l:result) is v:t_dict + let l:result = [l:result] + elseif type(l:result) isnot v:t_list + let l:result = [] + endif + + for l:item in l:result + if has_key(l:item, 'targetUri') + " LocationLink items use targetUri + let l:uri = l:item.targetUri + let l:line = l:item.targetRange.start.line + 1 + let l:column = l:item.targetRange.start.character + 1 + else + " LocationLink items use uri + let l:uri = l:item.uri + let l:line = l:item.range.start.line + 1 + let l:column = l:item.range.start.character + 1 + endif + + call ale#definition#UpdateTagStack() + + let l:uri_handler = ale#uri#GetURIHandler(l:uri) + + if l:uri_handler is# v:null + let l:filename = ale#path#FromFileURI(l:uri) + call ale#util#Open(l:filename, l:line, l:column, l:options) + else + call l:uri_handler.OpenURILink(l:uri, l:line, l:column, l:options, a:conn_id) + endif + + break + endfor + endif +endfunction + +function! s:OnReady(line, column, options, capability, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, a:capability) + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#definition#HandleTSServerResponse') + \ : function('ale#definition#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + if a:capability is# 'definition' + let l:message = ale#lsp#tsserver_message#Definition( + \ l:buffer, + \ a:line, + \ a:column + \) + elseif a:capability is# 'typeDefinition' + let l:message = ale#lsp#tsserver_message#TypeDefinition( + \ l:buffer, + \ a:line, + \ a:column + \) + elseif a:capability is# 'implementation' + let l:message = ale#lsp#tsserver_message#Implementation( + \ l:buffer, + \ a:line, + \ a:column + \) + endif + else + " Send a message saying the buffer has changed first, or the + " definition position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + " For LSP completions, we need to clamp the column to the length of + " the line. python-language-server and perhaps others do not implement + " this correctly. + if a:capability is# 'definition' + let l:message = ale#lsp#message#Definition(l:buffer, a:line, a:column) + elseif a:capability is# 'typeDefinition' + let l:message = ale#lsp#message#TypeDefinition(l:buffer, a:line, a:column) + elseif a:capability is# 'implementation' + let l:message = ale#lsp#message#Implementation(l:buffer, a:line, a:column) + else + " XXX: log here? + return + endif + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:go_to_definition_map[l:request_id] = { + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), + \} +endfunction + +function! s:GoToLSPDefinition(linter, options, capability) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + + let l:Callback = function( + \ 's:OnReady', + \ [l:line, l:column, a:options, a:capability] + \) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#definition#GoTo(options) abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:GoToLSPDefinition(l:linter, a:options, 'definition') + endif + endfor +endfunction + +function! ale#definition#GoToType(options) abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:GoToLSPDefinition(l:linter, a:options, 'typeDefinition') + endif + endfor +endfunction + +function! ale#definition#GoToImpl(options) abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:GoToLSPDefinition(l:linter, a:options, 'implementation') + endif + endfor +endfunction + +function! ale#definition#GoToCommandHandler(command, ...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + if a:command is# 'type' + call ale#definition#GoToType(l:options) + elseif a:command is# 'implementation' + call ale#definition#GoToImpl(l:options) + else + call ale#definition#GoTo(l:options) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/dhall.vim b/sources_non_forked/ale/autoload/ale/dhall.vim new file mode 100644 index 00000000..cc54418f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/dhall.vim @@ -0,0 +1,24 @@ +" Author: Pat Brisbin , toastal +" Description: Functions for working with Dhall’s executable + +call ale#Set('dhall_executable', 'dhall') +call ale#Set('dhall_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dhall_options', '') + +function! ale#dhall#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'dhall_executable') + + " Dhall is written in Haskell and commonly installed with Stack + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'dhall') +endfunction + +function! ale#dhall#GetExecutableWithOptions(buffer) abort + let l:executable = ale#dhall#GetExecutable(a:buffer) + + return l:executable + \ . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction + +function! ale#dhall#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'dhall_options')) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine.vim b/sources_non_forked/ale/autoload/ale/engine.vim new file mode 100644 index 00000000..97c46656 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/engine.vim @@ -0,0 +1,738 @@ +" Author: w0rp +" Description: Backend execution and job management +" Executes linters in the background, using NeoVim or Vim 8 jobs + +" Remapping of linter problems. +let g:ale_type_map = get(g:, 'ale_type_map', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) + +if !has_key(s:, 'executable_cache_map') + let s:executable_cache_map = {} +endif + +function! ale#engine#CleanupEveryBuffer() abort + for l:key in keys(g:ale_buffer_info) + " The key could be a filename or a buffer number, so try and + " convert it to a number. We need a number for the other + " functions. + let l:buffer = str2nr(l:key) + + if l:buffer > 0 + " Stop all jobs and clear the results for everything, and delete + " all of the data we stored for the buffer. + call ale#engine#Cleanup(l:buffer) + endif + endfor +endfunction + +function! ale#engine#MarkLinterActive(info, linter) abort + let l:found = 0 + + for l:other_linter in a:info.active_linter_list + if l:other_linter.name is# a:linter.name + let l:found = 1 + break + endif + endfor + + if !l:found + call add(a:info.active_linter_list, a:linter) + endif +endfunction + +function! ale#engine#MarkLinterInactive(info, linter_name) abort + call filter(a:info.active_linter_list, 'v:val.name isnot# a:linter_name') +endfunction + +function! ale#engine#ResetExecutableCache() abort + let s:executable_cache_map = {} +endfunction + +" Check if files are executable, and if they are, remember that they are +" for subsequent calls. We'll keep checking until programs can be executed. +function! ale#engine#IsExecutable(buffer, executable) abort + if empty(a:executable) + " Don't log the executable check if the executable string is empty. + return 0 + endif + + " Check for a cached executable() check. + let l:result = get(s:executable_cache_map, a:executable, v:null) + + if l:result isnot v:null + return l:result + endif + + " Check if the file is executable, and convert -1 to 1. + let l:result = executable(a:executable) isnot 0 + + " Cache the executable check if we found it, or if the option to cache + " failing checks is on. + if l:result || get(g:, 'ale_cache_executable_check_failures', 0) + let s:executable_cache_map[a:executable] = l:result + endif + + if g:ale_history_enabled + call ale#history#Add(a:buffer, l:result, 'executable', a:executable) + endif + + return l:result +endfunction + +function! ale#engine#InitBufferInfo(buffer) abort + if !has_key(g:ale_buffer_info, a:buffer) + " active_linter_list will hold the list of active linter names + " loclist holds the loclist items after all jobs have completed. + let g:ale_buffer_info[a:buffer] = { + \ 'active_linter_list': [], + \ 'active_other_sources_list': [], + \ 'loclist': [], + \} + + return 1 + endif + + return 0 +endfunction + +" This function is documented and part of the public API. +" +" Return 1 if ALE is busy checking a given buffer +function! ale#engine#IsCheckingBuffer(buffer) abort + let l:info = get(g:ale_buffer_info, a:buffer, {}) + + return !empty(get(l:info, 'active_linter_list', [])) + \ || !empty(get(l:info, 'active_other_sources_list', [])) +endfunction + +function! ale#engine#HandleLoclist(linter_name, buffer, loclist, from_other_source) abort + let l:info = get(g:ale_buffer_info, a:buffer, {}) + + if empty(l:info) + return + endif + + if !a:from_other_source + " Remove this linter from the list of active linters. + " This may have already been done when the job exits. + call filter(l:info.active_linter_list, 'v:val.name isnot# a:linter_name') + endif + + " Make some adjustments to the loclists to fix common problems, and also + " to set default values for loclist items. + let l:linter_loclist = ale#engine#FixLocList( + \ a:buffer, + \ a:linter_name, + \ a:from_other_source, + \ a:loclist, + \) + + " Remove previous items for this linter. + call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name') + + " We don't need to add items or sort the list when this list is empty. + if !empty(l:linter_loclist) + " Add the new items. + call extend(l:info.loclist, l:linter_loclist) + + " Sort the loclist again. + " We need a sorted list so we can run a binary search against it + " for efficient lookup of the messages in the cursor handler. + call sort(l:info.loclist, 'ale#util#LocItemCompare') + endif + + if ale#ShouldDoNothing(a:buffer) + return + endif + + call ale#engine#SetResults(a:buffer, l:info.loclist) +endfunction + +function! s:HandleExit(job_info, buffer, output, data) abort + let l:buffer_info = get(g:ale_buffer_info, a:buffer) + + if empty(l:buffer_info) + return + endif + + let l:linter = a:job_info.linter + let l:executable = a:job_info.executable + + " Remove this job from the list. + call ale#engine#MarkLinterInactive(l:buffer_info, l:linter.name) + + " Stop here if we land in the handle for a job completing if we're in + " a sandbox. + if ale#util#InSandbox() + return + endif + + if has('nvim') && !empty(a:output) && empty(a:output[-1]) + call remove(a:output, -1) + endif + + try + let l:loclist = ale#util#GetFunction(l:linter.callback)(a:buffer, a:output) + " Handle the function being unknown, or being deleted. + catch /E700/ + let l:loclist = [] + endtry + + call ale#engine#HandleLoclist(l:linter.name, a:buffer, l:loclist, 0) +endfunction + +function! ale#engine#SetResults(buffer, loclist) abort + let l:linting_is_done = !ale#engine#IsCheckingBuffer(a:buffer) + + " Set signs first. This could potentially fix some line numbers. + " The List could be sorted again here by SetSigns. + if g:ale_set_signs + call ale#sign#SetSigns(a:buffer, a:loclist) + endif + + if g:ale_set_quickfix || g:ale_set_loclist + call ale#list#SetLists(a:buffer, a:loclist) + endif + + if exists('*ale#statusline#Update') + " Don't load/run if not already loaded. + call ale#statusline#Update(a:buffer, a:loclist) + endif + + if g:ale_set_highlights + call ale#highlight#SetHighlights(a:buffer, a:loclist) + endif + + if g:ale_virtualtext_cursor == 2 + call ale#virtualtext#SetTexts(a:buffer, a:loclist) + endif + + if l:linting_is_done + if g:ale_echo_cursor + " Try and echo the warning now. + " This will only do something meaningful if we're in normal mode. + call ale#cursor#EchoCursorWarning() + endif + + if g:ale_virtualtext_cursor == 1 + " Try and show the warning now. + " This will only do something meaningful if we're in normal mode. + call ale#virtualtext#ShowCursorWarning() + endif + + " Reset the save event marker, used for opening windows, etc. + call setbufvar(a:buffer, 'ale_save_event_fired', 0) + " Set a marker showing how many times a buffer has been checked. + call setbufvar( + \ a:buffer, + \ 'ale_linted', + \ getbufvar(a:buffer, 'ale_linted', 0) + 1 + \) + + " Automatically remove all managed temporary files and directories + " now that all jobs have completed. + call ale#command#RemoveManagedFiles(a:buffer) + + " Call user autocommands. This allows users to hook into ALE's lint cycle. + silent doautocmd User ALELintPost + endif +endfunction + +function! s:RemapItemTypes(type_map, loclist) abort + for l:item in a:loclist + let l:key = l:item.type + \ . (get(l:item, 'sub_type', '') is# 'style' ? 'S' : '') + let l:new_key = get(a:type_map, l:key, '') + + if l:new_key is# 'E' + \|| l:new_key is# 'ES' + \|| l:new_key is# 'W' + \|| l:new_key is# 'WS' + \|| l:new_key is# 'I' + let l:item.type = l:new_key[0] + + if l:new_key is# 'ES' || l:new_key is# 'WS' + let l:item.sub_type = 'style' + elseif has_key(l:item, 'sub_type') + call remove(l:item, 'sub_type') + endif + endif + endfor +endfunction + +function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist) abort + let l:mappings = ale#GetFilenameMappings(a:buffer, a:linter_name) + + if !empty(l:mappings) + " We need to apply reverse filename mapping here. + let l:mappings = ale#filename_mapping#Invert(l:mappings) + endif + + let l:bufnr_map = {} + let l:new_loclist = [] + + " Some errors have line numbers beyond the end of the file, + " so we need to adjust them so they set the error at the last line + " of the file instead. + let l:last_line_number = ale#util#GetLineCount(a:buffer) + + for l:old_item in a:loclist + " Copy the loclist item with some default values and corrections. + " + " line and column numbers will be converted to numbers. + " The buffer will default to the buffer being checked. + " The vcol setting will default to 0, a byte index. + " The error type will default to 'E' for errors. + " The error number will default to -1. + " + " The line number and text are the only required keys. + " + " The linter_name will be set on the errors so it can be used in + " output, filtering, etc.. + let l:item = { + \ 'bufnr': a:buffer, + \ 'text': l:old_item.text, + \ 'lnum': str2nr(l:old_item.lnum), + \ 'col': str2nr(get(l:old_item, 'col', 0)), + \ 'vcol': 0, + \ 'type': get(l:old_item, 'type', 'E'), + \ 'nr': get(l:old_item, 'nr', -1), + \ 'linter_name': a:linter_name, + \} + + if a:from_other_source + let l:item.from_other_source = 1 + endif + + if has_key(l:old_item, 'code') + let l:item.code = l:old_item.code + endif + + let l:old_name = get(l:old_item, 'filename', '') + + " Map parsed from output to local filesystem files. + if !empty(l:old_name) && !empty(l:mappings) + let l:old_name = ale#filename_mapping#Map(l:old_name, l:mappings) + endif + + if !empty(l:old_name) && !ale#path#IsTempName(l:old_name) + " Use the filename given. + " Temporary files are assumed to be for this buffer, + " and the filename is not included then, because it looks bad + " in the loclist window. + let l:filename = l:old_name + let l:item.filename = l:filename + + if has_key(l:old_item, 'bufnr') + " If a buffer number is also given, include that too. + " If Vim detects that he buffer number is valid, it will + " be used instead of the filename. + let l:item.bufnr = l:old_item.bufnr + elseif has_key(l:bufnr_map, l:filename) + " Get the buffer number from the map, which can be faster. + let l:item.bufnr = l:bufnr_map[l:filename] + else + " Look up the buffer number. + let l:item.bufnr = bufnr(l:filename) + let l:bufnr_map[l:filename] = l:item.bufnr + endif + elseif has_key(l:old_item, 'bufnr') + let l:item.bufnr = l:old_item.bufnr + endif + + if has_key(l:old_item, 'detail') + let l:item.detail = l:old_item.detail + endif + + " Pass on a end_col key if set, used for highlights. + if has_key(l:old_item, 'end_col') + let l:item.end_col = str2nr(l:old_item.end_col) + endif + + if has_key(l:old_item, 'end_lnum') + let l:item.end_lnum = str2nr(l:old_item.end_lnum) + + " When the error ends after the end of the file, put it at the + " end. This is only done for the current buffer. + if l:item.bufnr == a:buffer && l:item.end_lnum > l:last_line_number + let l:item.end_lnum = l:last_line_number + endif + endif + + if has_key(l:old_item, 'sub_type') + let l:item.sub_type = l:old_item.sub_type + endif + + if l:item.lnum < 1 + " When errors appear before line 1, put them at line 1. + let l:item.lnum = 1 + elseif l:item.bufnr == a:buffer && l:item.lnum > l:last_line_number + " When errors go beyond the end of the file, put them at the end. + " This is only done for the current buffer. + let l:item.lnum = l:last_line_number + elseif get(l:old_item, 'vcol', 0) + " Convert virtual column positions to byte positions. + " The positions will be off if the buffer has changed recently. + let l:line = getbufline(a:buffer, l:item.lnum)[0] + + let l:item.col = ale#util#Col(l:line, l:item.col) + + if has_key(l:item, 'end_col') + let l:end_line = get(l:item, 'end_lnum', l:line) != l:line + \ ? getbufline(a:buffer, l:item.end_lnum)[0] + \ : l:line + + let l:item.end_col = ale#util#Col(l:end_line, l:item.end_col) + endif + endif + + call add(l:new_loclist, l:item) + endfor + + let l:type_map = get(ale#Var(a:buffer, 'type_map'), a:linter_name, {}) + + if !empty(l:type_map) + call s:RemapItemTypes(l:type_map, l:new_loclist) + endif + + return l:new_loclist +endfunction + +" Given part of a command, replace any % with %%, so that no characters in +" the string will be replaced with filenames, etc. +function! ale#engine#EscapeCommandPart(command_part) abort + " TODO: Emit deprecation warning here later. + return ale#command#EscapeCommandPart(a:command_part) +endfunction + +" Run a job. +" +" Returns 1 when a job was started successfully. +function! s:RunJob(command, options) abort + if ale#command#IsDeferred(a:command) + let a:command.result_callback = { + \ command -> s:RunJob(command, a:options) + \} + + return 1 + endif + + let l:command = a:command + + if empty(l:command) + return 0 + endif + + let l:cwd = a:options.cwd + let l:executable = a:options.executable + let l:buffer = a:options.buffer + let l:linter = a:options.linter + let l:output_stream = a:options.output_stream + let l:read_buffer = a:options.read_buffer && !a:options.lint_file + let l:info = g:ale_buffer_info[l:buffer] + + let l:Callback = function('s:HandleExit', [{ + \ 'linter': l:linter, + \ 'executable': l:executable, + \}]) + let l:result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'cwd': l:cwd, + \ 'output_stream': l:output_stream, + \ 'executable': l:executable, + \ 'read_buffer': l:read_buffer, + \ 'log_output': 1, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:linter.name), + \}) + + " Only proceed if the job is being run. + if empty(l:result) + return 0 + endif + + call ale#engine#MarkLinterActive(l:info, l:linter) + + silent doautocmd User ALEJobStarted + + return 1 +endfunction + +function! s:StopCurrentJobs(buffer, clear_lint_file_jobs, linter_slots) abort + let l:info = get(g:ale_buffer_info, a:buffer, {}) + call ale#command#StopJobs(a:buffer, 'linter') + + " Update the active linter list, clearing out anything not running. + if a:clear_lint_file_jobs + call ale#command#StopJobs(a:buffer, 'file_linter') + let l:info.active_linter_list = [] + else + let l:lint_file_map = {} + + " Use a previously computed map of `lint_file` values to find + " linters that are used for linting files. + for [l:lint_file, l:linter] in a:linter_slots + if l:lint_file is 1 + let l:lint_file_map[l:linter.name] = 1 + endif + endfor + + " Keep jobs for linting files when we're only linting buffers. + call filter(l:info.active_linter_list, 'get(l:lint_file_map, v:val.name)') + endif +endfunction + +function! ale#engine#Stop(buffer) abort + call s:StopCurrentJobs(a:buffer, 1, []) +endfunction + +function! s:RemoveProblemsForDisabledLinters(buffer, linters) abort + " Figure out which linters are still enabled, and remove + " problems for linters which are no longer enabled. + " Problems from other sources will be kept. + let l:name_map = {} + + for l:linter in a:linters + let l:name_map[l:linter.name] = 1 + endfor + + call filter( + \ get(g:ale_buffer_info[a:buffer], 'loclist', []), + \ 'get(v:val, ''from_other_source'') || get(l:name_map, get(v:val, ''linter_name''))', + \) +endfunction + +function! s:AddProblemsFromOtherBuffers(buffer, linters) abort + let l:filename = expand('#' . a:buffer . ':p') + let l:loclist = [] + let l:name_map = {} + + " Build a map of the active linters. + for l:linter in a:linters + let l:name_map[l:linter.name] = 1 + endfor + + " Find the items from other buffers, for the linters that are enabled. + for l:info in values(g:ale_buffer_info) + for l:item in l:info.loclist + if has_key(l:item, 'filename') + \&& l:item.filename is# l:filename + \&& has_key(l:name_map, l:item.linter_name) + " Copy the items and set the buffer numbers to this one. + let l:new_item = copy(l:item) + let l:new_item.bufnr = a:buffer + call add(l:loclist, l:new_item) + endif + endfor + endfor + + if !empty(l:loclist) + call sort(l:loclist, function('ale#util#LocItemCompareWithText')) + call uniq(l:loclist, function('ale#util#LocItemCompareWithText')) + + " Set the loclist variable, used by some parts of ALE. + let g:ale_buffer_info[a:buffer].loclist = l:loclist + call ale#engine#SetResults(a:buffer, l:loclist) + endif +endfunction + +function! s:RunIfExecutable(buffer, linter, lint_file, executable) abort + if ale#command#IsDeferred(a:executable) + let a:executable.result_callback = { + \ executable -> s:RunIfExecutable( + \ a:buffer, + \ a:linter, + \ a:lint_file, + \ executable + \ ) + \} + + return 1 + endif + + if ale#engine#IsExecutable(a:buffer, a:executable) + " Use different job types for file or linter jobs. + let l:job_type = a:lint_file ? 'file_linter' : 'linter' + call setbufvar(a:buffer, 'ale_job_type', l:job_type) + + " Get the cwd for the linter and set it before we call GetCommand. + " This will ensure that ale#command#Run uses it by default. + let l:cwd = ale#linter#GetCwd(a:buffer, a:linter) + + if l:cwd isnot v:null + call ale#command#SetCwd(a:buffer, l:cwd) + endif + + let l:command = ale#linter#GetCommand(a:buffer, a:linter) + + if l:cwd isnot v:null + call ale#command#ResetCwd(a:buffer) + endif + + let l:options = { + \ 'cwd': l:cwd, + \ 'executable': a:executable, + \ 'buffer': a:buffer, + \ 'linter': a:linter, + \ 'output_stream': get(a:linter, 'output_stream', 'stdout'), + \ 'read_buffer': a:linter.read_buffer, + \ 'lint_file': a:lint_file, + \} + + return s:RunJob(l:command, l:options) + endif + + return 0 +endfunction + +" Run a linter for a buffer. +" +" Returns 1 if the linter was successfully run. +function! s:RunLinter(buffer, linter, lint_file) abort + if !empty(a:linter.lsp) + return ale#lsp_linter#CheckWithLSP(a:buffer, a:linter) + else + let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) + + return s:RunIfExecutable(a:buffer, a:linter, a:lint_file, l:executable) + endif + + return 0 +endfunction + +function! s:GetLintFileSlots(buffer, linters) abort + let l:linter_slots = [] + + for l:linter in a:linters + let l:LintFile = l:linter.lint_file + + if type(l:LintFile) is v:t_func + let l:LintFile = l:LintFile(a:buffer) + endif + + call add(l:linter_slots, [l:LintFile, l:linter]) + endfor + + return l:linter_slots +endfunction + +function! s:GetLintFileValues(slots, Callback) abort + let l:deferred_list = [] + let l:new_slots = [] + + for [l:lint_file, l:linter] in a:slots + while ale#command#IsDeferred(l:lint_file) && has_key(l:lint_file, 'value') + " If we've already computed the return value, use it. + let l:lint_file = l:lint_file.value + endwhile + + if ale#command#IsDeferred(l:lint_file) + " If we are going to return the result later, wait for it. + call add(l:deferred_list, l:lint_file) + else + " If we have the value now, coerce it to 0 or 1. + let l:lint_file = l:lint_file is 1 + endif + + call add(l:new_slots, [l:lint_file, l:linter]) + endfor + + if !empty(l:deferred_list) + for l:deferred in l:deferred_list + let l:deferred.result_callback = + \ {-> s:GetLintFileValues(l:new_slots, a:Callback)} + endfor + else + call a:Callback(l:new_slots) + endif +endfunction + +function! s:RunLinters( +\ buffer, +\ linters, +\ slots, +\ should_lint_file, +\ new_buffer, +\) abort + call s:StopCurrentJobs(a:buffer, a:should_lint_file, a:slots) + call s:RemoveProblemsForDisabledLinters(a:buffer, a:linters) + + " We can only clear the results if we aren't checking the buffer. + let l:can_clear_results = !ale#engine#IsCheckingBuffer(a:buffer) + + silent doautocmd User ALELintPre + + for [l:lint_file, l:linter] in a:slots + " Only run lint_file linters if we should. + if !l:lint_file || a:should_lint_file + if s:RunLinter(a:buffer, l:linter, l:lint_file) + " If a single linter ran, we shouldn't clear everything. + let l:can_clear_results = 0 + endif + else + " If we skipped running a lint_file linter still in the list, + " we shouldn't clear everything. + let l:can_clear_results = 0 + endif + endfor + + " Clear the results if we can. This needs to be done when linters are + " disabled, or ALE itself is disabled. + if l:can_clear_results + call ale#engine#SetResults(a:buffer, []) + elseif a:new_buffer + call s:AddProblemsFromOtherBuffers( + \ a:buffer, + \ map(copy(a:slots), 'v:val[1]') + \) + endif +endfunction + +function! ale#engine#RunLinters(buffer, linters, should_lint_file) abort + " Initialise the buffer information if needed. + let l:new_buffer = ale#engine#InitBufferInfo(a:buffer) + + call s:GetLintFileValues( + \ s:GetLintFileSlots(a:buffer, a:linters), + \ { + \ slots -> s:RunLinters( + \ a:buffer, + \ a:linters, + \ slots, + \ a:should_lint_file, + \ l:new_buffer, + \ ) + \ } + \) +endfunction + +" Clean up a buffer. +" +" This function will stop all current jobs for the buffer, +" clear the state of everything, and remove the Dictionary for managing +" the buffer. +function! ale#engine#Cleanup(buffer) abort + " Don't bother with cleanup code when newer NeoVim versions are exiting. + if get(v:, 'exiting', v:null) isnot v:null + return + endif + + if exists('*ale#lsp#CloseDocument') + call ale#lsp#CloseDocument(a:buffer) + endif + + if !has_key(g:ale_buffer_info, a:buffer) + return + endif + + call ale#engine#RunLinters(a:buffer, [], 1) + + call remove(g:ale_buffer_info, a:buffer) +endfunction + +" Given a buffer number, return the warnings and errors for a given buffer. +function! ale#engine#GetLoclist(buffer) abort + if !has_key(g:ale_buffer_info, a:buffer) + return [] + endif + + return g:ale_buffer_info[a:buffer].loclist +endfunction diff --git a/sources_non_forked/ale/autoload/ale/engine/ignore.vim b/sources_non_forked/ale/autoload/ale/engine/ignore.vim new file mode 100644 index 00000000..80574656 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/engine/ignore.vim @@ -0,0 +1,50 @@ +" Author: w0rp +" Description: Code for ignoring linters. Only loaded and if configured. + +" Given a filetype and a configuration for ignoring linters, return a List of +" Strings for linter names to ignore. +function! ale#engine#ignore#GetList(filetype, config) abort + if type(a:config) is v:t_list + return a:config + endif + + if type(a:config) is v:t_dict + let l:names_to_remove = [] + + for l:part in split(a:filetype , '\.') + call extend(l:names_to_remove, get(a:config, l:part, [])) + endfor + + return l:names_to_remove + endif + + return [] +endfunction + +" Given a List of linter descriptions, exclude the linters to be ignored. +function! ale#engine#ignore#Exclude(filetype, all_linters, config, disable_lsp) abort + let l:names_to_remove = ale#engine#ignore#GetList(a:filetype, a:config) + let l:filtered_linters = [] + + for l:linter in a:all_linters + let l:name_list = [l:linter.name] + l:linter.aliases + let l:should_include = 1 + + for l:name in l:name_list + if index(l:names_to_remove, l:name) >= 0 + let l:should_include = 0 + break + endif + endfor + + if a:disable_lsp && has_key(l:linter, 'lsp') && l:linter.lsp isnot# '' + let l:should_include = 0 + endif + + if l:should_include + call add(l:filtered_linters, l:linter) + endif + endfor + + return l:filtered_linters +endfunction diff --git a/sources_non_forked/ale/autoload/ale/events.vim b/sources_non_forked/ale/autoload/ale/events.vim new file mode 100644 index 00000000..4efb8a3b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/events.vim @@ -0,0 +1,165 @@ +" Author: w0rp +" Description: ALE functions for autocmd events. + +" Get the number of milliseconds since some vague, but consistent, point in +" the past. +" +" This function can be used for timing execution, etc. +" +" The time will be returned as a Number. +function! ale#events#ClockMilliseconds() abort + return float2nr(reltimefloat(reltime()) * 1000) +endfunction + +function! ale#events#QuitEvent(buffer) abort + " Remember when ALE is quitting for BufWrite, etc. + call setbufvar(a:buffer, 'ale_quitting', ale#events#ClockMilliseconds()) +endfunction + +function! ale#events#QuitRecently(buffer) abort + let l:time = getbufvar(a:buffer, 'ale_quitting', 0) + + return l:time && ale#events#ClockMilliseconds() - l:time < 1000 +endfunction + +function! ale#events#SaveEvent(buffer) abort + let l:should_lint = ale#Var(a:buffer, 'enabled') && g:ale_lint_on_save + + if l:should_lint + call setbufvar(a:buffer, 'ale_save_event_fired', 1) + endif + + if ale#Var(a:buffer, 'fix_on_save') && !ale#events#QuitRecently(a:buffer) + let l:will_fix = ale#fix#Fix(a:buffer, 'save_file') + let l:should_lint = l:should_lint && !l:will_fix + endif + + if l:should_lint && !ale#events#QuitRecently(a:buffer) + call ale#Queue(0, 'lint_file', a:buffer) + endif +endfunction + +function! ale#events#LintOnEnter(buffer) abort + " Unmark a file as being changed outside of Vim after we try to check it. + call setbufvar(a:buffer, 'ale_file_changed', 0) + + if ale#Var(a:buffer, 'enabled') && g:ale_lint_on_enter + call ale#Queue(0, 'lint_file', a:buffer) + endif +endfunction + +function! ale#events#ReadOrEnterEvent(buffer) abort + " Apply pattern options if the variable is set. + if get(g:, 'ale_pattern_options_enabled', 1) + \&& !empty(get(g:, 'ale_pattern_options')) + call ale#pattern_options#SetOptions(a:buffer) + endif + + " When entering a buffer, we are no longer quitting it. + call setbufvar(a:buffer, 'ale_quitting', 0) + let l:filetype = getbufvar(a:buffer, '&filetype') + call setbufvar(a:buffer, 'ale_original_filetype', l:filetype) + + " If the file changed outside of Vim, check it on BufEnter,BufRead + if getbufvar(a:buffer, 'ale_file_changed') + call ale#events#LintOnEnter(a:buffer) + endif +endfunction + +function! ale#events#FileTypeEvent(buffer, new_filetype) abort + " The old filetype will be set to an empty string by the BuFEnter event, + " and not linting when the old filetype hasn't been set yet prevents + " buffers being checked when you enter them when linting on enter is off. + let l:old_filetype = getbufvar(a:buffer, 'ale_original_filetype', v:null) + + if l:old_filetype isnot v:null + \&& !empty(a:new_filetype) + \&& a:new_filetype isnot# l:old_filetype + " Remember what the new filetype is. + call setbufvar(a:buffer, 'ale_original_filetype', a:new_filetype) + + if g:ale_lint_on_filetype_changed + call ale#Queue(300, 'lint_file', a:buffer) + endif + endif +endfunction + +function! ale#events#FileChangedEvent(buffer) abort + call setbufvar(a:buffer, 'ale_file_changed', 1) + + if bufnr('') == a:buffer + call ale#events#LintOnEnter(a:buffer) + endif +endfunction + +function! ale#events#Init() abort + " This value used to be a Boolean as a Number, and is now a String. + let l:text_changed = '' . g:ale_lint_on_text_changed + + augroup ALEEvents + autocmd! + + " These events always need to be set up. + autocmd BufEnter,BufRead * call ale#events#ReadOrEnterEvent(str2nr(expand(''))) + autocmd BufWritePost * call ale#events#SaveEvent(str2nr(expand(''))) + + if g:ale_enabled + if l:text_changed is? 'always' || l:text_changed is# '1' + autocmd TextChanged,TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) + elseif l:text_changed is? 'normal' + autocmd TextChanged * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) + elseif l:text_changed is? 'insert' + autocmd TextChangedI * call ale#Queue(ale#Var(str2nr(expand('')), 'lint_delay')) + endif + + if g:ale_lint_on_enter + autocmd BufWinEnter * call ale#events#LintOnEnter(str2nr(expand(''))) + " Track when the file is changed outside of Vim. + autocmd FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''))) + endif + + if g:ale_lint_on_filetype_changed + " Only start linting if the FileType actually changes after + " opening a buffer. The FileType will fire when buffers are opened. + autocmd FileType * call ale#events#FileTypeEvent( + \ str2nr(expand('')), + \ expand('') + \) + endif + + if g:ale_lint_on_insert_leave + autocmd InsertLeave * if ale#Var(str2nr(expand('')), 'lint_on_insert_leave') | call ale#Queue(0) | endif + endif + + if g:ale_echo_cursor || g:ale_cursor_detail + autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarningWithDelay() | endif + " Look for a warning to echo as soon as we leave Insert mode. + " The script's position variable used when moving the cursor will + " not be changed here. + autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#cursor#EchoCursorWarning() | endif + endif + + if g:ale_virtualtext_cursor == 1 + autocmd CursorMoved,CursorHold * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarningWithDelay() | endif + " Look for a warning to echo as soon as we leave Insert mode. + " The script's position variable used when moving the cursor will + " not be changed here. + autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarning() | endif + endif + + if g:ale_hover_cursor + autocmd CursorHold * if exists('*ale#lsp#Send') | call ale#hover#ShowTruncatedMessageAtCursor() | endif + endif + + if g:ale_close_preview_on_insert + autocmd InsertEnter * if exists('*ale#preview#CloseIfTypeMatches') | call ale#preview#CloseIfTypeMatches('ale-preview') | endif + endif + endif + augroup END + + augroup AleURISchemes + autocmd! + + autocmd BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('')) + augroup END +endfunction diff --git a/sources_non_forked/ale/autoload/ale/filename_mapping.vim b/sources_non_forked/ale/autoload/ale/filename_mapping.vim new file mode 100644 index 00000000..76d47acc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filename_mapping.vim @@ -0,0 +1,22 @@ +" Author: w0rp +" Description: Logic for handling mappings between files + +" Invert filesystem mappings so they can be mapped in reverse. +function! ale#filename_mapping#Invert(filename_mappings) abort + return map(copy(a:filename_mappings), '[v:val[1], v:val[0]]') +endfunction + +" Given a filename and some filename_mappings, map a filename. +function! ale#filename_mapping#Map(filename, filename_mappings) abort + let l:simplified_filename = ale#path#Simplify(a:filename) + + for [l:mapping_from, l:mapping_to] in a:filename_mappings + let l:mapping_from = ale#path#Simplify(l:mapping_from) + + if l:simplified_filename[:len(l:mapping_from) - 1] is# l:mapping_from + return l:mapping_to . l:simplified_filename[len(l:mapping_from):] + endif + endfor + + return a:filename +endfunction diff --git a/sources_non_forked/ale/autoload/ale/filerename.vim b/sources_non_forked/ale/autoload/ale/filerename.vim new file mode 100644 index 00000000..ec20d279 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filerename.vim @@ -0,0 +1,133 @@ +" Author: Dalius Dobravolskas +" Description: Rename file support for tsserver + +let s:filerename_map = {} + +" Used to get the rename map in tests. +function! ale#filerename#GetMap() abort + return deepcopy(s:filerename_map) +endfunction + +" Used to set the rename map in tests. +function! ale#filerename#SetMap(map) abort + let s:filerename_map = a:map +endfunction + +function! ale#filerename#ClearLSPData() abort + let s:filerename_map = {} +endfunction + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#filerename#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'getEditsForFileRename' + return + endif + + if !has_key(s:filerename_map, a:response.request_seq) + return + endif + + let l:options = remove(s:filerename_map, a:response.request_seq) + + let l:old_name = l:options.old_name + let l:new_name = l:options.new_name + + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error renaming file "' . l:old_name . '" to "' . l:new_name + \ . '". Reason: ' . l:message) + + return + endif + + let l:changes = a:response.body + + if empty(l:changes) + call s:message('No changes while renaming "' . l:old_name . '" to "' . l:new_name . '"') + else + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'filerename', + \ 'changes': l:changes, + \ }, + \ { + \ 'should_save': 1, + \ }, + \) + endif + + silent! noautocmd execute 'saveas ' . l:new_name + call delete(l:old_name) +endfunction + +function! s:OnReady(options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'filerename') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = function('ale#filerename#HandleTSServerResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#tsserver_message#GetEditsForFileRename( + \ a:options.old_name, + \ a:options.new_name, + \) + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:filerename_map[l:request_id] = a:options +endfunction + +function! s:ExecuteFileRename(linter, options) abort + let l:buffer = bufnr('') + + let l:Callback = function('s:OnReady', [a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#filerename#Execute() abort + let l:lsp_linters = [] + + for l:linter in ale#linter#Get(&filetype) + if l:linter.lsp is# 'tsserver' + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + call s:message('No active tsserver LSPs') + + return + endif + + let l:buffer = bufnr('') + let l:old_name = expand('#' . l:buffer . ':p') + let l:new_name = ale#util#Input('New file name: ', l:old_name, 'file') + + if l:old_name is# l:new_name + call s:message('New file name matches old file name') + + return + endif + + if empty(l:new_name) + call s:message('New name cannot be empty!') + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteFileRename(l:lsp_linter, { + \ 'old_name': l:old_name, + \ 'new_name': l:new_name, + \}) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/filetypes.vim b/sources_non_forked/ale/autoload/ale/filetypes.vim new file mode 100644 index 00000000..340a9c4e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/filetypes.vim @@ -0,0 +1,58 @@ +" Author: w0rp +" Description: This file handles guessing file extensions for filetypes, etc. + +function! ale#filetypes#LoadExtensionMap() abort + " Output includes: + " '*.erl setf erlang' + let l:output = execute('exec "autocmd"') + + let l:map = {} + + for l:line in split(l:output, "\n") + " Parse filetypes, like so: + " + " *.erl setf erlang + " *.md set filetype=markdown + " *.snippet setlocal filetype=snippets + let l:match = matchlist(l:line, '\v^ *\*(\.[^ ]+).*set(f *| *filetype=|local *filetype=)([^ ]+)') + + if !empty(l:match) + let l:map[substitute(l:match[3], '^=', '', '')] = l:match[1] + endif + endfor + + return l:map +endfunction + +let s:cached_map = {} + +function! s:GetCachedExtensionMap() abort + if empty(s:cached_map) + let s:cached_map = ale#filetypes#LoadExtensionMap() + endif + + return s:cached_map +endfunction + +function! ale#filetypes#GuessExtension(filetype) abort + let l:map = s:GetCachedExtensionMap() + let l:ext = get(l:map, a:filetype, '') + + " If we have an exact match, like something for javascript.jsx, use that. + if !empty(l:ext) + return l:ext + endif + + " If we don't have an exact match, use the first filetype in the compound + " filetype. + for l:part in split(a:filetype, '\.') + let l:ext = get(l:map, l:part, '') + + if !empty(l:ext) + return l:ext + endif + endfor + + " Return an empty string if we don't find anything. + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fix.vim b/sources_non_forked/ale/autoload/ale/fix.vim new file mode 100644 index 00000000..d9820847 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fix.vim @@ -0,0 +1,399 @@ +" Author: w0rp +" Description: Functions for fixing code with programs, or other means. + +let g:ale_fix_on_save_ignore = get(g:, 'ale_fix_on_save_ignore', {}) +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) + +" Apply fixes queued up for buffers which may be hidden. +" Vim doesn't let you modify hidden buffers. +function! ale#fix#ApplyQueuedFixes(buffer) abort + let l:data = get(g:ale_fix_buffer_data, a:buffer, {'done': 0}) + + if !l:data.done || (!ale#util#HasBuflineApi() && a:buffer isnot bufnr('')) + return + endif + + call remove(g:ale_fix_buffer_data, a:buffer) + + try + if l:data.changes_made + let l:new_lines = ale#util#SetBufferContents(a:buffer, l:data.output) + + if l:data.should_save + if a:buffer is bufnr('') + if empty(&buftype) + noautocmd :w! + else + set nomodified + endif + else + call writefile(l:new_lines, expand('#' . a:buffer . ':p')) " no-custom-checks + call setbufvar(a:buffer, '&modified', 0) + endif + endif + endif + catch /E21/ + " If we cannot modify the buffer now, try again later. + let g:ale_fix_buffer_data[a:buffer] = l:data + + return + endtry + + if l:data.should_save + let l:should_lint = ale#Var(a:buffer, 'fix_on_save') + \ && ale#Var(a:buffer, 'lint_on_save') + else + let l:should_lint = l:data.changes_made + endif + + silent doautocmd User ALEFixPost + + " If ALE linting is enabled, check for problems with the file again after + " fixing problems. + if g:ale_enabled + \&& l:should_lint + \&& !ale#events#QuitRecently(a:buffer) + call ale#Queue(0, l:data.should_save ? 'lint_file' : '') + endif +endfunction + +function! ale#fix#ApplyFixes(buffer, output) abort + let l:data = g:ale_fix_buffer_data[a:buffer] + let l:data.output = a:output + let l:data.changes_made = l:data.lines_before !=# l:data.output " no-custom-checks + let l:data.done = 1 + + call ale#command#RemoveManagedFiles(a:buffer) + + if !bufexists(a:buffer) + " Remove the buffer data when it doesn't exist. + call remove(g:ale_fix_buffer_data, a:buffer) + endif + + if l:data.changes_made && bufexists(a:buffer) + let l:lines = getbufline(a:buffer, 1, '$') + + if l:data.lines_before != l:lines + call remove(g:ale_fix_buffer_data, a:buffer) + + if !l:data.ignore_file_changed_errors + " no-custom-checks + echoerr 'The file was changed before fixing finished' + endif + + return + endif + endif + + " We can only change the lines of a buffer which is currently open, + " so try and apply the fixes to the current buffer. + call ale#fix#ApplyQueuedFixes(a:buffer) +endfunction + +function! s:HandleExit(job_info, buffer, job_output, data) abort + let l:buffer_info = get(g:ale_fix_buffer_data, a:buffer, {}) + + if empty(l:buffer_info) + return + endif + + if a:job_info.read_temporary_file + let l:output = !empty(a:data.temporary_file) + \ ? readfile(a:data.temporary_file) + \ : [] + else + let l:output = a:job_output + endif + + let l:ProcessWith = get(a:job_info, 'process_with', v:null) + + " Post-process the output with a function if we have one. + if l:ProcessWith isnot v:null + let l:output = call(l:ProcessWith, [a:buffer, l:output]) + endif + + " Use the output of the job for changing the file if it isn't empty, + " otherwise skip this job and use the input from before. + " + " We'll use the input from before for chained commands. + if !empty(split(join(l:output))) + let l:input = l:output + else + let l:input = a:job_info.input + endif + + call s:RunFixer({ + \ 'buffer': a:buffer, + \ 'input': l:input, + \ 'callback_list': a:job_info.callback_list, + \ 'callback_index': a:job_info.callback_index + 1, + \}) +endfunction + +function! s:RunJob(result, options) abort + if ale#command#IsDeferred(a:result) + let a:result.result_callback = {x -> s:RunJob(x, a:options)} + + return + endif + + let l:buffer = a:options.buffer + let l:input = a:options.input + let l:fixer_name = a:options.fixer_name + + if a:result is 0 || type(a:result) is v:t_list + if type(a:result) is v:t_list + let l:input = a:result + endif + + call s:RunFixer({ + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_index': a:options.callback_index + 1, + \ 'callback_list': a:options.callback_list, + \}) + + return + endif + + let l:command = get(a:result, 'command', '') + + if empty(l:command) + " If the command is empty, skip to the next item. + call s:RunFixer({ + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_index': a:options.callback_index, + \ 'callback_list': a:options.callback_list, + \}) + + return + endif + + let l:read_temporary_file = get(a:result, 'read_temporary_file', 0) + let l:read_buffer = get(a:result, 'read_buffer', 1) + let l:output_stream = get(a:result, 'output_stream', 'stdout') + let l:cwd = get(a:result, 'cwd', v:null) + + if l:read_temporary_file + let l:output_stream = 'none' + endif + + let l:Callback = function('s:HandleExit', [{ + \ 'input': l:input, + \ 'callback_index': a:options.callback_index, + \ 'callback_list': a:options.callback_list, + \ 'process_with': get(a:result, 'process_with', v:null), + \ 'read_temporary_file': l:read_temporary_file, + \}]) + let l:run_result = ale#command#Run(l:buffer, l:command, l:Callback, { + \ 'output_stream': l:output_stream, + \ 'executable': '', + \ 'read_buffer': l:read_buffer, + \ 'input': l:input, + \ 'log_output': 0, + \ 'cwd': l:cwd, + \ 'filename_mappings': ale#GetFilenameMappings(l:buffer, l:fixer_name), + \}) + + if empty(l:run_result) + call s:RunFixer({ + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_index': a:options.callback_index + 1, + \ 'callback_list': a:options.callback_list, + \}) + endif +endfunction + +function! s:RunFixer(options) abort + let l:buffer = a:options.buffer + let l:input = a:options.input + let l:index = a:options.callback_index + + if len(a:options.callback_list) <= l:index + call ale#fix#ApplyFixes(l:buffer, l:input) + + return + endif + + let [l:fixer_name, l:Function] = a:options.callback_list[l:index] + + " Record new jobs started as fixer jobs. + call setbufvar(l:buffer, 'ale_job_type', 'fixer') + + " Regular fixer commands accept (buffer, [input]) + let l:result = ale#util#FunctionArgCount(l:Function) == 1 + \ ? call(l:Function, [l:buffer]) + \ : call(l:Function, [l:buffer, copy(l:input)]) + + call s:RunJob(l:result, { + \ 'buffer': l:buffer, + \ 'input': l:input, + \ 'callback_list': a:options.callback_list, + \ 'callback_index': l:index, + \ 'fixer_name': l:fixer_name, + \}) +endfunction + +function! s:AddSubCallbacks(full_list, callbacks) abort + if type(a:callbacks) is v:t_string + call add(a:full_list, a:callbacks) + elseif type(a:callbacks) is v:t_list + call extend(a:full_list, a:callbacks) + else + return 0 + endif + + return 1 +endfunction + +function! s:IgnoreFixers(callback_list, filetype, config) abort + if type(a:config) is v:t_list + let l:ignore_list = a:config + else + let l:ignore_list = [] + + for l:part in split(a:filetype , '\.') + call extend(l:ignore_list, get(a:config, l:part, [])) + endfor + endif + + call filter(a:callback_list, 'index(l:ignore_list, v:val) < 0') +endfunction + +function! s:GetCallbacks(buffer, fixing_flag, fixers) abort + if len(a:fixers) + let l:callback_list = a:fixers + elseif type(get(b:, 'ale_fixers')) is v:t_list + " Lists can be used for buffer-local variables only + let l:callback_list = b:ale_fixers + else + " buffer and global options can use dictionaries mapping filetypes to + " callbacks to run. + let l:fixers = ale#Var(a:buffer, 'fixers') + let l:callback_list = [] + let l:matched = 0 + + for l:sub_type in split(&filetype, '\.') + if s:AddSubCallbacks(l:callback_list, get(l:fixers, l:sub_type)) + let l:matched = 1 + endif + endfor + + " If we couldn't find fixers for a filetype, default to '*' fixers. + if !l:matched + call s:AddSubCallbacks(l:callback_list, get(l:fixers, '*')) + endif + endif + + if a:fixing_flag is# 'save_file' + let l:config = ale#Var(a:buffer, 'fix_on_save_ignore') + + if !empty(l:config) + call s:IgnoreFixers(l:callback_list, &filetype, l:config) + endif + endif + + let l:corrected_list = [] + + " Variables with capital characters are needed, or Vim will complain about + " funcref variables. + for l:Item in l:callback_list + " Try to capture the names of registered fixer names, so we can use + " them for filename mapping or other purposes later. + let l:fixer_name = v:null + + if type(l:Item) is v:t_string + let l:Func = ale#fix#registry#GetFunc(l:Item) + + if !empty(l:Func) + let l:fixer_name = l:Item + let l:Item = l:Func + endif + endif + + try + call add(l:corrected_list, [ + \ l:fixer_name, + \ ale#util#GetFunction(l:Item) + \]) + catch /E475/ + " Rethrow exceptions for failing to get a function so we can print + " a friendly message about it. + throw 'BADNAME ' . v:exception + endtry + endfor + + return l:corrected_list +endfunction + +function! ale#fix#InitBufferData(buffer, fixing_flag) abort + " The 'done' flag tells the function for applying changes when fixing + " is complete. + let g:ale_fix_buffer_data[a:buffer] = { + \ 'lines_before': getbufline(a:buffer, 1, '$'), + \ 'done': 0, + \ 'should_save': a:fixing_flag is# 'save_file', + \ 'ignore_file_changed_errors': a:fixing_flag is# '!', + \ 'temporary_directory_list': [], + \} +endfunction + +" Accepts an optional argument for what to do when fixing. +" +" Returns 0 if no fixes can be applied, and 1 if fixing can be done. +function! ale#fix#Fix(buffer, fixing_flag, ...) abort + if a:fixing_flag isnot# '' + \&& a:fixing_flag isnot# '!' + \&& a:fixing_flag isnot# 'save_file' + throw "fixing_flag must be '', '!', or 'save_file'" + endif + + try + let l:callback_list = s:GetCallbacks(a:buffer, a:fixing_flag, a:000) + catch /E700\|BADNAME/ + if a:fixing_flag isnot# '!' + let l:function_name = join(split(split(v:exception, ':')[3])) + let l:echo_message = printf( + \ 'There is no fixer named `%s`. Check :ALEFixSuggest', + \ l:function_name, + \) + " no-custom-checks + echom l:echo_message + endif + + return 0 + endtry + + if empty(l:callback_list) + if a:fixing_flag is# '' + " no-custom-checks + echom 'No fixers have been defined. Try :ALEFixSuggest' + endif + + return 0 + endif + + call ale#command#StopJobs(a:buffer, 'fixer') + " Clean up any files we might have left behind from a previous run. + call ale#command#RemoveManagedFiles(a:buffer) + call ale#fix#InitBufferData(a:buffer, a:fixing_flag) + + silent doautocmd User ALEFixPre + + call s:RunFixer({ + \ 'buffer': a:buffer, + \ 'input': g:ale_fix_buffer_data[a:buffer].lines_before, + \ 'callback_index': 0, + \ 'callback_list': l:callback_list, + \}) + + return 1 +endfunction + +" Set up an autocmd command to try and apply buffer fixes when available. +augroup ALEBufferFixGroup + autocmd! + autocmd BufEnter * call ale#fix#ApplyQueuedFixes(str2nr(expand(''))) +augroup END diff --git a/sources_non_forked/ale/autoload/ale/fix/registry.vim b/sources_non_forked/ale/autoload/ale/fix/registry.vim new file mode 100644 index 00000000..2062f543 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fix/registry.vim @@ -0,0 +1,785 @@ +" Author: w0rp +" Description: A registry of functions for fixing things. + +let s:default_registry = { +\ 'add_blank_lines_for_python_control_statements': { +\ 'function': 'ale#fixers#generic_python#AddLinesBeforeControlStatements', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Add blank lines before control statements.', +\ }, +\ 'align_help_tags': { +\ 'function': 'ale#fixers#help#AlignTags', +\ 'suggested_filetypes': ['help'], +\ 'description': 'Align help tags to the right margin', +\ }, +\ 'autoimport': { +\ 'function': 'ale#fixers#autoimport#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix import issues with autoimport.', +\ }, +\ 'autoflake': { +\ 'function': 'ale#fixers#autoflake#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix flake issues with autoflake.', +\ }, +\ 'autopep8': { +\ 'function': 'ale#fixers#autopep8#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix PEP8 issues with autopep8.', +\ }, +\ 'bibclean': { +\ 'function': 'ale#fixers#bibclean#Fix', +\ 'suggested_filetypes': ['bib'], +\ 'description': 'Format bib files using bibclean.', +\ }, +\ 'black': { +\ 'function': 'ale#fixers#black#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix PEP8 issues with black.', +\ }, +\ 'buf-format': { +\ 'function': 'ale#fixers#buf_format#Fix', +\ 'suggested_filetypes': ['proto'], +\ 'description': 'Fix .proto files with buf format.', +\ }, +\ 'buildifier': { +\ 'function': 'ale#fixers#buildifier#Fix', +\ 'suggested_filetypes': ['bzl'], +\ 'description': 'Format BUILD and .bzl files with buildifier.', +\ }, +\ 'css-beautify': { +\ 'function': 'ale#fixers#css_beautify#Fix', +\ 'suggested_filetypes': ['css'], +\ 'description': 'Format CSS using css-beautify from js-beautify.', +\ }, +\ 'deno': { +\ 'function': 'ale#fixers#deno#Fix', +\ 'suggested_filetypes': ['typescript'], +\ 'description': 'Fix TypeScript using deno fmt.', +\ }, +\ 'dfmt': { +\ 'function': 'ale#fixers#dfmt#Fix', +\ 'suggested_filetypes': ['d'], +\ 'description': 'Fix D files with dfmt.', +\ }, +\ 'dhall': { +\ 'function': 'ale#fixers#dhall#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Fix Dhall files with dhall-format.', +\ }, +\ 'dhall-format': { +\ 'function': 'ale#fixers#dhall_format#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language', +\ 'aliases': ['dhall'], +\ }, +\ 'dhall-freeze': { +\ 'function': 'ale#fixers#dhall_freeze#Freeze', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Add integrity checks to remote import statements of an expression for the Dhall language', +\ }, +\ 'dhall-lint': { +\ 'function': 'ale#fixers#dhall_lint#Fix', +\ 'suggested_filetypes': ['dhall'], +\ 'description': 'Standard code formatter for the Dhall language and removing dead code', +\ }, +\ 'dune': { +\ 'function': 'ale#fixers#dune#Fix', +\ 'suggested_filetypes': ['dune'], +\ 'description': 'Fix dune files with dune format', +\ }, +\ 'fecs': { +\ 'function': 'ale#fixers#fecs#Fix', +\ 'suggested_filetypes': ['javascript', 'css', 'html'], +\ 'description': 'Apply fecs format to a file.', +\ }, +\ 'tidy': { +\ 'function': 'ale#fixers#tidy#Fix', +\ 'suggested_filetypes': ['html'], +\ 'description': 'Fix HTML files with tidy.', +\ }, +\ 'prettier_standard': { +\ 'function': 'ale#fixers#prettier_standard#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'Apply prettier-standard to a file.', +\ 'aliases': ['prettier-standard'], +\ }, +\ 'elm-format': { +\ 'function': 'ale#fixers#elm_format#Fix', +\ 'suggested_filetypes': ['elm'], +\ 'description': 'Apply elm-format to a file.', +\ 'aliases': ['format'], +\ }, +\ 'nimpretty': { +\ 'function': 'ale#fixers#nimpretty#Fix', +\ 'suggested_filetypes': ['nim'], +\ 'description': 'Apply nimpretty to a file.', +\ }, +\ 'erblint': { +\ 'function': 'ale#fixers#erblint#Fix', +\ 'suggested_filetypes': ['eruby'], +\ 'description': 'Apply erblint --autocorrect to a file.', +\ }, +\ 'eslint': { +\ 'function': 'ale#fixers#eslint#Fix', +\ 'suggested_filetypes': ['javascript', 'typescript'], +\ 'description': 'Apply eslint --fix to a file.', +\ }, +\ 'mix_format': { +\ 'function': 'ale#fixers#mix_format#Fix', +\ 'suggested_filetypes': ['elixir'], +\ 'description': 'Apply mix format to a file.', +\ }, +\ 'isort': { +\ 'function': 'ale#fixers#isort#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Sort Python imports with isort.', +\ }, +\ 'prettier': { +\ 'function': 'ale#fixers#prettier#Fix', +\ 'suggested_filetypes': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'json5', 'graphql', 'markdown', 'vue', 'svelte', 'html', 'yaml', 'openapi', 'ruby'], +\ 'description': 'Apply prettier to a file.', +\ }, +\ 'prettier_eslint': { +\ 'function': 'ale#fixers#prettier_eslint#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'Apply prettier-eslint to a file.', +\ 'aliases': ['prettier-eslint'], +\ }, +\ 'pyflyby': { +\ 'function': 'ale#fixers#pyflyby#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Tidy Python imports with pyflyby.', +\ }, +\ 'importjs': { +\ 'function': 'ale#fixers#importjs#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'automatic imports for javascript', +\ }, +\ 'puppetlint': { +\ 'function': 'ale#fixers#puppetlint#Fix', +\ 'suggested_filetypes': ['puppet'], +\ 'description': 'Run puppet-lint -f on a file.', +\ }, +\ 'remove_trailing_lines': { +\ 'function': 'ale#fixers#generic#RemoveTrailingBlankLines', +\ 'suggested_filetypes': [], +\ 'description': 'Remove all blank lines at the end of a file.', +\ }, +\ 'trim_whitespace': { +\ 'function': 'ale#fixers#generic#TrimWhitespace', +\ 'suggested_filetypes': [], +\ 'description': 'Remove all trailing whitespace characters at the end of every line.', +\ }, +\ 'yamlfix': { +\ 'function': 'ale#fixers#yamlfix#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Fix yaml files with yamlfix.', +\ }, +\ 'yapf': { +\ 'function': 'ale#fixers#yapf#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Fix Python files with yapf.', +\ }, +\ 'rubocop': { +\ 'function': 'ale#fixers#rubocop#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with rubocop --auto-correct.', +\ }, +\ 'rufo': { +\ 'function': 'ale#fixers#rufo#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with rufo', +\ }, +\ 'scalafmt': { +\ 'function': 'ale#fixers#scalafmt#Fix', +\ 'suggested_filetypes': ['sbt', 'scala'], +\ 'description': 'Fix Scala files using scalafmt', +\ }, +\ 'sorbet': { +\ 'function': 'ale#fixers#sorbet#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with srb tc --autocorrect.', +\ }, +\ 'standard': { +\ 'function': 'ale#fixers#standard#Fix', +\ 'suggested_filetypes': ['javascript'], +\ 'description': 'Fix JavaScript files using standard --fix', +\ }, +\ 'standardrb': { +\ 'function': 'ale#fixers#standardrb#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with standardrb --fix', +\ }, +\ 'statix': { +\ 'function': 'ale#fixers#statix#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'Fix common Nix antipatterns with statix fix', +\ }, +\ 'stylelint': { +\ 'function': 'ale#fixers#stylelint#Fix', +\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'], +\ 'description': 'Fix stylesheet files using stylelint --fix.', +\ }, +\ 'swiftformat': { +\ 'function': 'ale#fixers#swiftformat#Fix', +\ 'suggested_filetypes': ['swift'], +\ 'description': 'Apply SwiftFormat to a file.', +\ }, +\ 'syntax_tree': { +\ 'function': 'ale#fixers#syntax_tree#Fix', +\ 'suggested_filetypes': ['ruby'], +\ 'description': 'Fix ruby files with stree write', +\ }, +\ 'apple-swift-format': { +\ 'function': 'ale#fixers#appleswiftformat#Fix', +\ 'suggested_filetypes': ['swift'], +\ 'description': 'Apply apple/swift-format to a file.', +\ }, +\ 'phpcbf': { +\ 'function': 'ale#fixers#phpcbf#Fix', +\ 'suggested_filetypes': ['php'], +\ 'description': 'Fix PHP files with phpcbf.', +\ }, +\ 'php_cs_fixer': { +\ 'function': 'ale#fixers#php_cs_fixer#Fix', +\ 'suggested_filetypes': ['php'], +\ 'description': 'Fix PHP files with php-cs-fixer.', +\ }, +\ 'pint': { +\ 'function': 'ale#fixers#pint#Fix', +\ 'suggested_filetypes': ['php'], +\ 'description': 'Fix PHP files with Laravel Pint.', +\ }, +\ 'astyle': { +\ 'function': 'ale#fixers#astyle#Fix', +\ 'suggested_filetypes': ['c', 'cpp'], +\ 'description': 'Fix C/C++ with astyle.', +\ }, +\ 'clangtidy': { +\ 'function': 'ale#fixers#clangtidy#Fix', +\ 'suggested_filetypes': ['c', 'cpp', 'objc'], +\ 'description': 'Fix C/C++ and ObjectiveC files with clang-tidy.', +\ }, +\ 'clang-format': { +\ 'function': 'ale#fixers#clangformat#Fix', +\ 'suggested_filetypes': ['c', 'cpp', 'cuda'], +\ 'description': 'Fix C/C++ and cuda files with clang-format.', +\ }, +\ 'cmakeformat': { +\ 'function': 'ale#fixers#cmakeformat#Fix', +\ 'suggested_filetypes': ['cmake'], +\ 'description': 'Fix CMake files with cmake-format.', +\ }, +\ 'fish_indent': { +\ 'function': 'ale#fixers#fish_indent#Fix', +\ 'suggested_filetypes': ['fish'], +\ 'description': 'Format fish scripts using fish_indent.', +\ }, +\ 'gofmt': { +\ 'function': 'ale#fixers#gofmt#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with go fmt.', +\ }, +\ 'gofumpt': { +\ 'function': 'ale#fixers#gofumpt#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with gofumpt, a stricter go fmt.', +\ }, +\ 'goimports': { +\ 'function': 'ale#fixers#goimports#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files imports with goimports.', +\ }, +\ 'golines': { +\ 'function': 'ale#fixers#golines#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go file long lines with golines', +\ }, +\ 'gomod': { +\ 'function': 'ale#fixers#gomod#Fix', +\ 'suggested_filetypes': ['gomod'], +\ 'description': 'Fix Go module files with go mod edit -fmt.', +\ }, +\ 'tslint': { +\ 'function': 'ale#fixers#tslint#Fix', +\ 'suggested_filetypes': ['typescript'], +\ 'description': 'Fix typescript files with tslint --fix.', +\ }, +\ 'rustfmt': { +\ 'function': 'ale#fixers#rustfmt#Fix', +\ 'suggested_filetypes': ['rust'], +\ 'description': 'Fix Rust files with Rustfmt.', +\ }, +\ 'textlint': { +\ 'function': 'ale#fixers#textlint#Fix', +\ 'suggested_filetypes': ['text','markdown','asciidoc','tex'], +\ 'description': 'Fix text files with textlint --fix', +\ }, +\ 'hackfmt': { +\ 'function': 'ale#fixers#hackfmt#Fix', +\ 'suggested_filetypes': ['hack'], +\ 'description': 'Fix Hack files with hackfmt.', +\ }, +\ 'floskell': { +\ 'function': 'ale#fixers#floskell#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with floskell.', +\ }, +\ 'hfmt': { +\ 'function': 'ale#fixers#hfmt#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with hfmt.', +\ }, +\ 'brittany': { +\ 'function': 'ale#fixers#brittany#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with brittany.', +\ }, +\ 'hindent': { +\ 'function': 'ale#fixers#hindent#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with hindent.', +\ }, +\ 'hlint': { +\ 'function': 'ale#fixers#hlint#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Refactor Haskell files with hlint.', +\ }, +\ 'stylish-haskell': { +\ 'function': 'ale#fixers#stylish_haskell#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Refactor Haskell files with stylish-haskell.', +\ }, +\ 'purs-tidy': { +\ 'function': 'ale#fixers#purs_tidy#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purs-tidy.', +\ }, +\ 'purty': { +\ 'function': 'ale#fixers#purty#Fix', +\ 'suggested_filetypes': ['purescript'], +\ 'description': 'Format PureScript files with purty.', +\ }, +\ 'ocamlformat': { +\ 'function': 'ale#fixers#ocamlformat#Fix', +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], +\ 'description': 'Fix OCaml files with ocamlformat.', +\ }, +\ 'ocp-indent': { +\ 'function': 'ale#fixers#ocp_indent#Fix', +\ 'suggested_filetypes': ['ocaml', 'ocamlinterface'], +\ 'description': 'Fix OCaml files with ocp-indent.', +\ }, +\ 'refmt': { +\ 'function': 'ale#fixers#refmt#Fix', +\ 'suggested_filetypes': ['reason'], +\ 'description': 'Fix ReasonML files with refmt.', +\ }, +\ 'pandoc': { +\ 'function': 'ale#fixers#pandoc#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with pandoc.', +\ }, +\ 'shfmt': { +\ 'function': 'ale#fixers#shfmt#Fix', +\ 'suggested_filetypes': ['sh'], +\ 'description': 'Fix sh files with shfmt.', +\ }, +\ 'sqlfmt': { +\ 'function': 'ale#fixers#sqlfmt#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'Fix SQL files with sqlfmt.', +\ }, +\ 'sqlformat': { +\ 'function': 'ale#fixers#sqlformat#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'Fix SQL files with sqlformat.', +\ }, +\ 'google_java_format': { +\ 'function': 'ale#fixers#google_java_format#Fix', +\ 'suggested_filetypes': ['java'], +\ 'description': 'Fix Java files with google-java-format.', +\ }, +\ 'fixjson': { +\ 'function': 'ale#fixers#fixjson#Fix', +\ 'suggested_filetypes': ['json'], +\ 'description': 'Fix JSON files with fixjson.', +\ }, +\ 'jq': { +\ 'function': 'ale#fixers#jq#Fix', +\ 'suggested_filetypes': ['json'], +\ 'description': 'Fix JSON files with jq.', +\ }, +\ 'protolint': { +\ 'function': 'ale#fixers#protolint#Fix', +\ 'suggested_filetypes': ['proto'], +\ 'description': 'Fix Protocol Buffer files with protolint.', +\ }, +\ 'perltidy': { +\ 'function': 'ale#fixers#perltidy#Fix', +\ 'suggested_filetypes': ['perl'], +\ 'description': 'Fix Perl files with perltidy.', +\ }, +\ 'xo': { +\ 'function': 'ale#fixers#xo#Fix', +\ 'suggested_filetypes': ['javascript', 'typescript'], +\ 'description': 'Fix JavaScript/TypeScript files using xo --fix.', +\ }, +\ 'qmlfmt': { +\ 'function': 'ale#fixers#qmlfmt#Fix', +\ 'suggested_filetypes': ['qml'], +\ 'description': 'Fix QML files with qmlfmt.', +\ }, +\ 'dartfmt': { +\ 'function': 'ale#fixers#dartfmt#Fix', +\ 'suggested_filetypes': ['dart'], +\ 'description': 'Fix Dart files with dartfmt.', +\ }, +\ 'dart-format': { +\ 'function': 'ale#fixers#dart_format#Fix', +\ 'suggested_filetypes': ['dart'], +\ 'description': 'Fix Dart files with dart format.', +\ }, +\ 'dotnet-format': { +\ 'function': 'ale#fixers#dotnet_format#Fix', +\ 'suggested_filetypes': ['cs'], +\ 'description': 'Fix C# files with dotnet format.', +\ }, +\ 'xmllint': { +\ 'function': 'ale#fixers#xmllint#Fix', +\ 'suggested_filetypes': ['xml'], +\ 'description': 'Fix XML files with xmllint.', +\ }, +\ 'uncrustify': { +\ 'function': 'ale#fixers#uncrustify#Fix', +\ 'suggested_filetypes': ['c', 'cpp', 'cs', 'objc', 'objcpp', 'd', 'java', 'p', 'vala' ], +\ 'description': 'Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.', +\ }, +\ 'terraform': { +\ 'function': 'ale#fixers#terraform#Fix', +\ 'suggested_filetypes': ['hcl', 'terraform'], +\ 'description': 'Fix tf and hcl files with terraform fmt.', +\ }, +\ 'packer': { +\ 'function': 'ale#fixers#packer#Fix', +\ 'suggested_filetypes': ['hcl', 'packer'], +\ 'description': 'Fix Packer HCL files with packer fmt.', +\ }, +\ 'crystal': { +\ 'function': 'ale#fixers#crystal#Fix', +\ 'suggested_filetypes': ['cr'], +\ 'description': 'Fix cr (crystal).', +\ }, +\ 'ktlint': { +\ 'function': 'ale#fixers#ktlint#Fix', +\ 'suggested_filetypes': ['kt', 'kotlin'], +\ 'description': 'Fix Kotlin files with ktlint.', +\ }, +\ 'styler': { +\ 'function': 'ale#fixers#styler#Fix', +\ 'suggested_filetypes': ['r', 'rmarkdown', 'rmd'], +\ 'description': 'Fix R files with styler.', +\ }, +\ 'latexindent': { +\ 'function': 'ale#fixers#latexindent#Fix', +\ 'suggested_filetypes': ['tex'], +\ 'description' : 'Indent code within environments, commands, after headings and within special code blocks.', +\ }, +\ 'pgformatter': { +\ 'function': 'ale#fixers#pgformatter#Fix', +\ 'suggested_filetypes': ['sql'], +\ 'description': 'A PostgreSQL SQL syntax beautifier', +\ }, +\ 'reorder-python-imports': { +\ 'function': 'ale#fixers#reorder_python_imports#Fix', +\ 'suggested_filetypes': ['python'], +\ 'description': 'Sort Python imports with reorder-python-imports.', +\ }, +\ 'gnatpp': { +\ 'function': 'ale#fixers#gnatpp#Fix', +\ 'suggested_filetypes': ['ada'], +\ 'description': 'Format Ada files with gnatpp.', +\ }, +\ 'nixfmt': { +\ 'function': 'ale#fixers#nixfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A nix formatter written in Haskell.', +\ }, +\ 'nixpkgs-fmt': { +\ 'function': 'ale#fixers#nixpkgsfmt#Fix', +\ 'suggested_filetypes': ['nix'], +\ 'description': 'A formatter for Nix code', +\ }, +\ 'remark-lint': { +\ 'function': 'ale#fixers#remark_lint#Fix', +\ 'suggested_filetypes': ['markdown'], +\ 'description': 'Fix markdown files with remark-lint', +\ }, +\ 'html-beautify': { +\ 'function': 'ale#fixers#html_beautify#Fix', +\ 'suggested_filetypes': ['html', 'htmldjango'], +\ 'description': 'Fix HTML files with html-beautify from js-beautify.', +\ }, +\ 'lua-format': { +\ 'function': 'ale#fixers#lua_format#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with lua-format.', +\ }, +\ 'luafmt': { +\ 'function': 'ale#fixers#luafmt#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with luafmt.', +\ }, +\ 'dprint': { +\ 'function': 'ale#fixers#dprint#Fix', +\ 'suggested_filetypes': ['dockerfile', 'javascript', 'json', 'markdown', 'toml', 'typescript'], +\ 'description': 'Pluggable and configurable code formatting platform', +\ }, +\ 'stylua': { +\ 'function': 'ale#fixers#stylua#Fix', +\ 'suggested_filetypes': ['lua'], +\ 'description': 'Fix Lua files with stylua.', +\ }, +\ 'ormolu': { +\ 'function': 'ale#fixers#ormolu#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'A formatter for Haskell source code.', +\ }, +\ 'jsonnetfmt': { +\ 'function': 'ale#fixers#jsonnetfmt#Fix', +\ 'suggested_filetypes': ['jsonnet'], +\ 'description': 'Fix jsonnet files with jsonnetfmt', +\ }, +\ 'ptop': { +\ 'function': 'ale#fixers#ptop#Fix', +\ 'suggested_filetypes': ['pascal'], +\ 'description': 'Fix Pascal files with ptop.', +\ }, +\ 'opafmt': { +\ 'function': 'ale#fixers#opafmt#Fix', +\ 'suggested_filetypes': ['rego'], +\ 'description': 'Fix rego files with opa fmt.', +\ }, +\ 'vfmt': { +\ 'function': 'ale#fixers#vfmt#Fix', +\ 'suggested_filetypes': ['v'], +\ 'description': 'A formatter for V source code.', +\ }, +\ 'zigfmt': { +\ 'function': 'ale#fixers#zigfmt#Fix', +\ 'suggested_filetypes': ['zig'], +\ 'description': 'Official formatter for Zig', +\ }, +\ 'raco_fmt': { +\ 'function': 'ale#fixers#raco_fmt#Fix', +\ 'suggested_filetypes': ['racket'], +\ 'description': 'Fix Racket files with raco fmt.', +\ } +\} + +" Reset the function registry to the default entries. +function! ale#fix#registry#ResetToDefaults() abort + let s:entries = deepcopy(s:default_registry) + let s:aliases = {} + + " Set up aliases for fixers too. + for [l:key, l:entry] in items(s:entries) + for l:alias in get(l:entry, 'aliases', []) + let s:aliases[l:alias] = l:key + endfor + endfor +endfunction + +" Set up entries now. +call ale#fix#registry#ResetToDefaults() + +" Remove everything from the registry, useful for tests. +function! ale#fix#registry#Clear() abort + let s:entries = {} + let s:aliases = {} +endfunction + +" Add a function for fixing problems to the registry. +" (name, func, filetypes, desc, aliases) +function! ale#fix#registry#Add(name, func, filetypes, desc, ...) abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + + if type(a:name) isnot v:t_string + throw '''name'' must be a String' + endif + + if type(a:func) isnot v:t_string + throw '''func'' must be a String' + endif + + if type(a:filetypes) isnot v:t_list + throw '''filetypes'' must be a List' + endif + + for l:type in a:filetypes + if type(l:type) isnot v:t_string + throw 'Each entry of ''filetypes'' must be a String' + endif + endfor + + if type(a:desc) isnot v:t_string + throw '''desc'' must be a String' + endif + + let l:aliases = get(a:000, 0, []) + + if type(l:aliases) isnot v:t_list + \|| !empty(filter(copy(l:aliases), 'type(v:val) isnot v:t_string')) + throw '''aliases'' must be a List of String values' + endif + + let s:entries[a:name] = { + \ 'function': a:func, + \ 'suggested_filetypes': a:filetypes, + \ 'description': a:desc, + \} + + " Set up aliases for the fixer. + if !empty(l:aliases) + let s:entries[a:name].aliases = l:aliases + + for l:alias in l:aliases + let s:aliases[l:alias] = a:name + endfor + endif +endfunction + +" Get a function from the registry by its short name. +function! ale#fix#registry#GetFunc(name) abort + " Use the exact name, or an alias. + let l:resolved_name = !has_key(s:entries, a:name) + \ ? get(s:aliases, a:name, a:name) + \ : a:name + + return get(s:entries, l:resolved_name, {'function': ''}).function +endfunction + +function! s:ShouldSuggestForType(suggested_filetypes, type_list) abort + for l:type in a:type_list + if index(a:suggested_filetypes, l:type) >= 0 + return 1 + endif + endfor + + return 0 +endfunction + +function! s:IsGenericFixer(suggested_filetypes) abort + if empty(a:suggested_filetypes) + return 1 + endif + + return 0 +endfunction + +function! s:FormatEntry(key, entry) abort + let l:aliases_str = '' + + " Show aliases in :ALEFixSuggest if they are there. + if !empty(get(a:entry, 'aliases', [])) + let l:aliases_str = ', ' . join( + \ map(copy(a:entry.aliases), 'string(v:val)'), + \ ',' + \) + endif + + return printf( + \ '%s%s - %s', + \ string(a:key), + \ l:aliases_str, + \ a:entry.description, + \) +endfunction + +" Get list of applicable fixers for filetype, including generic fixers +function! ale#fix#registry#GetApplicableFixers(filetype) abort + let l:type_list = split(a:filetype, '\.') + let l:fixer_name_list = [] + + for l:key in sort(keys(s:entries)) + let l:suggested_filetypes = s:entries[l:key].suggested_filetypes + + if s:IsGenericFixer(l:suggested_filetypes) || s:ShouldSuggestForType(l:suggested_filetypes, l:type_list) + call add(l:fixer_name_list, l:key) + endif + endfor + + return l:fixer_name_list +endfunction + +" Function that returns autocomplete candidates for ALEFix command +function! ale#fix#registry#CompleteFixers(ArgLead, CmdLine, CursorPos) abort + return filter(ale#fix#registry#GetApplicableFixers(&filetype), 'v:val =~? a:ArgLead') +endfunction + +function! ale#fix#registry#SuggestedFixers(filetype) abort + let l:type_list = split(a:filetype, '\.') + let l:filetype_fixer_list = [] + + for l:key in sort(keys(s:entries)) + let l:suggested_filetypes = s:entries[l:key].suggested_filetypes + + if s:ShouldSuggestForType(l:suggested_filetypes, l:type_list) + call add( + \ l:filetype_fixer_list, + \ s:FormatEntry(l:key, s:entries[l:key]), + \) + endif + endfor + + let l:generic_fixer_list = [] + + for l:key in sort(keys(s:entries)) + if s:IsGenericFixer(s:entries[l:key].suggested_filetypes) + call add( + \ l:generic_fixer_list, + \ s:FormatEntry(l:key, s:entries[l:key]), + \) + endif + endfor + + return [l:filetype_fixer_list, l:generic_fixer_list] +endfunction + +" Suggest functions to use from the registry. +function! ale#fix#registry#Suggest(filetype) abort + let l:suggested = ale#fix#registry#SuggestedFixers(a:filetype) + let l:filetype_fixer_list = l:suggested[0] + let l:generic_fixer_list = l:suggested[1] + + let l:filetype_fixer_header = !empty(l:filetype_fixer_list) + \ ? ['Try the following fixers appropriate for the filetype:', ''] + \ : [] + let l:generic_fixer_header = !empty(l:generic_fixer_list) + \ ? ['Try the following generic fixers:', ''] + \ : [] + + let l:has_both_lists = !empty(l:filetype_fixer_list) && !empty(l:generic_fixer_list) + + let l:lines = + \ l:filetype_fixer_header + \ + l:filetype_fixer_list + \ + (l:has_both_lists ? [''] : []) + \ + l:generic_fixer_header + \ + l:generic_fixer_list + + if empty(l:lines) + let l:lines = ['There is nothing in the registry to suggest.'] + else + let l:lines += ['', 'See :help ale-fix-configuration'] + endif + + let l:lines += ['', 'Press q to close this window'] + + new +set\ filetype=ale-fix-suggest + call setline(1, l:lines) + setlocal nomodified + setlocal nomodifiable +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim new file mode 100644 index 00000000..ca27e82c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/appleswiftformat.vim @@ -0,0 +1,16 @@ +" Author: (bosr) +" Description: Integration of apple/swift-format formatter with ALE. + +function! ale#fixers#appleswiftformat#Fix(buffer) abort + let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' format --in-place %t' + let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer) + + if l:config_args isnot# '' + let l:command_args = l:command_args . ' ' . l:config_args + endif + + return { + \ 'read_temporary_file': 1, + \ 'command': l:command_args, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/astyle.vim b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim new file mode 100644 index 00000000..3a5a70a1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/astyle.vim @@ -0,0 +1,59 @@ +" Author: James Kim +" Description: Fix C/C++ files with astyle. + +function! s:set_variables() abort + for l:ft in ['c', 'cpp'] + call ale#Set(l:ft . '_astyle_executable', 'astyle') + call ale#Set(l:ft . '_astyle_project_options', '') + endfor +endfunction + +call s:set_variables() + + +function! ale#fixers#astyle#Var(buffer, name) abort + let l:ft = getbufvar(str2nr(a:buffer), '&filetype') + let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c' + + return ale#Var(a:buffer, l:ft . '_astyle_' . a:name) +endfunction + +" Try to find a project options file. +function! ale#fixers#astyle#FindProjectOptions(buffer) abort + let l:proj_options = ale#fixers#astyle#Var(a:buffer, 'project_options') + + " If user has set project options variable then use it and skip any searching. + " This would allow users to use project files named differently than .astylerc. + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest .astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '.astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " Try to find nearest _astylerc file. + let l:proj_options = fnamemodify(ale#path#FindNearestFile(a:buffer, '_astylerc'), ':t') + + if !empty(l:proj_options) + return l:proj_options + endif + + " If no project options file is found return an empty string. + return '' +endfunction + +function! ale#fixers#astyle#Fix(buffer) abort + let l:executable = ale#fixers#astyle#Var(a:buffer, 'executable') + let l:proj_options = ale#fixers#astyle#FindProjectOptions(a:buffer) + let l:command = ' --stdin=' . ale#Escape(expand('#' . a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:proj_options) ? '' : ' --project=' . l:proj_options) + \ . l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim new file mode 100644 index 00000000..e2ad6536 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoflake.vim @@ -0,0 +1,28 @@ +" Author: circld +" Description: Fixing files with autoflake. + +call ale#Set('python_autoflake_executable', 'autoflake') +call ale#Set('python_autoflake_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_autoflake_options', '') + +function! ale#fixers#autoflake#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autoflake', + \ ['autoflake'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:options = ale#Var(a:buffer, 'python_autoflake_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --in-place ' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim new file mode 100644 index 00000000..700d36b5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autoimport.vim @@ -0,0 +1,27 @@ +" Author: lyz-code +" Description: Fixing Python imports with autoimport. + +call ale#Set('python_autoimport_executable', 'autoimport') +call ale#Set('python_autoimport_options', '') +call ale#Set('python_autoimport_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#autoimport#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'python_autoimport_options') + + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autoimport', + \ ['autoimport'], + \) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim new file mode 100644 index 00000000..5798d827 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/autopep8.vim @@ -0,0 +1,26 @@ +" Author: w0rp +" Description: Fixing files with autopep8. + +call ale#Set('python_autopep8_executable', 'autopep8') +call ale#Set('python_autopep8_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_autopep8_options', '') + +function! ale#fixers#autopep8#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_autopep8', + \ ['autopep8'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:options = ale#Var(a:buffer, 'python_autopep8_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/bibclean.vim b/sources_non_forked/ale/autoload/ale/fixers/bibclean.vim new file mode 100644 index 00000000..89cb97ab --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/bibclean.vim @@ -0,0 +1,15 @@ +" Author: Horacio Sanson - https://github.com/hsanson +" Description: Support for bibclean fixer for BibTeX files. + +call ale#Set('bib_bibclean_executable', 'bibclean') +call ale#Set('bib_bibclean_options', '-align-equals') + +function! ale#fixers#bibclean#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'bib_bibclean_options') + let l:executable = ale#Var(a:buffer, 'bib_bibclean_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . (empty(l:options) ? '' : l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/black.vim b/sources_non_forked/ale/autoload/ale/fixers/black.vim new file mode 100644 index 00000000..4a88c5cd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/black.vim @@ -0,0 +1,52 @@ +" Author: w0rp +" Description: Fixing Python files with black. +" +call ale#Set('python_black_executable', 'black') +call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_black_options', '') +call ale#Set('python_black_auto_pipenv', 0) +call ale#Set('python_black_auto_poetry', 0) +call ale#Set('python_black_change_directory', 1) + +function! ale#fixers#black#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_black_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_black_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_black', ['black']) +endfunction + +function! ale#fixers#black#Fix(buffer) abort + let l:executable = ale#fixers#black#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'black']) + endif + + let l:options = ale#Var(a:buffer, 'python_black_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + if expand('#' . a:buffer . ':e') is? 'pyi' + call add(l:cmd, '--pyi') + endif + + call add(l:cmd, '-') + + let l:result = {'command': join(l:cmd, ' ')} + + if ale#Var(a:buffer, 'python_black_change_directory') + let l:result.cwd = '%s:h' + endif + + return l:result +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/brittany.vim b/sources_non_forked/ale/autoload/ale/fixers/brittany.vim new file mode 100644 index 00000000..c2448348 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/brittany.vim @@ -0,0 +1,22 @@ +" Author: eborden , ifyouseewendy , aspidiets +" Description: Integration of brittany with ALE. + +call ale#Set('haskell_brittany_executable', 'brittany') + +function! ale#fixers#brittany#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_brittany_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'brittany') +endfunction + +function! ale#fixers#brittany#Fix(buffer) abort + let l:executable = ale#fixers#brittany#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --write-mode inplace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim b/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim new file mode 100644 index 00000000..c2c156b7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/buf_format.vim @@ -0,0 +1,12 @@ +" Author: Alex McKinney +" Description: Run buf format. + +call ale#Set('proto_buf_format_executable', 'buf') + +function! ale#fixers#buf_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'proto_buf_format_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' format %t', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim new file mode 100644 index 00000000..48103b2e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/buildifier.vim @@ -0,0 +1,26 @@ +" Author: Jon Parise +" Description: Format Bazel BUILD and .bzl files with buildifier. +" +call ale#Set('bazel_buildifier_executable', 'buildifier') +call ale#Set('bazel_buildifier_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('bazel_buildifier_options', '') + +function! ale#fixers#buildifier#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'bazel_buildifier', [ + \ 'buildifier', + \]) +endfunction + +function! ale#fixers#buildifier#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#buildifier#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'bazel_buildifier_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + let l:command = l:executable . ' -mode fix -lint fix -path ' . l:filename + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return {'command': l:command . ' -'} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim new file mode 100644 index 00000000..81498ebd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/clangformat.vim @@ -0,0 +1,47 @@ +scriptencoding utf-8 +" Author: Peter Renström +" Description: Fixing C/C++ files with clang-format. + +call ale#Set('c_clangformat_executable', 'clang-format') +call ale#Set('c_clangformat_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('c_clangformat_options', '') +call ale#Set('c_clangformat_style_option', '') +call ale#Set('c_clangformat_use_local_file', 0) + +function! ale#fixers#clangformat#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'c_clangformat', [ + \ 'clang-format', + \]) +endfunction + +function! ale#fixers#clangformat#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#clangformat#GetExecutable(a:buffer)) + let l:filename = ale#Escape(bufname(a:buffer)) + let l:options = ale#Var(a:buffer, 'c_clangformat_options') + let l:style_option = ale#Var(a:buffer, 'c_clangformat_style_option') + let l:use_local_file = ale#Var(a:buffer, 'c_clangformat_use_local_file') + + if l:style_option isnot# '' + let l:style_option = '-style=' . "'" . l:style_option . "'" + endif + + if l:use_local_file + let l:config = ale#path#FindNearestFile(a:buffer, '.clang-format') + + if !empty(l:config) + let l:style_option = '-style=file' + endif + endif + + if l:style_option isnot# '' + let l:options .= ' ' . l:style_option + endif + + let l:command = l:executable . ' --assume-filename=' . l:filename + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return {'command': l:command} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/clangtidy.vim b/sources_non_forked/ale/autoload/ale/fixers/clangtidy.vim new file mode 100644 index 00000000..b37360a7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/clangtidy.vim @@ -0,0 +1,52 @@ +scriptencoding utf-8 +" Author: ObserverOfTime +" Description: Fixing C/C++ files with clang-tidy. + +function! s:set_variables() abort + let l:use_global = get(g:, 'ale_use_global_executables', 0) + + for l:ft in ['c', 'cpp'] + call ale#Set(l:ft . '_clangtidy_executable', 'clang-tidy') + call ale#Set(l:ft . '_clangtidy_use_global', l:use_global) + call ale#Set(l:ft . '_clangtidy_checks', []) + call ale#Set(l:ft . '_clangtidy_options', '') + call ale#Set(l:ft . '_clangtidy_extra_options', '') + call ale#Set(l:ft . '_clangtidy_fix_errors', 1) + endfor + + call ale#Set('c_build_dir', '') +endfunction + +call s:set_variables() + +function! ale#fixers#clangtidy#Var(buffer, name) abort + let l:ft = getbufvar(str2nr(a:buffer), '&filetype') + let l:ft = l:ft =~# 'cpp' ? 'cpp' : 'c' + + return ale#Var(a:buffer, l:ft . '_clangtidy_' . a:name) +endfunction + +function! ale#fixers#clangtidy#GetCommand(buffer) abort + let l:checks = join(ale#fixers#clangtidy#Var(a:buffer, 'checks'), ',') + let l:extra_options = ale#fixers#clangtidy#Var(a:buffer, 'extra_options') + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:options = empty(l:build_dir) + \ ? ale#fixers#clangtidy#Var(a:buffer, 'options') : '' + let l:fix_errors = ale#fixers#clangtidy#Var(a:buffer, 'fix_errors') + + return ' -fix' . (l:fix_errors ? ' -fix-errors' : '') + \ . (empty(l:checks) ? '' : ' -checks=' . ale#Escape(l:checks)) + \ . (empty(l:extra_options) ? '' : ' ' . l:extra_options) + \ . (empty(l:build_dir) ? '' : ' -p ' . ale#Escape(l:build_dir)) + \ . ' %t' . (empty(l:options) ? '' : ' -- ' . l:options) +endfunction + +function! ale#fixers#clangtidy#Fix(buffer) abort + let l:executable = ale#fixers#clangtidy#Var(a:buffer, 'executable') + let l:command = ale#fixers#clangtidy#GetCommand(a:buffer) + + return { + \ 'command': ale#Escape(l:executable) . l:command, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim new file mode 100644 index 00000000..dcc29cf3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/cmakeformat.vim @@ -0,0 +1,16 @@ +" Author: Attila Maczak +" Description: Integration of cmakeformat with ALE. + +call ale#Set('cmake_cmakeformat_executable', 'cmake-format') +call ale#Set('cmake_cmakeformat_options', '') + +function! ale#fixers#cmakeformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'cmake_cmakeformat_executable') + let l:options = ale#Var(a:buffer, 'cmake_cmakeformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/crystal.vim b/sources_non_forked/ale/autoload/ale/fixers/crystal.vim new file mode 100644 index 00000000..4ba702ba --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/crystal.vim @@ -0,0 +1,14 @@ +call ale#Set('crystal_format_executable', 'crystal') +call ale#Set('crystal_format_options', '') + +function! ale#fixers#crystal#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'crystal_format_executable') + let l:options = ale#Var(a:buffer, 'crystal_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' tool format' + \ . ale#Pad(l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim b/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim new file mode 100644 index 00000000..14a837c4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/css_beautify.vim @@ -0,0 +1,20 @@ +" Author: https://github.com/Spixmaster +" Description: Format CSS using css-beautify from js-beautify. + +call ale#Set('css_css_beautify_executable', 'css-beautify') +call ale#Set('css_css_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('css_css_beautify_options', '') + +function! ale#fixers#css_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'css_css_beautify', + \ ['css-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'css_css_beautify_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim new file mode 100644 index 00000000..4b8f730b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dart_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dart format with ALE. + +call ale#Set('dart_format_executable', 'dart') +call ale#Set('dart_format_options', '') + +function! ale#fixers#dart_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_format_executable') + let l:options = ale#Var(a:buffer, 'dart_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dartfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/dartfmt.vim new file mode 100644 index 00000000..0687d6d1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dartfmt.vim @@ -0,0 +1,18 @@ +" Author: reisub0 +" Description: Integration of dartfmt with ALE. + +call ale#Set('dart_dartfmt_executable', 'dartfmt') +call ale#Set('dart_dartfmt_options', '') + +function! ale#fixers#dartfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'dart_dartfmt_executable') + let l:options = ale#Var(a:buffer, 'dart_dartfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/deno.vim b/sources_non_forked/ale/autoload/ale/fixers/deno.vim new file mode 100644 index 00000000..7154c6ee --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/deno.vim @@ -0,0 +1,17 @@ +function! ale#fixers#deno#Fix(buffer) abort + let l:executable = ale#handlers#deno#GetExecutable(a:buffer) + + if !executable(l:executable) + return 0 + endif + + let l:options = ' fmt -' + + if ale#Var(a:buffer, 'deno_unstable') + let l:options = l:options . ' --unstable' + endif + + return { + \ 'command': ale#Escape(l:executable) . l:options + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim new file mode 100644 index 00000000..0072e045 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dfmt.vim @@ -0,0 +1,18 @@ +" Author: theoldmoon0602 +" Description: Integration of dfmt with ALE. + +call ale#Set('d_dfmt_executable', 'dfmt') +call ale#Set('d_dfmt_options', '') + +function! ale#fixers#dfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'd_dfmt_executable') + let l:options = ale#Var(a:buffer, 'd_dfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim new file mode 100644 index 00000000..4f12abc8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_format.vim @@ -0,0 +1,11 @@ +" Author: toastal +" Description: Dhall’s built-in formatter +" +function! ale#fixers#dhall_format#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' format' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim new file mode 100644 index 00000000..ff54482d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_freeze.vim @@ -0,0 +1,14 @@ +" Author: toastal +" Description: Dhall’s package freezing + +call ale#Set('dhall_freeze_options', '') + +function! ale#fixers#dhall_freeze#Freeze(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' freeze' + \ . ale#Pad(ale#Var(a:buffer, 'dhall_freeze_options')) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim new file mode 100644 index 00000000..149a6581 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dhall_lint.vim @@ -0,0 +1,11 @@ +" Author: toastal +" Description: Dhall’s built-in linter/formatter + +function! ale#fixers#dhall_lint#Fix(buffer) abort + let l:executable = ale#dhall#GetExecutableWithOptions(a:buffer) + + return { + \ 'command': l:executable + \ . ' lint' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim b/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim new file mode 100644 index 00000000..b44a28bd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dotnet_format.vim @@ -0,0 +1,18 @@ +" Author: ghsang +" Description: Integration of dotnet format with ALE. + +call ale#Set('cs_dotnet_format_executable', 'dotnet') +call ale#Set('cs_dotnet_format_options', '') + +function! ale#fixers#dotnet_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'cs_dotnet_format_executable') + let l:options = ale#Var(a:buffer, 'cs_dotnet_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --folder --include %t "$(dirname %t)"', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dprint.vim b/sources_non_forked/ale/autoload/ale/fixers/dprint.vim new file mode 100644 index 00000000..99e590df --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dprint.vim @@ -0,0 +1,29 @@ +call ale#Set('dprint_executable', 'dprint') +call ale#Set('dprint_executable_override', 0) +call ale#Set('dprint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('dprint_options', '') +call ale#Set('dprint_config', 'dprint.json') + +function! ale#fixers#dprint#Fix(buffer) abort + let l:executable = ale#path#FindExecutable(a:buffer, 'dprint', ['dprint']) + let l:executable_override = ale#Var(a:buffer, 'dprint_executable_override') + + if !executable(l:executable) && !l:executable_override + return 0 + endif + + let l:options = ale#Var(a:buffer, 'dprint_options') + let l:config = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'dprint_config')) + + if !empty(l:config) + let l:options = l:options . ' -c ' . ale#Escape(l:config) + endif + + let l:options = l:options . ' --stdin %s' + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt ' + \ . l:options + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/dune.vim b/sources_non_forked/ale/autoload/ale/fixers/dune.vim new file mode 100644 index 00000000..6ef7ec9f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/dune.vim @@ -0,0 +1,16 @@ +" Author: Albert Peschar +" Description: Fix files with dune format. + +call ale#Set('ocaml_dune_executable', 'dune') +call ale#Set('ocaml_dune_options', '') + +function! ale#fixers#dune#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ocaml_dune_executable') + let l:options = ale#Var(a:buffer, 'ocaml_dune_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim new file mode 100644 index 00000000..a4740db4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/elm_format.vim @@ -0,0 +1,23 @@ +" Author: soywod +" Description: Integration of elm-format with ALE. + +call ale#Set('elm_format_executable', 'elm-format') +call ale#Set('elm_format_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('elm_format_options', '--yes') + +function! ale#fixers#elm_format#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'elm_format', [ + \ 'node_modules/.bin/elm-format', + \]) +endfunction + +function! ale#fixers#elm_format#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'elm_format_options') + + return { + \ 'command': ale#Escape(ale#fixers#elm_format#GetExecutable(a:buffer)) + \ . ' %t' + \ . (empty(l:options) ? '' : ' ' . l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erblint.vim b/sources_non_forked/ale/autoload/ale/fixers/erblint.vim new file mode 100644 index 00000000..41aca0c8 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erblint.vim @@ -0,0 +1,40 @@ +" Author: Roeland Moors - https://github.com/roelandmoors +" Description: ERB Lint, support for https://github.com/Shopify/erb-lint + +call ale#Set('eruby_erblint_executable', 'erblint') +call ale#Set('eruby_erblint_options', '') + + +" Erblint fixer outputs diagnostics first and then the fixed +" output. These are delimited by something like this: +" ================ /path/to/demo.html.erb ================== +" We only need the output after this +function! ale#fixers#erblint#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+.*=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + +function! ale#fixers#erblint#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'eruby_erblint_executable') + let l:options = ale#Var(a:buffer, 'eruby_erblint_options') + + return ale#ruby#EscapeExecutable(l:executable, 'erblint') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --autocorrect --stdin %s' +endfunction + +function! ale#fixers#erblint#Fix(buffer) abort + return { + \ 'command': ale#fixers#erblint#GetCommand(a:buffer), + \ 'process_with': 'ale#fixers#erblint#PostProcess' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim new file mode 100644 index 00000000..f9951e9d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/erlfmt.vim @@ -0,0 +1,21 @@ +" Author: AntoineGagne - https://github.com/AntoineGagne +" Description: Integration of erlfmt with ALE. + +call ale#Set('erlang_erlfmt_executable', 'erlfmt') +call ale#Set('erlang_erlfmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('erlang_erlfmt_options', '') + +function! ale#fixers#erlfmt#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'erlang_erlfmt', ['erlfmt']) +endfunction + +function! ale#fixers#erlfmt#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'erlang_erlfmt_options') + let l:executable = ale#fixers#erlfmt#GetExecutable(a:buffer) + + let l:command = ale#Escape(l:executable) . (empty(l:options) ? '' : ' ' . l:options) . ' %s' + + return { + \ 'command': l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim new file mode 100644 index 00000000..c9535cb0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/eslint.vim @@ -0,0 +1,83 @@ +" Author: w0rp +" Description: Fixing files with eslint. + +function! ale#fixers#eslint#Fix(buffer) abort + let l:executable = ale#handlers#eslint#GetExecutable(a:buffer) + let l:command = ale#node#Executable(a:buffer, l:executable) + \ . ' --version' + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#eslint#ApplyFixForVersion'), + \) +endfunction + +function! ale#fixers#eslint#ProcessFixDryRunOutput(buffer, output) abort + for l:item in ale#util#FuzzyJSONDecode(a:output, []) + return split(get(l:item, 'output', ''), "\n") + endfor + + return [] +endfunction + +function! ale#fixers#eslint#ProcessEslintDOutput(buffer, output) abort + " If the output is an error message, don't use it. + for l:line in a:output[:10] + if l:line =~# '\v^Error:|^Could not connect' + return [] + endif + endfor + + return a:output +endfunction + +function! ale#fixers#eslint#ApplyFixForVersion(buffer, version) abort + let l:executable = ale#handlers#eslint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'javascript_eslint_options') + + " Use the configuration file from the options, if configured. + if l:options =~# '\v(^| )-c|(^| )--config' + let l:config = '' + let l:has_config = 1 + else + let l:config = ale#handlers#eslint#FindConfig(a:buffer) + let l:has_config = !empty(l:config) + endif + + if !l:has_config + return 0 + endif + + " Use --fix-to-stdout with eslint_d + if l:executable =~# 'eslint_d$' && ale#semver#GTE(a:version, [3, 19, 0]) + return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . ale#Pad(l:options) + \ . ' --stdin-filename %s --stdin --fix-to-stdout', + \ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput', + \} + endif + + " 4.9.0 is the first version with --fix-dry-run + if ale#semver#GTE(a:version, [4, 9, 0]) + return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . ale#Pad(l:options) + \ . ' --stdin-filename %s --stdin --fix-dry-run --format=json', + \ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput', + \} + endif + + return { + \ 'cwd': ale#handlers#eslint#GetCwd(a:buffer), + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . ale#Pad(l:options) + \ . (!empty(l:config) ? ' -c ' . ale#Escape(l:config) : '') + \ . ' --fix %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fecs.vim b/sources_non_forked/ale/autoload/ale/fixers/fecs.vim new file mode 100644 index 00000000..d692bc97 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fecs.vim @@ -0,0 +1,17 @@ +" Author: harttle +" Description: Apply fecs format to a file. + +function! ale#fixers#fecs#Fix(buffer) abort + let l:executable = ale#handlers#fecs#GetExecutable(a:buffer) + + if !executable(l:executable) + return 0 + endif + + let l:config_options = ' format --replace=true %t' + + return { + \ 'command': ale#Escape(l:executable) . l:config_options, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim new file mode 100644 index 00000000..ebf17c5a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fish_indent.vim @@ -0,0 +1,19 @@ +" Author: Chen YuanYuan +" Description: Integration of fish_indent with ALE. + +call ale#Set('fish_fish_indent_executable', 'fish_indent') +call ale#Set('fish_fish_indent_options', '') + +function! ale#fixers#fish_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'fish_fish_indent_executable') + let l:options = ale#Var(a:buffer, 'fish_fish_indent_options') + let l:filename = ale#Escape(bufname(a:buffer)) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w ' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim new file mode 100644 index 00000000..4bad8f9b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/fixjson.vim @@ -0,0 +1,28 @@ +" Author: rhysd +" Description: Integration of fixjson with ALE. + +call ale#Set('json_fixjson_executable', 'fixjson') +call ale#Set('json_fixjson_options', '') +call ale#Set('json_fixjson_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#fixjson#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'json_fixjson', [ + \ 'node_modules/.bin/fixjson', + \]) +endfunction + +function! ale#fixers#fixjson#Fix(buffer) abort + let l:executable = ale#Escape(ale#fixers#fixjson#GetExecutable(a:buffer)) + let l:filename = ale#Escape(bufname(a:buffer)) + let l:command = l:executable . ' --stdin-filename ' . l:filename + + let l:options = ale#Var(a:buffer, 'json_fixjson_options') + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return { + \ 'command': l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/floskell.vim b/sources_non_forked/ale/autoload/ale/fixers/floskell.vim new file mode 100644 index 00000000..f0015db7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/floskell.vim @@ -0,0 +1,20 @@ +" Author: robertjlooby +" Description: Integration of floskell with ALE. + +call ale#Set('haskell_floskell_executable', 'floskell') + +function! ale#fixers#floskell#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_floskell_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'floskell') +endfunction + +function! ale#fixers#floskell#Fix(buffer) abort + let l:executable = ale#fixers#floskell#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic.vim b/sources_non_forked/ale/autoload/ale/fixers/generic.vim new file mode 100644 index 00000000..cb8865b4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/generic.vim @@ -0,0 +1,25 @@ +" Author: w0rp +" Description: Generic functions for fixing files with. + +function! ale#fixers#generic#RemoveTrailingBlankLines(buffer, lines) abort + let l:end_index = len(a:lines) - 1 + + while l:end_index > 0 && empty(a:lines[l:end_index]) + let l:end_index -= 1 + endwhile + + return a:lines[:l:end_index] +endfunction + +" Remove all whitespaces at the end of lines +function! ale#fixers#generic#TrimWhitespace(buffer, lines) abort + let l:index = 0 + let l:lines_new = range(len(a:lines)) + + for l:line in a:lines + let l:lines_new[l:index] = substitute(l:line, '\s\+$', '', 'g') + let l:index = l:index + 1 + endfor + + return l:lines_new +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim new file mode 100644 index 00000000..d55a23c3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/generic_python.vim @@ -0,0 +1,75 @@ +" Author: w0rp +" Description: Generic fixer functions for Python. + +" Add blank lines before control statements. +function! ale#fixers#generic_python#AddLinesBeforeControlStatements(buffer, lines) abort + let l:new_lines = [] + let l:last_indent_size = 0 + let l:last_line_is_blank = 0 + let l:in_docstring = 0 + + for l:line in a:lines + let l:indent_size = len(matchstr(l:line, '^ *')) + + if !l:in_docstring + " Make sure it is not just a single line docstring and then verify + " it's starting a new docstring + if match(l:line, '\v^ *("""|'''''').*("""|'''''')') == -1 + \&& match(l:line, '\v^ *("""|'''''')') >= 0 + let l:in_docstring = 1 + endif + else + if match(l:line, '\v^ *.*("""|'''''')') >= 0 + let l:in_docstring = 0 + endif + endif + + if !l:last_line_is_blank + \&& !l:in_docstring + \&& l:indent_size <= l:last_indent_size + \&& match(l:line, '\v^ *(return|if|for|while|break|continue)(\(| |$)') >= 0 + call add(l:new_lines, '') + endif + + call add(l:new_lines, l:line) + let l:last_indent_size = l:indent_size + let l:last_line_is_blank = empty(split(l:line)) + endfor + + return l:new_lines +endfunction + +" This function breaks up long lines so that autopep8 or other tools can +" fix the badly-indented code which is produced as a result. +function! ale#fixers#generic_python#BreakUpLongLines(buffer, lines) abort + " Default to a maximum line length of 79 + let l:max_line_length = 79 + let l:conf = ale#path#FindNearestFile(a:buffer, 'setup.cfg') + + " Read the maximum line length from setup.cfg + if !empty(l:conf) + for l:match in ale#util#GetMatches( + \ readfile(l:conf), + \ '\v^ *max-line-length *\= *(\d+)', + \) + let l:max_line_length = str2nr(l:match[1]) + endfor + endif + + let l:new_list = [] + + for l:line in a:lines + if len(l:line) > l:max_line_length && l:line !~# '# *noqa' + let l:line = substitute(l:line, '\v([(,])([^)])', '\1\n\2', 'g') + let l:line = substitute(l:line, '\v([^(])([)])', '\1,\n\2', 'g') + + for l:split_line in split(l:line, "\n") + call add(l:new_list, l:split_line) + endfor + else + call add(l:new_list, l:line) + endif + endfor + + return l:new_list +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gnatpp.vim b/sources_non_forked/ale/autoload/ale/fixers/gnatpp.vim new file mode 100644 index 00000000..bf3d484e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gnatpp.vim @@ -0,0 +1,17 @@ +" Author: tim +" Description: Fix files with gnatpp. + +call ale#Set('ada_gnatpp_executable', 'gnatpp') +call ale#Set('ada_gnatpp_options', '') + +function! ale#fixers#gnatpp#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ada_gnatpp_executable') + let l:options = ale#Var(a:buffer, 'ada_gnatpp_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim new file mode 100644 index 00000000..b9cfbb58 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gofmt.vim @@ -0,0 +1,16 @@ +" Author: aliou +" Description: Integration of gofmt with ALE. + +call ale#Set('go_gofmt_executable', 'gofmt') +call ale#Set('go_gofmt_options', '') + +function! ale#fixers#gofmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_gofmt_executable') + let l:options = ale#Var(a:buffer, 'go_gofmt_options') + let l:env = ale#go#EnvString(a:buffer) + + return { + \ 'command': l:env . ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim b/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim new file mode 100644 index 00000000..99753209 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gofumpt.vim @@ -0,0 +1,17 @@ +" Author: David Houston +" Description: A stricter gofmt implementation. + +call ale#Set('go_gofumpt_executable', 'gofumpt') +call ale#Set('go_gofumpt_options', '') + +function! ale#fixers#gofumpt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_gofumpt_executable') + let l:options = ale#Var(a:buffer, 'go_gofumpt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' -w -- %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/goimports.vim b/sources_non_forked/ale/autoload/ale/fixers/goimports.vim new file mode 100644 index 00000000..65f0fd98 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/goimports.vim @@ -0,0 +1,23 @@ +" Author: Jeff Willette +" Description: Integration of goimports with ALE. + +call ale#Set('go_goimports_executable', 'goimports') +call ale#Set('go_goimports_options', '') + +function! ale#fixers#goimports#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_goimports_executable') + let l:options = ale#Var(a:buffer, 'go_goimports_options') + let l:env = ale#go#EnvString(a:buffer) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': l:env . ale#Escape(l:executable) + \ . ' -l -w -srcdir %s' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/golines.vim b/sources_non_forked/ale/autoload/ale/fixers/golines.vim new file mode 100644 index 00000000..9326f482 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/golines.vim @@ -0,0 +1,21 @@ +" Author Pig Frown +" Description: Fix Go files long lines with golines" + +call ale#Set('go_golines_executable', 'golines') + +call ale#Set('go_golines_options', '') + +function! ale#fixers#golines#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_golines_executable') + let l:options = ale#Var(a:buffer, 'go_golines_options') + let l:env = ale#go#EnvString(a:buffer) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': l:env . ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/gomod.vim b/sources_non_forked/ale/autoload/ale/fixers/gomod.vim new file mode 100644 index 00000000..ee8c46c9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/gomod.vim @@ -0,0 +1,11 @@ +call ale#Set('go_go_executable', 'go') + +function! ale#fixers#gomod#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'go_go_executable') + let l:env = ale#go#EnvString(a:buffer) + + return { + \ 'command': l:env . ale#Escape(l:executable) . ' mod edit -fmt %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim b/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim new file mode 100644 index 00000000..20086c73 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/google_java_format.vim @@ -0,0 +1,23 @@ +" Author: butlerx +" Description: Integration of Google-java-format with ALE. + +call ale#Set('java_google_java_format_executable', 'google-java-format') +call ale#Set('java_google_java_format_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('java_google_java_format_options', '') + +function! ale#fixers#google_java_format#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'java_google_java_format_options') + let l:executable = ale#Var(a:buffer, 'java_google_java_format_executable') + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --replace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim new file mode 100644 index 00000000..bf2d4f71 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hackfmt.vim @@ -0,0 +1,18 @@ +" Author: Sam Howie +" Description: Integration of hackfmt with ALE. + +call ale#Set('hack_hackfmt_executable', 'hackfmt') +call ale#Set('hack_hackfmt_options', '') + +function! ale#fixers#hackfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'hack_hackfmt_executable') + let l:options = ale#Var(a:buffer, 'hack_hackfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/help.vim b/sources_non_forked/ale/autoload/ale/fixers/help.vim new file mode 100644 index 00000000..b20740fe --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/help.vim @@ -0,0 +1,24 @@ +" Author: w0rp +" Description: Generic fixer functions for Vim help documents. + +function! ale#fixers#help#AlignTags(buffer, lines) abort + let l:new_lines = [] + + for l:line in a:lines + if len(l:line) != 79 + let l:match = matchlist(l:line, '\v +(\*[^*]+\*)$') + + if !empty(l:match) + let l:start = l:line[:-len(l:match[0]) - 1] + let l:tag = l:match[1] + let l:spaces = repeat(' ', 79 - len(l:start) - len(l:tag)) + + let l:line = l:start . l:spaces . l:tag + endif + endif + + call add(l:new_lines, l:line) + endfor + + return l:new_lines +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/hfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/hfmt.vim new file mode 100644 index 00000000..0407b713 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hfmt.vim @@ -0,0 +1,16 @@ +" Author: zack +" Description: Integration of hfmt with ALE. + +call ale#Set('haskell_hfmt_executable', 'hfmt') + +function! ale#fixers#hfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hfmt_executable') + + return { + \ 'command': ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hfmt') + \ . ' -w' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/hindent.vim b/sources_non_forked/ale/autoload/ale/fixers/hindent.vim new file mode 100644 index 00000000..b6009a2c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hindent.vim @@ -0,0 +1,20 @@ +" Author: AlexeiDrake +" Description: Integration of hindent formatting with ALE. +" +call ale#Set('haskell_hindent_executable', 'hindent') + +function! ale#fixers#hindent#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hindent_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hindent') +endfunction + +function! ale#fixers#hindent#Fix(buffer) abort + let l:executable = ale#fixers#hindent#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/hlint.vim b/sources_non_forked/ale/autoload/ale/fixers/hlint.vim new file mode 100644 index 00000000..88779a55 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/hlint.vim @@ -0,0 +1,13 @@ +" Author: eborden +" Description: Integration of hlint refactor with ALE. +" + +function! ale#fixers#hlint#Fix(buffer) abort + return { + \ 'command': ale#handlers#hlint#GetExecutable(a:buffer) + \ . ' --refactor' + \ . ' --refactor-options="--inplace"' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim new file mode 100644 index 00000000..9817563e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/html_beautify.vim @@ -0,0 +1,20 @@ +" Author: WhyNotHugo +" Description: Format HTML files with html-beautify. + +call ale#Set('html_beautify_executable', 'html-beautify') +call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('html_beautify_options', '') + +function! ale#fixers#html_beautify#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'html_beautify', + \ ['html-beautify'] + \) + + let l:options = ale#Var(a:buffer, 'html_beautify_options') + + return { + \ 'command': ale#Escape(l:executable) . ' ' . l:options . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/importjs.vim b/sources_non_forked/ale/autoload/ale/fixers/importjs.vim new file mode 100644 index 00000000..b5487b2c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/importjs.vim @@ -0,0 +1,25 @@ +" Author: Jeff Willette +" Description: Integration of importjs with ALE. + +call ale#Set('javascript_importjs_executable', 'importjs') + +function! ale#fixers#importjs#ProcessOutput(buffer, output) abort + let l:result = ale#util#FuzzyJSONDecode(a:output, []) + + return split(get(l:result, 'fileContent', ''), "\n") +endfunction + +function! ale#fixers#importjs#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'javascript_importjs_executable') + + if !executable(l:executable) + return 0 + endif + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fix' + \ . ' %s', + \ 'process_with': 'ale#fixers#importjs#ProcessOutput', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/isort.vim b/sources_non_forked/ale/autoload/ale/fixers/isort.vim new file mode 100644 index 00000000..6eb6a67c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/isort.vim @@ -0,0 +1,71 @@ +" Author: w0rp +" Description: Fixing Python imports with isort. + +call ale#Set('python_isort_executable', 'isort') +call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_isort_options', '') +call ale#Set('python_isort_auto_pipenv', 0) +call ale#Set('python_isort_auto_poetry', 0) + +function! ale#fixers#isort#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_isort_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort']) +endfunction + +function! ale#fixers#isort#GetCmd(buffer) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'isort']) + endif + + return join(l:cmd, ' ') +endfunction + +function! ale#fixers#isort#FixForVersion(buffer, version) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'isort']) + endif + + if ale#semver#GTE(a:version, [5, 7, 0]) + call add(l:cmd, '--filename %s') + endif + + let l:options = ale#Var(a:buffer, 'python_isort_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + call add(l:cmd, '-') + + return { + \ 'cwd': '%s:h', + \ 'command': join(l:cmd, ' '), + \} +endfunction + +function! ale#fixers#isort#Fix(buffer) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:command = ale#fixers#isort#GetCmd(a:buffer) . ale#Pad('--version') + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#isort#FixForVersion'), + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/jq.vim b/sources_non_forked/ale/autoload/ale/fixers/jq.vim new file mode 100644 index 00000000..cd9b9138 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/jq.vim @@ -0,0 +1,22 @@ +call ale#Set('json_jq_executable', 'jq') +call ale#Set('json_jq_options', '') +call ale#Set('json_jq_filters', '.') + +function! ale#fixers#jq#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'json_jq_executable') +endfunction + +function! ale#fixers#jq#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'json_jq_options') + let l:filters = ale#Var(a:buffer, 'json_jq_filters') + + if empty(l:filters) + return 0 + endif + + return { + \ 'command': ale#Escape(ale#fixers#jq#GetExecutable(a:buffer)) + \ . ' ' . l:filters . ' ' + \ . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim new file mode 100644 index 00000000..f1e41cd5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/jsonnetfmt.vim @@ -0,0 +1,18 @@ +" Authors: Trevor Whitney and Takuya Kosugiyama +" Description: Integration of jsonnetfmt with ALE. + +call ale#Set('jsonnet_jsonnetfmt_executable', 'jsonnetfmt') +call ale#Set('jsonnet_jsonnetfmt_options', '') + +function! ale#fixers#jsonnetfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_executable') + let l:options = ale#Var(a:buffer, 'jsonnet_jsonnetfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -i' + \ . ale#Pad(l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim new file mode 100644 index 00000000..64d1340d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ktlint.vim @@ -0,0 +1,8 @@ +" Author: Michael Phillips +" Description: Fix Kotlin files with ktlint. + +function! ale#fixers#ktlint#Fix(buffer) abort + return { + \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim new file mode 100644 index 00000000..54f1231e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/latexindent.vim @@ -0,0 +1,16 @@ +" Author: riley-martine +" Description: Integration of latexindent with ALE. + +call ale#Set('tex_latexindent_executable', 'latexindent') +call ale#Set('tex_latexindent_options', '') + +function! ale#fixers#latexindent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'tex_latexindent_executable') + let l:options = ale#Var(a:buffer, 'tex_latexindent_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -l' + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim new file mode 100644 index 00000000..98b155c0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/lua_format.vim @@ -0,0 +1,16 @@ +" Author: Mathias Jean Johansen +" Description: Integration of LuaFormatter with ALE. + +call ale#Set('lua_lua_format_executable', 'lua-format') +call ale#Set('lua_lua_format_options', '') + +function! ale#fixers#lua_format#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_lua_format_executable') + let l:options = ale#Var(a:buffer, 'lua_lua_format_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad(l:options) + \ . ' -i', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim new file mode 100644 index 00000000..6cb9ef4a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/luafmt.vim @@ -0,0 +1,13 @@ +call ale#Set('lua_luafmt_executable', 'luafmt') +call ale#Set('lua_luafmt_options', '') + +function! ale#fixers#luafmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_luafmt_executable') + let l:options = ale#Var(a:buffer, 'lua_luafmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --stdin', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/mix_format.vim b/sources_non_forked/ale/autoload/ale/fixers/mix_format.vim new file mode 100644 index 00000000..7a091701 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/mix_format.vim @@ -0,0 +1,25 @@ +" Author: carakan , Fernando Mendes +" Description: Fixing files with elixir formatter 'mix format'. + +call ale#Set('elixir_mix_executable', 'mix') +call ale#Set('elixir_mix_format_options', '') + +function! ale#fixers#mix_format#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'elixir_mix_executable') +endfunction + +function! ale#fixers#mix_format#GetCommand(buffer) abort + let l:executable = ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer)) + let l:options = ale#Var(a:buffer, 'elixir_mix_format_options') + + return l:executable . ' format' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale#fixers#mix_format#Fix(buffer) abort + return { + \ 'command': ale#fixers#mix_format#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim new file mode 100644 index 00000000..fe2e7136 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nimpretty.vim @@ -0,0 +1,15 @@ +" Author: Nhan +" Description: Integration of nimpretty with ALE. + +call ale#Set('nim_nimpretty_executable', 'nimpretty') +call ale#Set('nim_nimpretty_options', '--maxLineLen:80') + +function! ale#fixers#nimpretty#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nim_nimpretty_executable') + let l:options = ale#Var(a:buffer, 'nim_nimpretty_options') + + return { + \ 'command': ale#Escape(l:executable) . ' %t' . ale#Pad(l:options), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim new file mode 100644 index 00000000..4a548b23 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixfmt.vim @@ -0,0 +1,15 @@ +scriptencoding utf-8 +" Author: houstdav000 +" Description: Fix files with nixfmt + +call ale#Set('nix_nixfmt_executable', 'nixfmt') +call ale#Set('nix_nixfmt_options', '') + +function! ale#fixers#nixfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim new file mode 100644 index 00000000..403ce798 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/nixpkgsfmt.vim @@ -0,0 +1,12 @@ +call ale#Set('nix_nixpkgsfmt_executable', 'nixpkgs-fmt') +call ale#Set('nix_nixpkgsfmt_options', '') + +function! ale#fixers#nixpkgsfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_nixpkgsfmt_executable') + let l:options = ale#Var(a:buffer, 'nix_nixpkgsfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim new file mode 100644 index 00000000..b12d2eb9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ocamlformat.vim @@ -0,0 +1,17 @@ +" Author: Stephen Lumenta <@sbl> +" Description: Integration of ocamlformat with ALE. + +call ale#Set('ocaml_ocamlformat_executable', 'ocamlformat') +call ale#Set('ocaml_ocamlformat_options', '') + +function! ale#fixers#ocamlformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ocaml_ocamlformat_executable') + let l:options = ale#Var(a:buffer, 'ocaml_ocamlformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --name=%s' + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ocp_indent.vim b/sources_non_forked/ale/autoload/ale/fixers/ocp_indent.vim new file mode 100644 index 00000000..e1b047b3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ocp_indent.vim @@ -0,0 +1,18 @@ +" Author: Kanenobu Mitsuru +" Description: Integration of ocp-indent with ALE. + +call ale#Set('ocaml_ocp_indent_executable', 'ocp-indent') +call ale#Set('ocaml_ocp_indent_options', '') +call ale#Set('ocaml_ocp_indent_config', '') + +function! ale#fixers#ocp_indent#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'ocaml_ocp_indent_executable') + let l:config = ale#Var(a:buffer, 'ocaml_ocp_indent_config') + let l:options = ale#Var(a:buffer, 'ocaml_ocp_indent_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:config) ? '' : ' --config=' . ale#Escape(l:config)) + \ . (empty(l:options) ? '': ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim new file mode 100644 index 00000000..a0999b70 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/opafmt.vim @@ -0,0 +1,15 @@ +" Description: Fixer for rego files + +call ale#Set('opa_fmt_executable', 'opa') +call ale#Set('opa_fmt_options', '') + +function! ale#fixers#opafmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'opa_fmt_executable') + let l:options = ale#Var(a:buffer, 'opa_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim new file mode 100644 index 00000000..69b55c1f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ormolu.vim @@ -0,0 +1,12 @@ +call ale#Set('haskell_ormolu_executable', 'ormolu') +call ale#Set('haskell_ormolu_options', '') + +function! ale#fixers#ormolu#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_ormolu_executable') + let l:options = ale#Var(a:buffer, 'haskell_ormolu_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/packer.vim b/sources_non_forked/ale/autoload/ale/fixers/packer.vim new file mode 100644 index 00000000..8770550d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/packer.vim @@ -0,0 +1,17 @@ +" Author: Zhuoyun Wei +" Description: Fixer for Packer HCL files + +call ale#Set('packer_fmt_executable', 'packer') +call ale#Set('packer_fmt_options', '') + +function! ale#fixers#packer#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'packer_fmt_executable') + let l:options = ale#Var(a:buffer, 'packer_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim new file mode 100644 index 00000000..d704c8a2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pandoc.vim @@ -0,0 +1,16 @@ +scriptencoding utf-8 +" Author: Jesse Hathaway +" Description: Fix markdown files with pandoc. + +call ale#Set('markdown_pandoc_executable', 'pandoc') +call ale#Set('markdown_pandoc_options', '-f gfm -t gfm -s -') + +function! ale#fixers#pandoc#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'markdown_pandoc_executable') + let l:options = ale#Var(a:buffer, 'markdown_pandoc_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim b/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim new file mode 100644 index 00000000..a55a572b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/perltidy.vim @@ -0,0 +1,18 @@ +" Author: kfly8 +" Description: Integration of perltidy with ALE. + +call ale#Set('perl_perltidy_executable', 'perltidy') +call ale#Set('perl_perltidy_options', '') + +function! ale#fixers#perltidy#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'perl_perltidy_executable') + let l:options = ale#Var(a:buffer, 'perl_perltidy_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -b' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pgformatter.vim b/sources_non_forked/ale/autoload/ale/fixers/pgformatter.vim new file mode 100644 index 00000000..9ea08ec6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pgformatter.vim @@ -0,0 +1,12 @@ +call ale#Set('sql_pgformatter_executable', 'pg_format') +call ale#Set('sql_pgformatter_options', '') + +function! ale#fixers#pgformatter#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_pgformatter_executable') + let l:options = ale#Var(a:buffer, 'sql_pgformatter_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim new file mode 100644 index 00000000..c8f9c7b0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/php_cs_fixer.vim @@ -0,0 +1,24 @@ +" Author: Julien Deniau +" Description: Fixing files with php-cs-fixer. + +call ale#Set('php_cs_fixer_executable', 'php-cs-fixer') +call ale#Set('php_cs_fixer_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_cs_fixer_options', '') + +function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_cs_fixer', [ + \ 'vendor/bin/php-cs-fixer', + \ 'php-cs-fixer' + \]) +endfunction + +function! ale#fixers#php_cs_fixer#Fix(buffer) abort + let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . ale#Var(a:buffer, 'php_cs_fixer_options') + \ . ' fix %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim new file mode 100644 index 00000000..494bf346 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/phpcbf.vim @@ -0,0 +1,26 @@ +" Author: notomo +" Description: Fixing files with phpcbf. + +call ale#Set('php_phpcbf_standard', '') +call ale#Set('php_phpcbf_options', '') +call ale#Set('php_phpcbf_executable', 'phpcbf') +call ale#Set('php_phpcbf_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#phpcbf#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_phpcbf', [ + \ 'vendor/bin/phpcbf', + \ 'phpcbf' + \]) +endfunction + +function! ale#fixers#phpcbf#Fix(buffer) abort + let l:executable = ale#fixers#phpcbf#GetExecutable(a:buffer) + let l:standard = ale#Var(a:buffer, 'php_phpcbf_standard') + let l:standard_option = !empty(l:standard) + \ ? '--standard=' . l:standard + \ : '' + + return { + \ 'command': ale#Escape(l:executable) . ' --stdin-path=%s ' . l:standard_option . ale#Pad(ale#Var(a:buffer, 'php_phpcbf_options')) . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/pint.vim b/sources_non_forked/ale/autoload/ale/fixers/pint.vim new file mode 100644 index 00000000..274ddd9e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pint.vim @@ -0,0 +1,25 @@ +" Author: Michael Dyrynda +" Description: Fixing files with Laravel Pint. + +call ale#Set('php_pint_executable', 'pint') +call ale#Set('php_pint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('php_pint_options', '') + +function! ale#fixers#pint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'php_pint', [ + \ 'vendor/bin/pint', + \ 'pint' + \]) +endfunction + +function! ale#fixers#pint#Fix(buffer) abort + let l:executable = ale#fixers#pint#GetExecutable(a:buffer) + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . ale#Var(a:buffer, 'php_pint_options') + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim new file mode 100644 index 00000000..8a67e2ff --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier.vim @@ -0,0 +1,124 @@ +" Author: tunnckoCore (Charlike Mike Reagent) , +" w0rp , morhetz (Pavel Pertsev) +" Description: Integration of Prettier with ALE. + +call ale#Set('javascript_prettier_executable', 'prettier') +call ale#Set('javascript_prettier_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_prettier_options', '') + +function! ale#fixers#prettier#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_prettier', [ + \ 'node_modules/.bin/prettier_d', + \ 'node_modules/prettier-cli/index.js', + \ 'node_modules/.bin/prettier', + \]) +endfunction + +function! ale#fixers#prettier#Fix(buffer) abort + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ ale#fixers#prettier#GetExecutable(a:buffer), + \ '%e --version', + \ function('ale#fixers#prettier#ApplyFixForVersion'), + \) +endfunction + +function! ale#fixers#prettier#ProcessPrettierDOutput(buffer, output) abort + " If the output is an error message, don't use it. + for l:line in a:output[:10] + if l:line =~# '^\w*Error:' + return [] + endif + endfor + + return a:output +endfunction + +function! ale#fixers#prettier#GetCwd(buffer) abort + let l:config = ale#path#FindNearestFile(a:buffer, '.prettierignore') + + " Fall back to the directory of the buffer + return !empty(l:config) ? fnamemodify(l:config, ':h') : '%s:h' +endfunction + +function! ale#fixers#prettier#ApplyFixForVersion(buffer, version) abort + let l:executable = ale#fixers#prettier#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'javascript_prettier_options') + let l:parser = '' + + let l:filetypes = split(getbufvar(a:buffer, '&filetype'), '\.') + + if index(l:filetypes, 'handlebars') > -1 + let l:parser = 'glimmer' + endif + + " Append the --parser flag depending on the current filetype (unless it's + " already set in g:javascript_prettier_options). + if empty(expand('#' . a:buffer . ':e')) && l:parser is# '' && match(l:options, '--parser') == -1 + " Mimic Prettier's defaults. In cases without a file extension or + " filetype (scratch buffer), Prettier needs `parser` set to know how + " to process the buffer. + if ale#semver#GTE(a:version, [1, 16, 0]) + let l:parser = 'babel' + else + let l:parser = 'babylon' + endif + + let l:prettier_parsers = { + \ 'typescript': 'typescript', + \ 'css': 'css', + \ 'less': 'less', + \ 'scss': 'scss', + \ 'json': 'json', + \ 'json5': 'json5', + \ 'graphql': 'graphql', + \ 'markdown': 'markdown', + \ 'vue': 'vue', + \ 'svelte': 'svelte', + \ 'yaml': 'yaml', + \ 'openapi': 'yaml', + \ 'html': 'html', + \ 'ruby': 'ruby', + \} + + for l:filetype in l:filetypes + if has_key(l:prettier_parsers, l:filetype) + let l:parser = l:prettier_parsers[l:filetype] + break + endif + endfor + endif + + if !empty(l:parser) + let l:options = (!empty(l:options) ? l:options . ' ' : '') . '--parser ' . l:parser + endif + + " Special error handling needed for prettier_d + if l:executable =~# 'prettier_d$' + return { + \ 'cwd': '%s:h', + \ 'command':ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filepath %s --stdin', + \ 'process_with': 'ale#fixers#prettier#ProcessPrettierDOutput', + \} + endif + + " 1.4.0 is the first version with --stdin-filepath + if ale#semver#GTE(a:version, [1, 4, 0]) + return { + \ 'cwd': ale#fixers#prettier#GetCwd(a:buffer), + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filepath %s --stdin', + \} + endif + + return { + \ 'command': ale#Escape(l:executable) + \ . ' %t' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --write', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim new file mode 100644 index 00000000..0b9c88b7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_eslint.vim @@ -0,0 +1,56 @@ +" Author: tunnckoCore (Charlike Mike Reagent) , +" w0rp , morhetz (Pavel Pertsev) +" Description: Integration between Prettier and ESLint. + +call ale#Set('javascript_prettier_eslint_executable', 'prettier-eslint') +call ale#Set('javascript_prettier_eslint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_prettier_eslint_options', '') + +function! ale#fixers#prettier_eslint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_eslint', [ + \ 'node_modules/prettier-eslint-cli/dist/index.js', + \ 'node_modules/.bin/prettier-eslint', + \]) +endfunction + +function! ale#fixers#prettier_eslint#Fix(buffer) abort + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ ale#fixers#prettier_eslint#GetExecutable(a:buffer), + \ '%e --version', + \ function('ale#fixers#prettier_eslint#ApplyFixForVersion'), + \) +endfunction + +function! ale#fixers#prettier_eslint#ApplyFixForVersion(buffer, version) abort + let l:options = ale#Var(a:buffer, 'javascript_prettier_eslint_options') + let l:executable = ale#fixers#prettier_eslint#GetExecutable(a:buffer) + + " 4.2.0 is the first version with --eslint-config-path + let l:config = ale#semver#GTE(a:version, [4, 2, 0]) + \ ? ale#handlers#eslint#FindConfig(a:buffer) + \ : '' + let l:eslint_config_option = !empty(l:config) + \ ? ' --eslint-config-path ' . ale#Escape(l:config) + \ : '' + + " 4.4.0 is the first version with --stdin-filepath + if ale#semver#GTE(a:version, [4, 4, 0]) + return { + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . l:eslint_config_option + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --stdin-filepath %s --stdin', + \} + endif + + return { + \ 'command': ale#Escape(l:executable) + \ . ' %t' + \ . l:eslint_config_option + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --write', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim new file mode 100644 index 00000000..c8c09e31 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/prettier_standard.vim @@ -0,0 +1,24 @@ +" Author: sheerun (Adam Stankiewicz) +" Description: Integration of Prettier Standard with ALE. + +call ale#Set('javascript_prettier_standard_executable', 'prettier-standard') +call ale#Set('javascript_prettier_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_prettier_standard_options', '') + +function! ale#fixers#prettier_standard#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_prettier_standard', [ + \ 'node_modules/prettier-standard/lib/index.js', + \ 'node_modules/.bin/prettier-standard', + \]) +endfunction + +function! ale#fixers#prettier_standard#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'javascript_prettier_standard_options') + + return { + \ 'command': ale#Escape(ale#fixers#prettier_standard#GetExecutable(a:buffer)) + \ . ' --stdin' + \ . ' --stdin-filepath=%s' + \ . ' ' . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/protolint.vim b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim new file mode 100644 index 00000000..9b8e72f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/protolint.vim @@ -0,0 +1,26 @@ +" Author: Yohei Yoshimuta +" Description: Integration of protolint with ALE. + +call ale#Set('proto_protolint_executable', 'protolint') +call ale#Set('proto_protolint_config', '') + +function! ale#fixers#protolint#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'proto_protolint_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#protolint#Fix(buffer) abort + let l:executable = ale#fixers#protolint#GetExecutable(a:buffer) + let l:config = ale#Var(a:buffer, 'proto_protolint_config') + + return { + \ 'command': l:executable + \ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '') + \ . ' -fix' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + + diff --git a/sources_non_forked/ale/autoload/ale/fixers/ptop.vim b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim new file mode 100644 index 00000000..98345226 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ptop.vim @@ -0,0 +1,17 @@ +" Author: BarrOff https://github.com/BarrOff +" Description: Integration of ptop with ALE. + +call ale#Set('pascal_ptop_executable', 'ptop') +call ale#Set('pascal_ptop_options', '') + +function! ale#fixers#ptop#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'pascal_ptop_executable') + let l:options = ale#Var(a:buffer, 'pascal_ptop_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %s %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/puppetlint.vim b/sources_non_forked/ale/autoload/ale/fixers/puppetlint.vim new file mode 100644 index 00000000..bf36e486 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/puppetlint.vim @@ -0,0 +1,22 @@ +" Author: Alexander Olofsson +" Description: puppet-lint fixer + +if !exists('g:ale_puppet_puppetlint_executable') + let g:ale_puppet_puppetlint_executable = 'puppet-lint' +endif + +if !exists('g:ale_puppet_puppetlint_options') + let g:ale_puppet_puppetlint_options = '' +endif + +function! ale#fixers#puppetlint#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'puppet_puppetlint_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' ' . ale#Var(a:buffer, 'puppet_puppetlint_options') + \ . ' --fix' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim b/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim new file mode 100644 index 00000000..09fa631b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/purs_tidy.vim @@ -0,0 +1,24 @@ +" Author: toastal +" Description: Integration of purs-tidy with ALE. + +call ale#Set('purescript_tidy_executable', 'purs-tidy') +call ale#Set('purescript_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('purescript_tidy_options', '') + +function! ale#fixers#purs_tidy#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'purescript_tidy', [ + \ 'node_modules/purescript-tidy/bin/index.js', + \ 'node_modules/.bin/purs-tidy', + \]) +endfunction + +function! ale#fixers#purs_tidy#Fix(buffer) abort + let l:executable = ale#fixers#purs_tidy#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'purescript_tidy_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' format' + \ . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/purty.vim b/sources_non_forked/ale/autoload/ale/fixers/purty.vim new file mode 100644 index 00000000..46d2cacd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/purty.vim @@ -0,0 +1,22 @@ +" Author: iclanzan +" Description: Integration of purty with ALE. + +call ale#Set('purescript_purty_executable', 'purty') + +function! ale#fixers#purty#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'purescript_purty_executable') + + return ale#Escape(l:executable) +endfunction + +function! ale#fixers#purty#Fix(buffer) abort + let l:executable = ale#fixers#purty#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --write' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim new file mode 100644 index 00000000..81c0f05e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/pyflyby.vim @@ -0,0 +1,41 @@ +" Author: infokiller +" Description: Tidy imports using pyflyby's tidy-import script +" https://github.com/deshaw/pyflyby + +call ale#Set('python_pyflyby_executable', 'tidy-imports') +call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('python_pyflyby_options', '') +call ale#Set('python_pyflyby_auto_pipenv', 0) +call ale#Set('python_pyflyby_auto_poetry', 0) + +function! ale#fixers#pyflyby#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflyby_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflyby_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_pyflyby', ['tidy-imports']) +endfunction + +function! ale#fixers#pyflyby#Fix(buffer) abort + " let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) + let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'tidy-imports']) + endif + + let l:options = ale#Var(a:buffer, 'python_pyflyby_options') + + if !empty(l:options) + call add(l:cmd, l:options) + endif + + return {'command': join(l:cmd, ' ')} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim new file mode 100644 index 00000000..90b25679 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/qmlfmt.vim @@ -0,0 +1,11 @@ +call ale#Set('qml_qmlfmt_executable', 'qmlfmt') + +function! ale#fixers#qmlfmt#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'qml_qmlfmt_executable') +endfunction + +function! ale#fixers#qmlfmt#Fix(buffer) abort + return { + \ 'command': ale#Escape(ale#fixers#qmlfmt#GetExecutable(a:buffer)), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim b/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim new file mode 100644 index 00000000..16cf4468 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/raco_fmt.vim @@ -0,0 +1,15 @@ +" Author: Jeremy Cantrell +" Description: Integration of raco fmt with ALE. + +call ale#Set('racket_raco_fmt_executable', 'raco') +call ale#Set('racket_raco_fmt_options', '') + +function! ale#fixers#raco_fmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'racket_raco_fmt_executable') + let l:options = ale#Var(a:buffer, 'racket_raco_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/refmt.vim b/sources_non_forked/ale/autoload/ale/fixers/refmt.vim new file mode 100644 index 00000000..514f950a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/refmt.vim @@ -0,0 +1,18 @@ +" Author: Ahmed El Gabri <@ahmedelgabri> +" Description: Integration of refmt with ALE. + +call ale#Set('reasonml_refmt_executable', 'refmt') +call ale#Set('reasonml_refmt_options', '') + +function! ale#fixers#refmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'reasonml_refmt_executable') + let l:options = ale#Var(a:buffer, 'reasonml_refmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' --in-place' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim new file mode 100644 index 00000000..85593b44 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/remark_lint.vim @@ -0,0 +1,24 @@ +" Author: blyoa +" Description: Fixing files with remark-lint. + +call ale#Set('markdown_remark_lint_executable', 'remark') +call ale#Set('markdown_remark_lint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('markdown_remark_lint_options', '') + +function! ale#fixers#remark_lint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'markdown_remark_lint', [ + \ 'node_modules/remark-cli/cli.js', + \ 'node_modules/.bin/remark', + \]) +endfunction + +function! ale#fixers#remark_lint#Fix(buffer) abort + let l:executable = ale#fixers#remark_lint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'markdown_remark_lint_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : ''), + \} +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim b/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim new file mode 100644 index 00000000..42a0a6e2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/reorder_python_imports.vim @@ -0,0 +1,25 @@ +" Author: jake +" Description: Fixing Python imports with reorder-python-imports. + +call ale#Set('python_reorder_python_imports_executable', 'reorder-python-imports') +call ale#Set('python_reorder_python_imports_options', '') +call ale#Set('python_reorder_python_imports_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#reorder_python_imports#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_reorder_python_imports', + \ ['reorder-python-imports'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:options = ale#Var(a:buffer, 'python_reorder_python_imports_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim new file mode 100644 index 00000000..5a1b7959 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/rubocop.vim @@ -0,0 +1,38 @@ +call ale#Set('ruby_rubocop_options', '') +call ale#Set('ruby_rubocop_auto_correct_all', 0) +call ale#Set('ruby_rubocop_executable', 'rubocop') + +" Rubocop fixer outputs diagnostics first and then the fixed +" output. These are delimited by a "=======" string that we +" look for to remove everything before it. +function! ale#fixers#rubocop#PostProcess(buffer, output) abort + let l:line = 0 + + for l:output in a:output + let l:line = l:line + 1 + + if l:output =~# "^=\\+$" + break + endif + endfor + + return a:output[l:line :] +endfunction + +function! ale#fixers#rubocop#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_rubocop_executable') + let l:options = ale#Var(a:buffer, 'ruby_rubocop_options') + let l:auto_correct_all = ale#Var(a:buffer, 'ruby_rubocop_auto_correct_all') + + return ale#ruby#EscapeExecutable(l:executable, 'rubocop') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . (l:auto_correct_all ? ' --auto-correct-all' : ' --auto-correct') + \ . ' --force-exclusion --stdin %s' +endfunction + +function! ale#fixers#rubocop#Fix(buffer) abort + return { + \ 'command': ale#fixers#rubocop#GetCommand(a:buffer), + \ 'process_with': 'ale#fixers#rubocop#PostProcess' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/ruff.vim b/sources_non_forked/ale/autoload/ale/fixers/ruff.vim new file mode 100644 index 00000000..92f9b75b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/ruff.vim @@ -0,0 +1,54 @@ +" Author: Yining +" Description: ruff as ALE fixer for python files + +function! ale#fixers#ruff#GetCwd(buffer) abort + if ale#Var(a:buffer, 'python_ruff_change_directory') + " Run from project root if found, else from buffer dir. + let l:project_root = ale#python#FindProjectRoot(a:buffer) + + return !empty(l:project_root) ? l:project_root : '%s:h' + endif + + return '' +endfunction + +function! ale#fixers#ruff#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_ruff_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_ruff_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff']) +endfunction + +function! ale#fixers#ruff#GetCommand(buffer, version) abort + let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer) + let l:exec_args = l:executable =~? 'pipenv\|poetry$' + \ ? ' run ruff' + \ : '' + + " NOTE: ruff version `0.0.72` implement `--fix` with stdin + return ale#Escape(l:executable) . l:exec_args + \ . ale#Pad(ale#Var(a:buffer, 'python_ruff_options')) + \ . ' --fix' + \ . (ale#semver#GTE(a:version, [0, 0, 72]) ? ' -' : ' %s') +endfunction + +function! ale#fixers#ruff#Fix(buffer) abort + let l:fix_cmd = {buffer -> ale#semver#RunWithVersionCheck( + \ buffer, + \ ale#fixers#ruff#GetExecutable(buffer), + \ '%e --version', + \ function('ale#fixers#ruff#GetCommand'), + \ )}(a:buffer) + + return { + \ 'cwd': ale#fixers#ruff#GetCwd(a:buffer), + \ 'command': l:fix_cmd, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/rufo.vim b/sources_non_forked/ale/autoload/ale/fixers/rufo.vim new file mode 100644 index 00000000..01d537a9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/rufo.vim @@ -0,0 +1,20 @@ +" Author: Fohte (Hayato Kawai) https://github.com/fohte +" Description: Integration of Rufo with ALE. + +call ale#Set('ruby_rufo_executable', 'rufo') + +function! ale#fixers#rufo#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_rufo_executable') + let l:exec_args = l:executable =~? 'bundle$' + \ ? ' exec rufo' + \ : '' + + return ale#Escape(l:executable) . l:exec_args . ' %t' +endfunction + +function! ale#fixers#rufo#Fix(buffer) abort + return { + \ 'command': ale#fixers#rufo#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/rustfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/rustfmt.vim new file mode 100644 index 00000000..38882fbf --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/rustfmt.vim @@ -0,0 +1,15 @@ +" Author: Kelly Fox +" Description: Integration of rustfmt with ALE. + +call ale#Set('rust_rustfmt_executable', 'rustfmt') +call ale#Set('rust_rustfmt_options', '') + +function! ale#fixers#rustfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'rust_rustfmt_executable') + let l:options = ale#Var(a:buffer, 'rust_rustfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim b/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim new file mode 100644 index 00000000..dd0e7745 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/scalafmt.vim @@ -0,0 +1,25 @@ +" Author: Jeffrey Lau https://github.com/zoonfafer +" Description: Integration of Scalafmt with ALE. + +call ale#Set('scala_scalafmt_executable', 'scalafmt') +call ale#Set('scala_scalafmt_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('scala_scalafmt_options', '') + +function! ale#fixers#scalafmt#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'scala_scalafmt_executable') + let l:options = ale#Var(a:buffer, 'scala_scalafmt_options') + let l:exec_args = l:executable =~? 'ng$' + \ ? ' scalafmt' + \ : '' + + return ale#Escape(l:executable) . l:exec_args + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t' +endfunction + +function! ale#fixers#scalafmt#Fix(buffer) abort + return { + \ 'command': ale#fixers#scalafmt#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim new file mode 100644 index 00000000..0eefc985 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/shfmt.vim @@ -0,0 +1,17 @@ +scriptencoding utf-8 +" Author: Simon Bugert +" Description: Fix sh files with shfmt. + +call ale#Set('sh_shfmt_executable', 'shfmt') +call ale#Set('sh_shfmt_options', '') + +function! ale#fixers#shfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sh_shfmt_executable') + let l:options = ale#Var(a:buffer, 'sh_shfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -filename=%s' + \ . (empty(l:options) ? '' : ' ' . l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim new file mode 100644 index 00000000..7c12fa1e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sorbet.vim @@ -0,0 +1,19 @@ +call ale#Set('ruby_sorbet_executable', 'srb') +call ale#Set('ruby_sorbet_options', '') + +function! ale#fixers#sorbet#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable') + let l:options = ale#Var(a:buffer, 'ruby_sorbet_options') + + return ale#ruby#EscapeExecutable(l:executable, 'srb') + \ . ' tc' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --autocorrect --file %t' +endfunction + +function! ale#fixers#sorbet#Fix(buffer) abort + return { + \ 'command': ale#fixers#sorbet#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/sqlfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/sqlfmt.vim new file mode 100644 index 00000000..c88a8ec2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sqlfmt.vim @@ -0,0 +1,13 @@ +call ale#Set('sql_sqlfmt_executable', 'sqlfmt') +call ale#Set('sql_sqlfmt_options', '') + +function! ale#fixers#sqlfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_sqlfmt_executable') + let l:options = ale#Var(a:buffer, 'sql_sqlfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w' + \ . (empty(l:options) ? '' : ' ' . l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim new file mode 100644 index 00000000..6319c1ac --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/sqlformat.vim @@ -0,0 +1,16 @@ +" Author: Cluas +" Description: Fixing files with sqlformat. + +call ale#Set('sql_sqlformat_executable', 'sqlformat') +call ale#Set('sql_sqlformat_options', '') + +function! ale#fixers#sqlformat#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'sql_sqlformat_executable') + let l:options = ale#Var(a:buffer, 'sql_sqlformat_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standard.vim b/sources_non_forked/ale/autoload/ale/fixers/standard.vim new file mode 100644 index 00000000..b9d60ebb --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/standard.vim @@ -0,0 +1,33 @@ +" Author: Sumner Evans +" Description: Fixing files with Standard. + +call ale#Set('javascript_standard_executable', 'standard') +call ale#Set('javascript_standard_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_standard_options', '') + +function! ale#fixers#standard#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_standard', [ + \ 'node_modules/standardx/bin/cmd.js', + \ 'node_modules/standard/bin/cmd.js', + \ 'node_modules/.bin/standard', + \]) +endfunction + +function! ale#fixers#standard#Fix(buffer) abort + let l:executable = ale#fixers#standard#GetExecutable(a:buffer) + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:options_type = 'javascript_standard_options' + + if l:filetype =~# 'typescript' + let l:options_type = 'typescript_standard_options' + endif + + let l:options = ale#Var(a:buffer, l:options_type) + + return { + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --fix --stdin < %s > %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim new file mode 100644 index 00000000..acb310c6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/standardrb.vim @@ -0,0 +1,23 @@ +" Author: Justin Searls - https://github.com/searls +" Description: Fix Ruby files with StandardRB. + +call ale#Set('ruby_standardrb_options', '') +call ale#Set('ruby_standardrb_executable', 'standardrb') + +function! ale#fixers#standardrb#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_standardrb_executable') + let l:config = ale#path#FindNearestFile(a:buffer, '.standard.yml') + let l:options = ale#Var(a:buffer, 'ruby_standardrb_options') + + return ale#ruby#EscapeExecutable(l:executable, 'standardrb') + \ . (!empty(l:config) ? ' --config ' . ale#Escape(l:config) : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --fix --force-exclusion --stdin %s' +endfunction + +function! ale#fixers#standardrb#Fix(buffer) abort + return { + \ 'command': ale#fixers#standardrb#GetCommand(a:buffer), + \ 'process_with': 'ale#fixers#rubocop#PostProcess' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/statix.vim b/sources_non_forked/ale/autoload/ale/fixers/statix.vim new file mode 100644 index 00000000..5991c925 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/statix.vim @@ -0,0 +1,17 @@ +" Author: David Houston +" Description: Provide statix fix as a fixer for simple Nix antipatterns. + +call ale#Set('nix_statix_fix_executable', 'statix') +call ale#Set('nix_statix_fix_options', '') + +function! ale#fixers#statix#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'nix_statix_fix_executable') + let l:options = ale#Var(a:buffer, 'nix_statix_fix_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ale#Pad('fix') + \ . ale#Pad('--stdin') + \ . ale#Pad(l:options), + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim new file mode 100644 index 00000000..650b9c4a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylelint.vim @@ -0,0 +1,26 @@ +" Author: Mahmoud Mostafa +" Description: Fixing files with stylelint. + +call ale#Set('stylelint_executable', 'stylelint') +call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('stylelint_options', '') + +function! ale#fixers#stylelint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'stylelint', [ + \ 'node_modules/stylelint/bin/stylelint.js', + \ 'node_modules/.bin/stylelint', + \]) +endfunction + +function! ale#fixers#stylelint#Fix(buffer) abort + let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'stylelint_options') + + return { + \ 'cwd': '%s:h', + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . ale#Pad(l:options) + \ . ' --fix --stdin --stdin-filename %s', + \ 'read_temporary_file': 0, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/styler.vim b/sources_non_forked/ale/autoload/ale/fixers/styler.vim new file mode 100644 index 00000000..1c7607bd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/styler.vim @@ -0,0 +1,16 @@ +" Author: tvatter +" Description: Fixing R files with styler. + +call ale#Set('r_styler_executable', 'Rscript') +call ale#Set('r_styler_options', 'tidyverse_style()') + +function! ale#fixers#styler#Fix(buffer) abort + return { + \ 'command': 'Rscript --vanilla -e ' + \ . '"suppressPackageStartupMessages(library(styler));' + \ . 'style_file(commandArgs(TRUE), transformers = ' + \ . ale#Var(a:buffer, 'r_styler_options') . ')"' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim b/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim new file mode 100644 index 00000000..ce71c1ce --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylish_haskell.vim @@ -0,0 +1,21 @@ +" Author: eborden +" Description: Integration of stylish-haskell formatting with ALE. +" +call ale#Set('haskell_stylish_haskell_executable', 'stylish-haskell') + +function! ale#fixers#stylish_haskell#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_stylish_haskell_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'stylish-haskell') +endfunction + +function! ale#fixers#stylish_haskell#Fix(buffer) abort + let l:executable = ale#fixers#stylish_haskell#GetExecutable(a:buffer) + + return { + \ 'command': l:executable + \ . ' --inplace' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/stylua.vim b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim new file mode 100644 index 00000000..3521c935 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/stylua.vim @@ -0,0 +1,14 @@ +" Author: Robert Liebowitz +" Description: https://github.com/johnnymorganz/stylua + +call ale#Set('lua_stylua_executable', 'stylua') +call ale#Set('lua_stylua_options', '') + +function! ale#fixers#stylua#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'lua_stylua_executable') + let l:options = ale#Var(a:buffer, 'lua_stylua_options') + + return { + \ 'command': ale#Escape(l:executable) . ale#Pad(l:options) . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim new file mode 100644 index 00000000..cc553b7d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/swiftformat.vim @@ -0,0 +1,25 @@ +" Author: gfontenot (Gordon Fontenot) +" Description: Integration of SwiftFormat with ALE. + +call ale#Set('swift_swiftformat_executable', 'swiftformat') +call ale#Set('swift_swiftformat_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('swift_swiftformat_options', '') + +function! ale#fixers#swiftformat#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'swift_swiftformat', [ + \ 'Pods/SwiftFormat/CommandLineTool/swiftformat', + \ 'ios/Pods/SwiftFormat/CommandLineTool/swiftformat', + \ 'swiftformat', + \]) +endfunction + +function! ale#fixers#swiftformat#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'swift_swiftformat_options') + + return { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape(ale#fixers#swiftformat#GetExecutable(a:buffer)) + \ . ' %t' + \ . ' ' . l:options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim new file mode 100644 index 00000000..7ae03373 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/syntax_tree.vim @@ -0,0 +1,19 @@ +call ale#Set('ruby_syntax_tree_options', '') +call ale#Set('ruby_syntax_tree_executable', 'stree') + +function! ale#fixers#syntax_tree#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'ruby_syntax_tree_executable') + let l:options = ale#Var(a:buffer, 'ruby_syntax_tree_options') + + return ale#ruby#EscapeExecutable(l:executable, 'stree') + \ . ' write' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale#fixers#syntax_tree#Fix(buffer) abort + return { + \ 'command': ale#fixers#syntax_tree#GetCommand(a:buffer), + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/terraform.vim b/sources_non_forked/ale/autoload/ale/fixers/terraform.vim new file mode 100644 index 00000000..bc05380a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/terraform.vim @@ -0,0 +1,17 @@ +" Author: dsifford +" Description: Fixer for terraform and .hcl files + +call ale#Set('terraform_fmt_executable', 'terraform') +call ale#Set('terraform_fmt_options', '') + +function! ale#fixers#terraform#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'terraform_fmt_executable') + let l:options = ale#Var(a:buffer, 'terraform_fmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' fmt' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' -' + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/textlint.vim b/sources_non_forked/ale/autoload/ale/fixers/textlint.vim new file mode 100644 index 00000000..38ab2bfd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/textlint.vim @@ -0,0 +1,15 @@ +" Author: TANIGUCHI Masaya +" Description: Integration of textlint with ALE. + +function! ale#fixers#textlint#Fix(buffer) abort + let l:executable = ale#handlers#textlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'textlint_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' --fix' + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/tidy.vim b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim new file mode 100644 index 00000000..2c79e73a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/tidy.vim @@ -0,0 +1,26 @@ +" Author: meain +" Description: Fixing HTML files with tidy. + +call ale#Set('html_tidy_executable', 'tidy') +call ale#Set('html_tidy_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#tidy#Fix(buffer) abort + let l:executable = ale#path#FindExecutable( + \ a:buffer, + \ 'html_tidy', + \ ['tidy'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:config = ale#path#FindNearestFile(a:buffer, '.tidyrc') + let l:config_options = !empty(l:config) + \ ? ' -q --tidy-mark no --show-errors 0 --show-warnings 0 -config ' . ale#Escape(l:config) + \ : ' -q --tidy-mark no --show-errors 0 --show-warnings 0' + + return { + \ 'command': ale#Escape(l:executable) . l:config_options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/tslint.vim b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim new file mode 100644 index 00000000..15768fd5 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/tslint.vim @@ -0,0 +1,22 @@ +" Author: carakan +" Description: Fixing files with tslint. + +function! ale#fixers#tslint#Fix(buffer) abort + let l:executable = ale#handlers#tslint#GetExecutable(a:buffer) + + let l:tslint_config_path = ale#path#ResolveLocalPath( + \ a:buffer, + \ 'tslint.json', + \ ale#Var(a:buffer, 'typescript_tslint_config_path') + \) + let l:tslint_config_option = !empty(l:tslint_config_path) + \ ? ' -c ' . ale#Escape(l:tslint_config_path) + \ : '' + + return { + \ 'command': ale#node#Executable(a:buffer, l:executable) + \ . l:tslint_config_option + \ . ' --outputAbsolutePaths --fix %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim b/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim new file mode 100644 index 00000000..0e8271ec --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/uncrustify.vim @@ -0,0 +1,33 @@ +" Author: Derek P Sifford +" Description: Fixer for C, C++, C#, ObjectiveC, D, Java, Pawn, and VALA. + +call ale#Set('c_uncrustify_executable', 'uncrustify') +call ale#Set('c_uncrustify_options', '') + +let s:languages = { +\ 'c': 'C', +\ 'cpp': 'CPP', +\ 'cs': 'CS', +\ 'objc': 'OC', +\ 'objcpp': 'OC+', +\ 'd': 'D', +\ 'java': 'JAVA', +\ 'vala': 'VALA', +\ 'p': 'PAWN', +\} + +function! ale#fixers#uncrustify#Language(buffer) abort + return get(s:languages, &filetype, 'C') +endfunction + +function! ale#fixers#uncrustify#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'c_uncrustify_executable') + let l:options = ale#Var(a:buffer, 'c_uncrustify_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' --no-backup ' + \ . '-l' . ale#Pad(ale#fixers#uncrustify#Language(a:buffer)) + \ . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim new file mode 100644 index 00000000..2e780318 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/vfmt.vim @@ -0,0 +1,13 @@ +" Author: fiatjaf +" Description: Integration of `v fmt` with ALE. + +call ale#Set('v_vfmt_options', '') + +function! ale#fixers#vfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'v_v_executable') + let l:options = ale#Var(a:buffer, 'v_vfmt_options') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt' . ale#Pad(l:options) + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim b/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim new file mode 100644 index 00000000..b14ffd36 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/xmllint.vim @@ -0,0 +1,29 @@ +" Author: Cyril Roelandt +" Description: Integration of xmllint with ALE. + +call ale#Set('xml_xmllint_executable', 'xmllint') +call ale#Set('xml_xmllint_options', '') +call ale#Set('xml_xmllint_indentsize', 2) + +function! ale#fixers#xmllint#Fix(buffer) abort + let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable')) + let l:filename = ale#Escape(bufname(a:buffer)) + let l:command = l:executable . ' --format ' . l:filename + + let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize') + + if l:indent isnot# '' + let l:env = ale#Env('XMLLINT_INDENT', repeat(' ', l:indent)) + let l:command = l:env . l:command + endif + + let l:options = ale#Var(a:buffer, 'xml_xmllint_options') + + if l:options isnot# '' + let l:command .= ' ' . l:options + endif + + return { + \ 'command': l:command + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/xo.vim b/sources_non_forked/ale/autoload/ale/fixers/xo.vim new file mode 100644 index 00000000..dcf4c737 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/xo.vim @@ -0,0 +1,36 @@ +" Author: Albert Marquez - https://github.com/a-marquez +" Description: Fixing files with XO. + +function! ale#fixers#xo#Fix(buffer) abort + let l:executable = ale#handlers#xo#GetExecutable(a:buffer) + let l:options = ale#handlers#xo#GetOptions(a:buffer) + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ '%e --version', + \ {b, v -> ale#fixers#xo#ApplyFixForVersion(b, v, l:executable, l:options)} + \) +endfunction + +function! ale#fixers#xo#ApplyFixForVersion(buffer, version, executable, options) abort + let l:executable = ale#node#Executable(a:buffer, a:executable) + let l:options = ale#Pad(a:options) + + " 0.30.0 is the first version with a working --stdin --fix + if ale#semver#GTE(a:version, [0, 30, 0]) + return { + \ 'command': l:executable + \ . ' --stdin --stdin-filename %s' + \ . ' --fix' + \ . l:options, + \} + endif + + return { + \ 'command': l:executable + \ . ' --fix %t' + \ . l:options, + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim new file mode 100644 index 00000000..6654a25c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yamlfix.vim @@ -0,0 +1,25 @@ +" Author: lyz-code +" Description: Fixing yaml files with yamlfix. + +call ale#Set('yaml_yamlfix_executable', 'yamlfix') +call ale#Set('yaml_yamlfix_options', '') +call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#yamlfix#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options') + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'yaml_yamlfix', + \ ['yamlfix'], + \) + + if !executable(l:executable) + return 0 + endif + + return { + \ 'cwd': '%s:h', + \ 'command': ale#Escape(l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') . ' -', + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/yapf.vim b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim new file mode 100644 index 00000000..f04bb1f9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/yapf.vim @@ -0,0 +1,26 @@ +" Author: w0rp +" Description: Fixing Python files with yapf. + +call ale#Set('python_yapf_executable', 'yapf') +call ale#Set('python_yapf_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#fixers#yapf#Fix(buffer) abort + let l:executable = ale#python#FindExecutable( + \ a:buffer, + \ 'python_yapf', + \ ['yapf'], + \) + + if !executable(l:executable) + return 0 + endif + + let l:config = ale#path#FindNearestFile(a:buffer, '.style.yapf') + let l:config_options = !empty(l:config) + \ ? ' --no-local-style --style ' . ale#Escape(l:config) + \ : '' + + return { + \ 'command': ale#Escape(l:executable) . l:config_options, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim b/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim new file mode 100644 index 00000000..b22e5b83 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/fixers/zigfmt.vim @@ -0,0 +1,14 @@ +scriptencoding utf-8 +" Author: Arash Mousavi +" Description: Official formatter for Zig. + +call ale#Set('zig_zigfmt_executable', 'zig') + +function! ale#fixers#zigfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'zig_zigfmt_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' fmt %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/floating_preview.vim b/sources_non_forked/ale/autoload/ale/floating_preview.vim new file mode 100644 index 00000000..b6deec4c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/floating_preview.vim @@ -0,0 +1,231 @@ +" Author: Jan-Grimo Sobez +" Author: Kevin Clark +" Author: D. Ben Knoble +" Author: Shaun Duncan +" Description: Floating preview window for showing whatever information in. + +" Precondition: exists('*nvim_open_win') || has('popupwin') + +function! ale#floating_preview#Show(lines, ...) abort + if !exists('*nvim_open_win') && !has('popupwin') + " no-custom-checks + echom 'Floating windows not supported in this vim instance.' + + return + endif + + let l:options = get(a:000, 0, {}) + + if has('nvim') + call s:NvimShow(a:lines, l:options) + else + call s:VimShow(a:lines, l:options) + endif +endfunction + +function! s:NvimShow(lines, options) abort + " Remove the close autocmd so it doesn't happen mid update + augroup ale_floating_preview_window + autocmd! + augroup END + + " Only create a new window if we need it + if !exists('w:preview') || index(nvim_list_wins(), w:preview['id']) is# -1 + call s:NvimCreate(a:options) + else + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:true) + endif + + " Execute commands in window context + let l:parent_window = nvim_get_current_win() + + call nvim_set_current_win(w:preview['id']) + + for l:command in get(a:options, 'commands', []) + call execute(l:command) + endfor + + call nvim_set_current_win(l:parent_window) + + " Return to parent context on move + augroup ale_floating_preview_window + autocmd! + + if g:ale_close_preview_on_insert + autocmd CursorMoved,TabLeave,WinLeave,InsertEnter ++once call s:NvimClose() + else + autocmd CursorMoved,TabLeave,WinLeave ++once call s:NvimClose() + endif + augroup END + + let [l:lines, l:width, l:height] = s:NvimPrepareWindowContent(a:lines) + + call nvim_win_set_width(w:preview['id'], l:width) + call nvim_win_set_height(w:preview['id'], l:height) + call nvim_buf_set_lines(w:preview['buffer'], 0, -1, v:false, l:lines) + call nvim_buf_set_option(w:preview['buffer'], 'modified', v:false) + call nvim_buf_set_option(w:preview['buffer'], 'modifiable', v:false) +endfunction + +function! s:VimShow(lines, options) abort + if g:ale_close_preview_on_insert + " Remove the close autocmd so it doesn't happen mid update + silent! autocmd! ale_floating_preview_window + endif + + " Only create a new window if we need it + if !exists('w:preview') || index(popup_list(), w:preview['id']) is# -1 + call s:VimCreate(a:options) + endif + + " Execute commands in window context + for l:command in get(a:options, 'commands', []) + call win_execute(w:preview['id'], l:command) + endfor + + call popup_settext(w:preview['id'], a:lines) + + if g:ale_close_preview_on_insert + augroup ale_floating_preview_window + autocmd! + autocmd InsertEnter * ++once call s:VimClose() + augroup END + endif +endfunction + +function! s:NvimPrepareWindowContent(lines) abort + let l:max_height = 10 + + let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)')) + let l:height = min([len(a:lines), l:max_height]) + + if empty(g:ale_floating_window_border) + return [a:lines, l:width, l:height] + endif + + " Add the size of borders + let l:width += 2 + let l:height += 2 + + let l:left = get(g:ale_floating_window_border, 0, '|') + let l:top = get(g:ale_floating_window_border, 1, '-') + let l:top_left = get(g:ale_floating_window_border, 2, '+') + let l:top_right = get(g:ale_floating_window_border, 3, '+') + let l:bottom_right = get(g:ale_floating_window_border, 4, '+') + let l:bottom_left = get(g:ale_floating_window_border, 5, '+') + let l:right = get(g:ale_floating_window_border, 6, l:left) + let l:bottom = get(g:ale_floating_window_border, 7, l:top) + + let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right] + + for l:line in a:lines + let l:line_width = strchars(l:line) + let l:lines = add(l:lines, l:left . l:line . repeat(' ', l:width - l:line_width - 2). l:right) + endfor + + " Truncate the lines + if len(l:lines) > l:max_height + 1 + let l:lines = l:lines[0:l:max_height] + endif + + let l:lines = add(l:lines, l:bottom_left . repeat(l:bottom, l:width - 2) . l:bottom_right) + + return [l:lines, l:width, l:height] +endfunction + +function! s:NvimCreate(options) abort + let l:popup_opts = extend({ + \ 'relative': 'cursor', + \ 'row': 1, + \ 'col': 0, + \ 'width': 42, + \ 'height': 4, + \ 'style': 'minimal' + \ }, s:GetPopupOpts()) + + let l:buffer = nvim_create_buf(v:false, v:false) + let l:winid = nvim_open_win(l:buffer, v:false, l:popup_opts) + + call nvim_buf_set_option(l:buffer, 'buftype', 'acwrite') + call nvim_buf_set_option(l:buffer, 'bufhidden', 'delete') + call nvim_buf_set_option(l:buffer, 'swapfile', v:false) + call nvim_buf_set_option(l:buffer, 'filetype', get(a:options, 'filetype', 'ale-preview')) + + let w:preview = {'id': l:winid, 'buffer': l:buffer} +endfunction + +function! s:VimCreate(options) abort + " default options + let l:popup_opts = extend({ + \ 'line': 'cursor+1', + \ 'col': 'cursor', + \ 'drag': v:true, + \ 'resize': v:true, + \ 'close': 'button', + \ 'padding': [0, 1, 0, 1], + \ 'border': [], + \ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [ + \ get(g:ale_floating_window_border, 1, '-'), + \ get(g:ale_floating_window_border, 6, '|'), + \ get(g:ale_floating_window_border, 7, '-'), + \ get(g:ale_floating_window_border, 0, '|'), + \ get(g:ale_floating_window_border, 2, '+'), + \ get(g:ale_floating_window_border, 3, '+'), + \ get(g:ale_floating_window_border, 4, '+'), + \ get(g:ale_floating_window_border, 5, '+'), + \ ], + \ 'moved': 'any', + \ }, s:GetPopupOpts()) + + let l:popup_id = popup_create([], l:popup_opts) + call setbufvar(winbufnr(l:popup_id), '&filetype', get(a:options, 'filetype', 'ale-preview')) + let w:preview = {'id': l:popup_id} +endfunction + +function! s:NvimClose() abort + let l:mode = mode() + let l:restore_visual = l:mode is# 'v' || l:mode is# 'V' || l:mode is# "\" + + if !exists('w:preview') + return + endif + + call setbufvar(w:preview['buffer'], '&modified', 0) + + if win_id2win(w:preview['id']) > 0 + execute win_id2win(w:preview['id']).'wincmd c' + endif + + unlet w:preview + + if l:restore_visual + normal! gv + endif +endfunction + +function! s:VimClose() abort + if !exists('w:preview') + return + endif + + call popup_close(w:preview['id']) + unlet w:preview +endfunction + +" get either the results of a function callback or dictionary for popup overrides +function! s:GetPopupOpts() abort + if exists('g:ale_floating_preview_popup_opts') + let l:ref = g:ale_floating_preview_popup_opts + + if type(l:ref) is# v:t_dict + return l:ref + elseif type(l:ref) is# v:t_string + try + return function(l:ref)() + catch /E700/ + endtry + endif + endif + + return {} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/go.vim b/sources_non_forked/ale/autoload/ale/go.vim new file mode 100644 index 00000000..bce85a87 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/go.vim @@ -0,0 +1,58 @@ +" Author: Horacio Sanson https://github.com/hsanson +" Description: Functions for integrating with Go tools + +" Find the nearest dir listed in GOPATH and assume it the root of the go +" project. +function! ale#go#FindProjectRoot(buffer) abort + let l:sep = has('win32') ? ';' : ':' + + let l:filename = ale#path#Simplify(expand('#' . a:buffer . ':p')) + + for l:name in split($GOPATH, l:sep) + let l:path_dir = ale#path#Simplify(l:name) + + " Use the directory from GOPATH if the current filename starts with it. + if l:filename[: len(l:path_dir) - 1] is? l:path_dir + return l:path_dir + endif + endfor + + let l:default_go_path = ale#path#Simplify(expand('~/go')) + + if isdirectory(l:default_go_path) + return l:default_go_path + endif + + return '' +endfunction + + +call ale#Set('go_go111module', '') + +" Return a string setting Go-specific environment variables +function! ale#go#EnvString(buffer) abort + let l:env = '' + + " GO111MODULE - turn go modules behavior on/off + let l:go111module = ale#Var(a:buffer, 'go_go111module') + + if !empty(l:go111module) + let l:env = ale#Env('GO111MODULE', l:go111module) . l:env + endif + + return l:env +endfunction + +function! ale#go#GetGoPathExecutable(suffix) abort + let l:prefix = $GOPATH + + if !empty($GOPATH) + let l:prefix = $GOPATH + elseif has('win32') + let l:prefix = $USERPROFILE . '/go' + else + let l:prefix = $HOME . '/go' + endif + + return ale#path#Simplify(l:prefix . '/' . a:suffix) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/gradle.vim b/sources_non_forked/ale/autoload/ale/gradle.vim new file mode 100644 index 00000000..ba1add4d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/gradle.vim @@ -0,0 +1,74 @@ +" Author: Michael Pardo +" Description: Functions for working with Gradle projects. + +let s:script_path = fnamemodify(resolve(expand(':p')), ':h') +let s:init_path = has('win32') +\ ? s:script_path . '\gradle\init.gradle' +\ : s:script_path . '/gradle/init.gradle' + +function! ale#gradle#GetInitPath() abort + return s:init_path +endfunction + +" Given a buffer number, find a Gradle project root. +function! ale#gradle#FindProjectRoot(buffer) abort + let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew') + + if !empty(l:gradlew_path) + return fnamemodify(l:gradlew_path, ':h') + endif + + let l:settings_path = ale#path#FindNearestFile(a:buffer, 'settings.gradle') + + if !empty(l:settings_path) + return fnamemodify(l:settings_path, ':h') + endif + + let l:build_path = ale#path#FindNearestFile(a:buffer, 'build.gradle') + + if !empty(l:build_path) + return fnamemodify(l:build_path, ':h') + endif + + return '' +endfunction + +" Given a buffer number, find the path to the executable. +" First search on the path for 'gradlew', if nothing is found, try the global +" command. Returns an empty string if cannot find the executable. +function! ale#gradle#FindExecutable(buffer) abort + let l:gradlew_path = ale#path#FindNearestFile(a:buffer, 'gradlew') + + if !empty(l:gradlew_path) + return l:gradlew_path + endif + + if executable('gradle') + return 'gradle' + endif + + return '' +endfunction + +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Gradle is not detected. +function! ale#gradle#BuildClasspathCommand(buffer) abort + let l:executable = ale#gradle#FindExecutable(a:buffer) + + if !empty(l:executable) + let l:project_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) + \ . ' -I ' . ale#Escape(s:init_path) + \ . ' -q printClasspath' + \] + endif + endif + + return ['', ''] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/gradle/init.gradle b/sources_non_forked/ale/autoload/ale/gradle/init.gradle new file mode 100644 index 00000000..fb1db9ee --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/gradle/init.gradle @@ -0,0 +1,23 @@ +class ClasspathPlugin implements Plugin { + void apply(Project project) { + project.task('printClasspath') { + doLast { + project + .rootProject + .allprojects + .configurations + .flatten() + .findAll { it.name.endsWith('Classpath') } + .collect { it.resolve() } + .flatten() + .unique() + .findAll { it.exists() } + .each { println it } + } + } + } +} + +rootProject { + apply plugin: ClasspathPlugin +} diff --git a/sources_non_forked/ale/autoload/ale/handlers/actionlint.vim b/sources_non_forked/ale/autoload/ale/handlers/actionlint.vim new file mode 100644 index 00000000..73843c08 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/actionlint.vim @@ -0,0 +1,36 @@ +function! ale#handlers#actionlint#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_actionlint_options') + + " automatically add --no-color option if not defined + if l:options !~# '--no-color' + let l:options .= ' --no-color' + endif + + " automatically add --oneline option if not defined + if l:options !~# '--oneline' + let l:options .= ' --oneline' + endif + + return '%e ' . l:options . ' %t' +endfunction + +function! ale#handlers#actionlint#Handle(buffer, lines) abort + " Matches patterns line the following: + ".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax] + let l:pattern = '\v^.*:(\d+):(\d+): (.+) \[(.+)\]$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'code': l:match[4], + \ 'type': 'E', + \} + + call add(l:output, l:item) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/alex.vim b/sources_non_forked/ale/autoload/ale/handlers/alex.vim new file mode 100644 index 00000000..1a92bd14 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/alex.vim @@ -0,0 +1,55 @@ +scriptencoding utf-8 +" Author: Johannes Wienke +" Description: Error handling for errors in alex output format + +function! ale#handlers#alex#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'alex', [ + \ 'node_modules/.bin/alex', + \ 'node_modules/alex/cli.js', + \]) +endfunction + +function! ale#handlers#alex#CreateCommandCallback(flags) abort + return {b -> ale#node#Executable(b, ale#handlers#alex#GetExecutable(b)) + \ . ' --stdin ' + \ . a:flags + \} +endfunction + +function! ale#handlers#alex#Handle(buffer, lines) abort + " Example output: + " 6:256-6:262 warning Be careful with “killed”, it’s profane in some cases killed retext-profanities + let l:pattern = '\v^ *(\d+):(\d+)-(\d+):(\d+) +warning +(.{-}) +(.{-}) +(.{-})$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'end_lnum': l:match[3] + 0, + \ 'end_col': l:match[4] - 1, + \ 'text': l:match[5] . ' (' . (l:match[7]) . ')', + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +" Define a linter for a specific filetype. Accept flags to adapt to the filetype. +" no flags treat input as markdown +" --html treat input as HTML +" --mdx treat input as MDX +" --text treat input as plaintext +function! ale#handlers#alex#DefineLinter(filetype, flags) abort + call ale#Set('alex_executable', 'alex') + call ale#Set('alex_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'alex', + \ 'executable': function('ale#handlers#alex#GetExecutable'), + \ 'command': ale#handlers#alex#CreateCommandCallback(a:flags), + \ 'output_stream': 'stderr', + \ 'callback': 'ale#handlers#alex#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/atools.vim b/sources_non_forked/ale/autoload/ale/handlers/atools.vim new file mode 100644 index 00000000..c273fc40 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/atools.vim @@ -0,0 +1,41 @@ +" Author: Leo +" Description: Handlers for output expected from atools + +function! ale#handlers#atools#Handle(buffer, lines) abort + " Format: SEVERITY:[TAG]:PATH:LINENUM:MSG + " Example: MC:[AL5]:./APKBUILD:12:variable set to empty string: install= + let l:pattern = '\([^:]\+\):\([^:]\+\):\([^:]\+\):\(\d\+\):\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " We are expected to receive 2 characters, the first character + " can be 'S', 'I', 'M' 'T', which are respectively: + " Serious (Error) + " Important (Error) + " Minor (Warning) + " Style (Warning) + " + " The second character can be either 'C' or 'P', which are respectively: + " Certain (Error) + " Possible (Warning) + let l:severity = matchstr(l:match[1], '^.') + let l:certainty = matchstr(l:match[1], '.$') + + let l:type = 'E' + " If the tag returns 'Minor' or 'Style' or is 'Possible' + " then return a warning + + if l:severity is# 'M' || l:severity is# 'T' || l:certainty is# 'P' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[4] + 0, + \ 'text': l:match[5], + \ 'type': l:type, + \ 'code': matchstr(l:match[2], 'AL[0-9]*'), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ccls.vim b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim new file mode 100644 index 00000000..290f5852 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ccls.vim @@ -0,0 +1,26 @@ +scriptencoding utf-8 +" Author: Ye Jingchen +" Description: Utilities for ccls + +function! ale#handlers#ccls#GetProjectRoot(buffer) abort + " Try to find ccls configuration files first. + let l:config = ale#path#FindNearestFile(a:buffer, '.ccls-root') + + if empty(l:config) + let l:config = ale#path#FindNearestFile(a:buffer, '.ccls') + endif + + if !empty(l:config) + return fnamemodify(l:config, ':h') + endif + + " Fall back on default project root detection. + return ale#c#FindProjectRoot(a:buffer) +endfunction + +function! ale#handlers#ccls#GetInitOpts(buffer, init_options_var) abort + let l:build_dir = ale#c#GetBuildDirectory(a:buffer) + let l:init_options = empty(l:build_dir) ? {} : {'compilationDatabaseDirectory': l:build_dir} + + return extend(l:init_options, ale#Var(a:buffer, a:init_options_var)) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim new file mode 100644 index 00000000..150bb007 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/cppcheck.vim @@ -0,0 +1,89 @@ +" Description: Handle errors for cppcheck. + +function! ale#handlers#cppcheck#GetCwd(buffer) abort + let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) + + return !empty(l:dir) ? l:dir : '' +endfunction + +function! ale#handlers#cppcheck#GetBufferPathIncludeOptions(buffer) abort + let l:buffer_path_include = '' + + " Get path to this buffer so we can include it into cppcheck with -I + " This could be expanded to get more -I directives from the compile + " command in compile_commands.json, if it's found. + let l:buffer_path = fnamemodify(bufname(a:buffer), ':p:h') + let l:buffer_path_include = ' -I' . ale#Escape(l:buffer_path) + + return l:buffer_path_include +endfunction + +function! ale#handlers#cppcheck#GetCompileCommandsOptions(buffer) abort + " The compile_commands.json doesn't apply to headers and cppheck will + " bail out if it cannot find a file matching the filter, below. Skip out + " now, for headers. Also, suppress FPs; cppcheck is not meant to + " process lone header files. + let b:buffer_name = bufname(a:buffer) + let b:file_extension = fnamemodify(b:buffer_name, ':e') + + if b:file_extension is# 'h' || b:file_extension is# 'hpp' + return ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer) + \ . ' --suppress=unusedStructMember' + endif + + " If the current buffer is modified, using compile_commands.json does no + " good, so include the file's directory instead. It's not quite as good as + " using --project, but is at least equivalent to running cppcheck on this + " file manually from the file's directory. + let l:modified = getbufvar(a:buffer, '&modified') + + if l:modified + return '' + endif + + " Search upwards from the file for compile_commands.json. + " + " If we find it, we'll `cd` to where the compile_commands.json file is, + " then use the file to set up import paths, etc. + let [l:dir, l:json_path] = ale#c#FindCompileCommands(a:buffer) + + " By default, cppcheck processes every config in compile_commands.json. + " Use --file-filter to limit to just the buffer file. + return !empty(l:json_path) + \ ? '--project=' . ale#Escape(l:json_path[len(l:dir) + 1: ]) . ' --file-filter=' . ale#Escape(bufname(a:buffer)) + \ : '' +endfunction + +function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort + " Look for lines like the following. + " + "test.cpp:974:6: error:inconclusive Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ + " n[3]=3; + " ^ + "" OR if cppcheck doesn't support {column} or {inconclusive:text}: + "test.cpp:974:{column}: error:{inconclusive:inconclusive} Array 'n[3]' accessed at index 3, which is out of bounds. [arrayIndexOutOfBounds]\ + " n[3]=3; + " ^ + " + "" OR if using the misra addon: + "test.c:1:16: style: misra violation (use --rule-texts= to get proper output) [misra-c2012-2.7]\' + "void test( int parm ) {} + " ^ + let l:pattern = '\v(\f+):(\d+):(\d+|\{column\}): (\w+):(\{inconclusive:inconclusive\})? ?(.*) \[(%(\w[-.]?)+)\]\' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if ale#path#IsBufferPath(a:buffer, l:match[1]) + call add(l:output, { + \ 'lnum': str2nr(l:match[2]), + \ 'col': match(l:match[3],'{column}') >= 0 ? 1 : str2nr(l:match[3]), + \ 'type': l:match[4] is# 'error' ? 'E' : 'W', + \ 'sub_type': l:match[4] is# 'style' ? 'style' : '', + \ 'text': l:match[6], + \ 'code': l:match[7] + \}) + endif + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cpplint.vim b/sources_non_forked/ale/autoload/ale/handlers/cpplint.vim new file mode 100644 index 00000000..5c475a5c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/cpplint.vim @@ -0,0 +1,21 @@ +" Author: Dawid Kurek https://github.com/dawikur +" Description: Handle errors for cpplint. + +function! ale#handlers#cpplint#HandleCppLintFormat(buffer, lines) abort + " Look for lines like the following. + " test.cpp:5: Estra space after ( in function call [whitespace/parents] [4] + let l:pattern = '^.\{-}:\(\d\+\): *\(.\+\) *\[\(.*/.*\)\] ' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': join(split(l:match[2])), + \ 'code': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/cspell.vim b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim new file mode 100644 index 00000000..2cd02d5c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/cspell.vim @@ -0,0 +1,54 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: Define a handler function for cspell's output + +function! ale#handlers#cspell#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, + \ 'cspell', [ + \ 'node_modules/.bin/cspell', + \ 'node_modules/cspell/bin.js', + \ ] + \) +endfunction + +function! ale#handlers#cspell#GetCommand(buffer) abort + let l:executable = ale#handlers#cspell#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'cspell_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . ' lint --no-color --no-progress --no-summary' + \ . ale#Pad(l:options) + \ . ' -- stdin' +endfunction + +function! ale#handlers#cspell#Handle(buffer, lines) abort + " Look for lines like the following: + " + " /home/user/repos/ale/README.md:723:48 - Unknown word (stylelint) + let l:pattern = '\v^.*:(\d+):(\d+) - (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#cspell#DefineLinter(filetype) abort + call ale#Set('cspell_executable', 'cspell') + call ale#Set('cspell_options', '') + call ale#Set('cspell_use_global', get(g:, 'ale_use_global_executables', 0)) + + call ale#linter#Define(a:filetype, { + \ 'name': 'cspell', + \ 'executable': function('ale#handlers#cspell#GetExecutable'), + \ 'command': function('ale#handlers#cspell#GetCommand'), + \ 'callback': 'ale#handlers#cspell#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/css.vim b/sources_non_forked/ale/autoload/ale/handlers/css.vim new file mode 100644 index 00000000..de9eadcc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/css.vim @@ -0,0 +1,70 @@ +scriptencoding utf-8 +" Author: w0rp +" Description: Error handling for CSS linters. + +function! ale#handlers#css#HandleCSSLintFormat(buffer, lines) abort + " Matches patterns line the following: + " + " something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors) + " something.css: line 2, col 5, Warning - Expected (inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex) but found 'wat'. (known-properties) + " + " These errors can be very massive, so the type will be moved to the front + " so you can actually read the error type. + let l:pattern = '\v^.*: line (\d+), col (\d+), (Error|Warning) - (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'Warning' ? 'W' : 'E', + \ 'text': l:match[4], + \} + + let l:code_match = matchlist(l:match[4], '\v(.+) \(([^(]+)\)$') + + " Split up the error code and the text if we find one. + if !empty(l:code_match) + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +function! ale#handlers#css#HandleStyleLintFormat(buffer, lines) abort + let l:exception_pattern = '\v^Error:' + + for l:line in a:lines[:10] + if len(matchlist(l:line, l:exception_pattern)) > 0 + return [{ + \ 'lnum': 1, + \ 'text': 'stylelint exception thrown (type :ALEDetail for more information)', + \ 'detail': join(a:lines, "\n"), + \}] + endif + endfor + + " Matches patterns line the following: + " + " src/main.css + " 108:10 ✖ Unexpected leading zero number-leading-zero + " 116:20 ✖ Expected a trailing semicolon declaration-block-trailing-semicolon + let l:pattern = '\v^.* (\d+):(\d+) \s+(\S+)\s+ (.*[^ ])\s+([^ ]+)\s*$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# '✖' ? 'E' : 'W', + \ 'text': l:match[4], + \ 'code': l:match[5], + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/deno.vim b/sources_non_forked/ale/autoload/ale/handlers/deno.vim new file mode 100644 index 00000000..b762f983 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/deno.vim @@ -0,0 +1,76 @@ +" Author: Mohammed Chelouti - https://github.com/motato1 +" Arnold Chand +" Description: Handler functions for Deno. + +call ale#Set('deno_executable', 'deno') +call ale#Set('deno_unstable', 0) +call ale#Set('deno_importMap', 'import_map.json') +call ale#Set('deno_lsp_project_root', '') + +function! ale#handlers#deno#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'deno_executable') +endfunction + +" Find project root for Deno's language server. +" +" Deno projects do not require a project or configuration file at the project root. +" This means the root directory has to be guessed, +" unless it is explicitly specified by the user. +" +" The project root is determined by ... +" 1. using a user-specified value from deno_lsp_project_root +" 2. looking for common top-level files/dirs +" 3. using the buffer's directory +function! ale#handlers#deno#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'deno_lsp_project_root') + + if !empty(l:project_root) + return l:project_root + endif + + let l:possible_project_roots = [ + \ 'deno.json', + \ 'deno.jsonc', + \ 'tsconfig.json', + \ '.git', + \ bufname(a:buffer), + \] + + for l:possible_root in l:possible_project_roots + let l:project_root = ale#path#FindNearestFile(a:buffer, l:possible_root) + + if empty(l:project_root) + let l:project_root = ale#path#FindNearestDirectory(a:buffer, l:possible_root) + endif + + if !empty(l:project_root) + " dir:p expands to /full/path/to/dir/ whereas + " file:p expands to /full/path/to/file (no trailing slash) + " Appending '/' ensures that :h:h removes the path's last segment + " regardless of whether it is a directory or not. + return fnamemodify(l:project_root . '/', ':p:h:h') + endif + endfor + + return '' +endfunction + +" Initialization Options for deno, for javascript and typescript +function! ale#handlers#deno#GetInitializationOptions(buffer) abort + let l:options = { + \ 'enable': v:true, + \ 'lint': v:true, + \ 'unstable': v:false, + \ 'importMap': ale#path#FindNearestFile(a:buffer, 'import_map.json'), + \ } + + if ale#Var(a:buffer, 'deno_unstable') + let l:options.unstable = v:true + endif + + if ale#Var(a:buffer, 'deno_importMap') isnot# '' + let l:options.importMap = ale#path#FindNearestFile(a:buffer, ale#Var(a:buffer, 'deno_importMap')) + endif + + return l:options +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/elixir.vim b/sources_non_forked/ale/autoload/ale/handlers/elixir.vim new file mode 100644 index 00000000..2fddf8e7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/elixir.vim @@ -0,0 +1,28 @@ +" Author: Matteo Centenaro (bugant) - https://github.com/bugant +" Author: Jon Parise +" Description: Functions for working with Elixir projects + +" Find the root directory for an elixir project that uses mix. +function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort + let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs') + + if !empty(l:mix_file) + return fnamemodify(l:mix_file, ':p:h') + endif + + return '.' +endfunction + +" Similar to ale#handlers#elixir#FindMixProjectRoot but also continue the +" search upward for a potential umbrella project root. If an umbrella root +" does not exist, the initial project root will be returned. +function! ale#handlers#elixir#FindMixUmbrellaRoot(buffer) abort + let l:app_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer) + let l:umbrella_root = fnamemodify(l:app_root, ':h:h') + + if filereadable(l:umbrella_root . '/mix.exs') + return l:umbrella_root + endif + + return l:app_root +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/eslint.vim b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim new file mode 100644 index 00000000..374460bc --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/eslint.vim @@ -0,0 +1,280 @@ +" Author: w0rp +" Description: Functions for working with eslint, for checking or fixing files. + +let s:executables = [ +\ '.yarn/sdks/eslint/bin/eslint.js', +\ 'node_modules/.bin/eslint_d', +\ 'node_modules/eslint/bin/eslint.js', +\ 'node_modules/.bin/eslint', +\] +let s:sep = has('win32') ? '\' : '/' + +call ale#Set('javascript_eslint_options', '') +call ale#Set('javascript_eslint_executable', 'eslint') +call ale#Set('javascript_eslint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_eslint_suppress_eslintignore', 0) +call ale#Set('javascript_eslint_suppress_missing_config', 0) + +function! ale#handlers#eslint#FindConfig(buffer) abort + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:basename in [ + \ '.eslintrc.js', + \ '.eslintrc.yaml', + \ '.eslintrc.yml', + \ '.eslintrc.json', + \ '.eslintrc', + \] + let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep)) + + if filereadable(l:config) + return l:config + endif + endfor + endfor + + return ale#path#FindNearestFile(a:buffer, 'package.json') +endfunction + +function! ale#handlers#eslint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_eslint', s:executables) +endfunction + +" Given a buffer, return an appropriate working directory for ESLint. +function! ale#handlers#eslint#GetCwd(buffer) abort + " ESLint 6 loads plugins/configs/parsers from the project root + " By default, the project root is simply the CWD of the running process. + " https://github.com/eslint/rfcs/blob/master/designs/2018-simplified-package-loading/README.md + " https://github.com/dense-analysis/ale/issues/2787 + " + " If eslint is installed in a directory which contains the buffer, assume + " it is the ESLint project root. Otherwise, use nearest node_modules. + " Note: If node_modules not present yet, can't load local deps anyway. + let l:executable = ale#path#FindNearestExecutable(a:buffer, s:executables) + + if !empty(l:executable) + let l:modules_index = strridx(l:executable, 'node_modules') + let l:modules_root = l:modules_index > -1 ? l:executable[0:l:modules_index - 2] : '' + + let l:sdks_index = strridx(l:executable, ale#path#Simplify('.yarn/sdks')) + let l:sdks_root = l:sdks_index > -1 ? l:executable[0:l:sdks_index - 2] : '' + else + let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') + let l:modules_root = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' + + let l:sdks_dir = ale#path#FindNearestDirectory(a:buffer, ale#path#Simplify('.yarn/sdks')) + let l:sdks_root = !empty(l:sdks_dir) ? fnamemodify(l:sdks_dir, ':h:h:h') : '' + endif + + return strlen(l:modules_root) > strlen(l:sdks_root) ? l:modules_root : l:sdks_root +endfunction + +function! ale#handlers#eslint#GetCommand(buffer) abort + let l:executable = ale#handlers#eslint#GetExecutable(a:buffer) + + let l:options = ale#Var(a:buffer, 'javascript_eslint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -f json --stdin --stdin-filename %s' +endfunction + +function! s:AddHintsForTypeScriptParsingErrors(output) abort + for l:item in a:output + let l:item.text = substitute( + \ l:item.text, + \ '^\(Parsing error\)', + \ '\1 (You may need configure typescript-eslint-parser)', + \ '', + \) + endfor +endfunction + +function! s:CheckForBadConfig(buffer, lines) abort + let l:config_error_pattern = '\v^ESLint couldn''t find a configuration file' + \ . '|^Cannot read config file' + \ . '|^.*Configuration for rule .* is invalid' + \ . '|^ImportDeclaration should appear' + + " Look for a message in the first few lines which indicates that + " a configuration file couldn't be found. + for l:line in a:lines[:10] + let l:match = matchlist(l:line, l:config_error_pattern) + + if len(l:match) > 0 + " Don't show the missing config error if we've disabled it. + if ale#Var(a:buffer, 'javascript_eslint_suppress_missing_config') + \&& l:match[0] is# 'ESLint couldn''t find a configuration file' + return 0 + endif + + return 1 + endif + endfor + + return 0 +endfunction + +function! s:parseJSON(buffer, lines) abort + let l:parsed = [] + + for l:line in a:lines + try + let l:parsed = extend(l:parsed, json_decode(l:line)) + catch + endtry + endfor + + if type(l:parsed) != v:t_list || empty(l:parsed) + return [] + endif + + let l:errors = l:parsed[0]['messages'] + + if empty(l:errors) + return [] + endif + + let l:output = [] + + for l:error in l:errors + let l:obj = ({ + \ 'lnum': get(l:error, 'line', 0), + \ 'text': get(l:error, 'message', ''), + \ 'type': 'E', + \}) + + if get(l:error, 'severity', 0) is# 1 + let l:obj.type = 'W' + endif + + if has_key(l:error, 'ruleId') + let l:code = l:error['ruleId'] + + " Sometimes ESLint returns null here + if !empty(l:code) + let l:obj.code = l:code + endif + endif + + if has_key(l:error, 'column') + let l:obj.col = l:error['column'] + endif + + if has_key(l:error, 'endColumn') + let l:obj.end_col = l:error['endColumn'] - 1 + endif + + if has_key(l:error, 'endLine') + let l:obj.end_lnum = l:error['endLine'] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + +let s:col_end_patterns = [ +\ '\vParsing error: Unexpected token (.+) ?', +\ '\v''(.+)'' is not defined.', +\ '\v%(Unexpected|Redundant use of) [''`](.+)[''`]', +\ '\vUnexpected (console) statement', +\] + +function! s:parseLines(buffer, lines) abort + " Matches patterns line the following: + " + " /path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle] + " /path/to/some-filename.js:56:41: Missing semicolon. [Error/semi] + let l:pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$' + " This second pattern matches lines like the following: + " + " /path/to/some-filename.js:13:3: Parsing error: Unexpected token + let l:parsing_pattern = '^.*:\(\d\+\):\(\d\+\): \(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:parsing_pattern]) + let l:text = l:match[3] + + let l:obj = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:text, + \ 'type': 'E', + \} + + " Take the error type from the output if available. + let l:split_code = split(l:match[4], '/') + + if get(l:split_code, 0, '') is# 'Warning' + let l:obj.type = 'W' + endif + + " The code can be something like 'Error/foo/bar', or just 'Error' + if !empty(get(l:split_code, 1)) + let l:obj.code = join(l:split_code[1:], '/') + endif + + for l:col_match in ale#util#GetMatches(l:text, s:col_end_patterns) + let l:obj.end_col = l:obj.col + len(l:col_match[1]) - 1 + endfor + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + +function! s:FilterResult(buffer, obj) abort + if ale#Var(a:buffer, 'javascript_eslint_suppress_eslintignore') + if a:obj.text =~# '^File ignored' + return 0 + endif + endif + + if has_key(a:obj, 'code') && a:obj.code is# 'no-trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + return 0 + endif + + return 1 +endfunction + +function! s:HandleESLintOutput(buffer, lines, type) abort + if s:CheckForBadConfig(a:buffer, a:lines) + return [{ + \ 'lnum': 1, + \ 'text': 'eslint configuration error (type :ALEDetail for more information)', + \ 'detail': join(a:lines, "\n"), + \}] + endif + + if a:lines == ['Could not connect'] + return [{ + \ 'lnum': 1, + \ 'text': 'Could not connect to eslint_d. Try updating eslint_d or killing it.', + \}] + endif + + if a:type is# 'json' + let l:output = s:parseJSON(a:buffer, a:lines) + else + let l:output = s:parseLines(a:buffer, a:lines) + endif + + call filter(l:output, {idx, obj -> s:FilterResult(a:buffer, obj)}) + + if expand('#' . a:buffer . ':t') =~? '\.tsx\?$' + call s:AddHintsForTypeScriptParsingErrors(l:output) + endif + + return l:output +endfunction + +function! ale#handlers#eslint#HandleJSON(buffer, lines) abort + return s:HandleESLintOutput(a:buffer, a:lines, 'json') +endfunction + +function! ale#handlers#eslint#Handle(buffer, lines) abort + return s:HandleESLintOutput(a:buffer, a:lines, 'lines') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/fecs.vim b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim new file mode 100644 index 00000000..064b927e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/fecs.vim @@ -0,0 +1,52 @@ +" Author: harttle +" Description: fecs http://fecs.baidu.com/ + +call ale#Set('javascript_fecs_executable', 'fecs') +call ale#Set('javascript_fecs_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#handlers#fecs#GetCommand(buffer) abort + return '%e check --colors=false --rule=true %t' +endfunction + +function! ale#handlers#fecs#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'javascript_fecs', [ + \ 'node_modules/.bin/fecs', + \ 'node_modules/fecs/bin/fecs', + \]) +endfunction + +function! ale#handlers#fecs#Handle(buffer, lines) abort + " Matches patterns looking like the following + " + " fecs WARN → line 20, col 25: Unexpected console statement. (no-console) + " fecs ERROR → line 24, col 36: Missing radix parameter. (radix) + " + let l:pattern = '\v^.*(WARN|ERROR)\s+→\s+line (\d+),\s+col\s+(\d+):\s+(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4] + \} + + let l:code_match = matchlist(l:match[4], '\v^(.{-})\s*\((.+)\)$') + + if !empty(l:code_match) + let l:obj.code = l:code_match[2] + let l:obj.text = l:code_match[1] + endif + + if l:match[1] is# 'WARN' + let l:obj.type = 'W' + elseif l:match[1] is# 'ERROR' + let l:obj.type = 'E' + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim b/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim new file mode 100644 index 00000000..b7d2bec3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/flawfinder.vim @@ -0,0 +1,48 @@ +scriptencoding utf-8 +" Author: Christian Gibbons +" Description: This file defines a handler function that should work for the +" flawfinder format with the -CDQS flags. + +" Swiped this function from the GCC handler. Not sure if needed, but doesn't +" hurt to have it. +function! s:RemoveUnicodeQuotes(text) abort + let l:text = a:text + let l:text = substitute(l:text, '[`´‘’]', '''', 'g') + let l:text = substitute(l:text, '\v\\u2018([^\\]+)\\u2019', '''\1''', 'g') + let l:text = substitute(l:text, '[“”]', '"', 'g') + + return l:text +endfunction + +function! ale#handlers#flawfinder#HandleFlawfinderFormat(buffer, lines) abort + " Look for lines like the following. + " + " :12:4: [2] (buffer) char:Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. + " :31:4: [1] (buffer) strncpy:Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ( \[[0-5]\] [^:]+):(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + " Use severity level to determine if it should be considered a warning + " or error. + let l:severity = str2nr(matchstr(split(l:match[4])[0], '[0-5]')) + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'type': (l:severity < ale#Var(a:buffer, 'c_flawfinder_error_severity')) + \ ? 'W' : 'E', + \ 'text': s:RemoveUnicodeQuotes(join(split(l:match[4])[1:]) . ': ' . l:match[5]), + \} + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/gawk.vim b/sources_non_forked/ale/autoload/ale/handlers/gawk.vim new file mode 100644 index 00000000..50bc4c45 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/gawk.vim @@ -0,0 +1,27 @@ +" Author: Anthony DeDominic +" Description: Handle output from gawk's --lint option + +function! ale#handlers#gawk#HandleGawkFormat(buffer, lines) abort + " Look for lines like the following: + " gawk: /tmp/v0fddXz/1/something.awk:1: ^ invalid char ''' in expression + let l:pattern = '^.\{-}:\(\d\+\):\s\+\(warning:\|\^\)\s*\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:ecode = 'E' + + if l:match[2] is? 'warning:' + let l:ecode = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': l:match[3], + \ 'code': 0, + \ 'type': l:ecode, + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/gcc.vim b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim new file mode 100644 index 00000000..0b37c98a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/gcc.vim @@ -0,0 +1,176 @@ +scriptencoding utf-8 +" Author: w0rp +" Description: This file defines a handler function which ought to work for +" any program which outputs errors in the format that GCC uses. + +let s:pragma_error = '#pragma once in main file' + +" Look for lines like the following. +" +" :8:5: warning: conversion lacks type at end of format [-Wformat=] +" :10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’) +" -:189:7: note: $/${} is unnecessary on arithmetic variables. [SC2004] +let s:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+)?:?(\d+)?:? ([^:]+): (.+)$' +let s:inline_pattern = '\v inlined from .* at \:(\d+):(\d+):$' + +function! s:IsHeaderFile(filename) abort + return a:filename =~? '\v\.(h|hpp)$' +endfunction + +function! s:RemoveUnicodeQuotes(text) abort + let l:text = a:text + let l:text = substitute(l:text, '[`´‘’]', '''', 'g') + let l:text = substitute(l:text, '\v\\u2018([^\\]+)\\u2019', '''\1''', 'g') + let l:text = substitute(l:text, '[“”]', '"', 'g') + + return l:text +endfunction + +function! s:ParseInlinedFunctionProblems(buffer, lines) abort + let l:output = [] + let l:pos_match = [] + + for l:line in a:lines + let l:match = matchlist(l:line, s:pattern) + + if !empty(l:match) && !empty(l:pos_match) + call add(l:output, { + \ 'lnum': str2nr(l:pos_match[1]), + \ 'col': str2nr(l:pos_match[2]), + \ 'type': (l:match[4] is# 'error' || l:match[4] is# 'fatal error') ? 'E' : 'W', + \ 'text': s:RemoveUnicodeQuotes(l:match[5]), + \}) + endif + + let l:pos_match = matchlist(l:line, s:inline_pattern) + endfor + + return l:output +endfunction + +" Report problems inside of header files just for gcc and clang +function! s:ParseProblemsInHeaders(buffer, lines) abort + let l:output = [] + let l:include_item = {} + + for l:line in a:lines[: -2] + let l:include_match = matchlist(l:line, '\v^In file included from') + + if !empty(l:include_item) + let l:pattern_match = matchlist(l:line, s:pattern) + + if !empty(l:pattern_match) && l:pattern_match[1] is# '' + if has_key(l:include_item, 'lnum') + call add(l:output, l:include_item) + endif + + let l:include_item = {} + + continue + endif + + let l:include_item.detail .= "\n" . l:line + endif + + if !empty(l:include_match) + if empty(l:include_item) + let l:include_item = { + \ 'text': 'Error found in header. See :ALEDetail', + \ 'detail': l:line, + \} + endif + endif + + if !empty(l:include_item) + let l:stdin_match = matchlist(l:line, '\vfrom \:(\d+):(\d*):?$') + + if !empty(l:stdin_match) + let l:include_item.lnum = str2nr(l:stdin_match[1]) + + if str2nr(l:stdin_match[2]) + let l:include_item.col = str2nr(l:stdin_match[2]) + endif + endif + endif + endfor + + if !empty(l:include_item) && has_key(l:include_item, 'lnum') + call add(l:output, l:include_item) + endif + + return l:output +endfunction + +function! ale#handlers#gcc#HandleGCCFormat(buffer, lines) abort + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, s:pattern) + " Filter out the pragma errors + if s:IsHeaderFile(bufname(bufnr(''))) + \&& l:match[5][:len(s:pragma_error) - 1] is# s:pragma_error + continue + endif + + " If the 'error type' is a note, make it detail related to + " the previous error parsed in output + if l:match[4] is# 'note' + if !empty(l:output) + if !has_key(l:output[-1], 'detail') + let l:output[-1].detail = l:output[-1].text + + " handle macro expansion errors/notes + if l:match[5] =~? '^in expansion of macro ‘\w*\w’$' + " if the macro expansion is in the file we're in, add + " the lnum and col keys to the previous error + if l:match[1] is# '' + \ && !has_key(l:output[-1], 'col') + let l:output[-1].lnum = str2nr(l:match[2]) + let l:output[-1].col = str2nr(l:match[3]) + else + " the error is not in the current file, and since + " macro expansion errors don't show the full path to + " the error from the current file, we have to just + " give out a generic error message + let l:output[-1].text = 'Error found in macro expansion. See :ALEDetail' + endif + endif + endif + + let l:output[-1].detail = l:output[-1].detail . "\n" + \ . s:RemoveUnicodeQuotes(l:match[0]) + endif + + continue + endif + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': (l:match[4] is# 'error' || l:match[4] is# 'fatal error') ? 'E' : 'W', + \ 'text': s:RemoveUnicodeQuotes(l:match[5]), + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +" Handle problems with the GCC format, but report problems inside of headers. +function! ale#handlers#gcc#HandleGCCFormatWithIncludes(buffer, lines) abort + let l:output = ale#handlers#gcc#HandleGCCFormat(a:buffer, a:lines) + + call extend(l:output, s:ParseInlinedFunctionProblems(a:buffer, a:lines)) + call extend(l:output, s:ParseProblemsInHeaders(a:buffer, a:lines)) + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/go.vim b/sources_non_forked/ale/autoload/ale/handlers/go.vim new file mode 100644 index 00000000..c969669d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/go.vim @@ -0,0 +1,29 @@ +" Author: neersighted +" Description: go vet for Go files +" +" Author: John Eikenberry +" Description: updated to work with go1.10 +" +" Author: Ben Paxton +" Description: moved to generic Golang file from govet +" +" Author: mostfunkyduck +" Description: updated to work with go 1.14 + +function! ale#handlers#go#Handler(buffer, lines) abort + let l:pattern = '\v^%(vet: )?([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? ?(.+)$' + let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:match[4], + \ 'type': 'E', + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/haskell.vim b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim new file mode 100644 index 00000000..70a3a7ea --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/haskell.vim @@ -0,0 +1,119 @@ +" Author: w0rp +" Description: Error handling for the format GHC outputs. +" +function! ale#handlers#haskell#GetStackExecutable(bufnr) abort + if ale#path#FindNearestFile(a:bufnr, 'stack.yaml') isnot# '' + return 'stack' + endif + + " if there is no stack.yaml file, we don't use stack even if it exists, + " so we return '', because executable('') apparently always fails + return '' +endfunction + +" Remember the directory used for temporary files for Vim. +let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h') +" Build part of a regular expression for matching ALE temporary filenames. +let s:temp_regex_prefix = +\ '\M' +\ . substitute(s:temp_dir, '\\', '\\\\', 'g') +\ . '\.\{-}' + +function! s:PanicOutput(lines) abort + return [{ + \ 'lnum': 1, + \ 'col': 1, + \ 'text': 'ghc panic!', + \ 'type': 'E', + \ 'detail' : join(a:lines, "\n"), + \}] +endfunction + +function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort + " Look for lines like the following. + " + "Appoint/Lib.hs:8:1: warning: + "Appoint/Lib.hs:8:1: + let l:basename = expand('#' . a:buffer . ':t') + " Build a complete regular expression for replacing temporary filenames + " in Haskell error messages with the basename for this file. + let l:temp_filename_regex = s:temp_regex_prefix . l:basename + + let l:pattern = '\v^\s*([a-zA-Z]?:?[^:]+):(\d+):(\d+):(.*)?$' + let l:output = [] + + let l:corrected_lines = [] + + " If ghc panic error, put the whole message in details and exit. + let l:panic_position = match(a:lines,'ghc: panic!') + let l:panic_end = match(a:lines,'Please report this as a GHC bug:') + + if l:panic_position >= 0 + return s:PanicOutput(a:lines[l:panic_position : l:panic_end]) + endif + + " Group the lines into smaller lists. + for l:line in a:lines + if len(matchlist(l:line, l:pattern)) > 0 + call add(l:corrected_lines, [l:line]) + elseif l:line is# '' + call add(l:corrected_lines, [l:line]) + elseif len(l:corrected_lines) > 0 + call add(l:corrected_lines[-1], l:line) + endif + endfor + + for l:line_list in l:corrected_lines + " Join the smaller lists into one large line to parse. + let l:line = l:line_list[0] + + for l:extra_line in l:line_list[1:] + let l:line .= substitute(l:extra_line, '\v^\s+', ' ', '') + endfor + + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + if !ale#path#IsBufferPath(a:buffer, l:match[1]) + continue + endif + + let l:errors = matchlist(l:match[4], '\v([wW]arning|[eE]rror): ?(.*)') + + if len(l:errors) > 0 + let l:ghc_type = l:errors[1] + let l:text = l:errors[2] + else + let l:ghc_type = '' + let l:text = l:match[4][:0] is# ' ' ? l:match[4][1:] : l:match[4] + endif + + if l:ghc_type is? 'Warning' + let l:type = 'W' + else + let l:type = 'E' + endif + + " Replace temporary filenames in problem messages with the basename + let l:text = substitute(l:text, l:temp_filename_regex, l:basename, 'g') + + let l:item = { + \ 'lnum': l:match[2] + 0, + \ 'col': l:match[3] + 0, + \ 'text': l:text, + \ 'type': l:type, + \} + + " Include extra lines as details if they are there. + if len(l:line_list) > 1 + let l:item.detail = join(l:line_list[1:], "\n") + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/haskell_stack.vim b/sources_non_forked/ale/autoload/ale/handlers/haskell_stack.vim new file mode 100644 index 00000000..108301a9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/haskell_stack.vim @@ -0,0 +1,7 @@ +function! ale#handlers#haskell_stack#EscapeExecutable(executable, stack_exec) abort + let l:exec_args = a:executable =~? 'stack$' + \ ? ' exec ' . ale#Escape(a:stack_exec) . ' --' + \ : '' + + return ale#Escape(a:executable) . l:exec_args +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim new file mode 100644 index 00000000..e871b083 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/hdl_checker.vim @@ -0,0 +1,73 @@ +" Author: suoto +" Description: Adds support for HDL Code Checker, which wraps vcom/vlog, ghdl +" or xvhdl. More info on https://github.com/suoto/hdl_checker + +call ale#Set('hdl_checker_executable', 'hdl_checker') +call ale#Set('hdl_checker_config_file', has('unix') ? '.hdl_checker.config' : '_hdl_checker.config') +call ale#Set('hdl_checker_options', '') + +" Use this as a function so we can mock it on testing. Need to do this because +" test files are inside /testplugin (which refers to the ale repo), which will +" always have a .git folder +function! ale#handlers#hdl_checker#IsDotGit(path) abort + return ! empty(a:path) && isdirectory(a:path) +endfunction + +" Should return (in order of preference) +" 1. Nearest config file +" 2. Nearest .git directory +" 3. The current path +function! ale#handlers#hdl_checker#GetProjectRoot(buffer) abort + let l:project_root = ale#path#FindNearestFile( + \ a:buffer, + \ ale#Var(a:buffer, 'hdl_checker_config_file')) + + if !empty(l:project_root) + return fnamemodify(l:project_root, ':h') + endif + + " Search for .git to use as root + let l:project_root = ale#path#FindNearestDirectory(a:buffer, '.git') + + if ale#handlers#hdl_checker#IsDotGit(l:project_root) + return fnamemodify(l:project_root, ':h:h') + endif + + return '' +endfunction + +function! ale#handlers#hdl_checker#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'hdl_checker_executable') +endfunction + +function! ale#handlers#hdl_checker#GetCommand(buffer) abort + let l:command = ale#Escape(ale#handlers#hdl_checker#GetExecutable(a:buffer)) . ' --lsp' + + " Add extra parameters only if config has been set + let l:options = ale#Var(a:buffer, 'hdl_checker_options') + + if ! empty(l:options) + let l:command = l:command . ' ' . l:options + endif + + return l:command +endfunction + +" To allow testing +function! ale#handlers#hdl_checker#GetInitOptions(buffer) abort + return {'project_file': ale#Var(a:buffer, 'hdl_checker_config_file')} +endfunction + +" Define the hdl_checker linter for a given filetype. +function! ale#handlers#hdl_checker#DefineLinter(filetype) abort + call ale#linter#Define(a:filetype, { + \ 'name': 'hdl-checker', + \ 'lsp': 'stdio', + \ 'language': a:filetype, + \ 'executable': function('ale#handlers#hdl_checker#GetExecutable'), + \ 'command': function('ale#handlers#hdl_checker#GetCommand'), + \ 'project_root': function('ale#handlers#hdl_checker#GetProjectRoot'), + \ 'initialization_options': function('ale#handlers#hdl_checker#GetInitOptions'), + \ }) +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/hlint.vim b/sources_non_forked/ale/autoload/ale/handlers/hlint.vim new file mode 100644 index 00000000..b9a8c322 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/hlint.vim @@ -0,0 +1,8 @@ +call ale#Set('haskell_hlint_executable', 'hlint') +call ale#Set('haskell_hlint_options', get(g:, 'hlint_options', '')) + +function! ale#handlers#hlint#GetExecutable(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hlint_executable') + + return ale#handlers#haskell_stack#EscapeExecutable(l:executable, 'hlint') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/inko.vim b/sources_non_forked/ale/autoload/ale/handlers/inko.vim new file mode 100644 index 00000000..73f06871 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/inko.vim @@ -0,0 +1,37 @@ +" Author: Yorick Peterse +" Description: output handlers for the Inko JSON format + +function! ale#handlers#inko#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + endif + + return 'E' +endfunction + +function! ale#handlers#inko#Handle(buffer, lines) abort + try + let l:errors = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:errors) + return [] + endif + + let l:output = [] + let l:dir = expand('#' . a:buffer . ':p:h') + + for l:error in l:errors + call add(l:output, { + \ 'filename': ale#path#GetAbsPath(l:dir, l:error['file']), + \ 'lnum': l:error['line'], + \ 'col': l:error['column'], + \ 'text': l:error['message'], + \ 'type': ale#handlers#inko#GetType(l:error['level']), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim new file mode 100644 index 00000000..77e7ab66 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ktlint.vim @@ -0,0 +1,45 @@ +" Author: Michael Phillips +" Description: Handler functions for ktlint. + +call ale#Set('kotlin_ktlint_executable', 'ktlint') +call ale#Set('kotlin_ktlint_rulesets', []) +call ale#Set('kotlin_ktlint_options', '') + +function! ale#handlers#ktlint#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'kotlin_ktlint_executable') + let l:options = ale#Var(a:buffer, 'kotlin_ktlint_options') + let l:rulesets = ale#handlers#ktlint#GetRulesets(a:buffer) + + return ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . (empty(l:rulesets) ? '' : ' ' . l:rulesets) + \ . ' --stdin' +endfunction + +function! ale#handlers#ktlint#GetRulesets(buffer) abort + let l:rulesets = map(ale#Var(a:buffer, 'kotlin_ktlint_rulesets'), '''--ruleset '' . v:val') + + return join(l:rulesets, ' ') +endfunction + +function! ale#handlers#ktlint#Handle(buffer, lines) abort + let l:message_pattern = '^\(.*\):\([0-9]\+\):\([0-9]\+\):\s\+\(.*\)' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:message_pattern) + let l:line = l:match[2] + 0 + let l:column = l:match[3] + 0 + let l:text = l:match[4] + + let l:type = l:text =~? 'not a valid kotlin file' ? 'E' : 'W' + + call add(l:output, { + \ 'lnum': l:line, + \ 'col': l:column, + \ 'text': l:text, + \ 'type': l:type + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim new file mode 100644 index 00000000..73974ceb --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/languagetool.vim @@ -0,0 +1,77 @@ +" Author: Vincent (wahrwolf [at] wolfpit.net) +" Description: languagetool for markdown files +" +call ale#Set('languagetool_executable', 'languagetool') +call ale#Set('languagetool_options', '--autoDetect') + +function! ale#handlers#languagetool#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'languagetool_executable') +endfunction + +function! ale#handlers#languagetool#GetCommand(buffer) abort + let l:executable = ale#handlers#languagetool#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'languagetool_options') + + return ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) . ' %s' +endfunction + +function! ale#handlers#languagetool#HandleOutput(buffer, lines) abort + " Match lines like: + " 1.) Line 5, column 1, Rule ID: + let l:head_pattern = '^\v.+.\) Line (\d+), column (\d+), Rule ID. (.+)$' + let l:head_matches = ale#util#GetMatches(a:lines, l:head_pattern) + + " Match lines like: + " Message: Did you forget a comma after a conjunctive/linking adverb? + let l:message_pattern = '^\vMessage. (.+)$' + let l:message_matches = ale#util#GetMatches(a:lines, l:message_pattern) + + " Match lines like: + " ^^^^^ " + let l:markers_pattern = '^\v *(\^+) *$' + let l:markers_matches = ale#util#GetMatches(a:lines, l:markers_pattern) + + let l:output = [] + + + " Okay tbh I was to lazy to figure out a smarter solution here + " We just check that the arrays are same sized and merge everything + " together + let l:i = 0 + + while l:i < len(l:head_matches) + \ && ( + \ (len(l:head_matches) == len(l:markers_matches)) + \ && (len(l:head_matches) == len(l:message_matches)) + \ ) + let l:item = { + \ 'lnum' : str2nr(l:head_matches[l:i][1]), + \ 'col' : str2nr(l:head_matches[l:i][2]), + \ 'end_col' : str2nr(l:head_matches[l:i][2]) + len(l:markers_matches[l:i][1])-1, + \ 'type' : 'W', + \ 'code' : l:head_matches[l:i][3], + \ 'text' : l:message_matches[l:i][1] + \} + call add(l:output, l:item) + let l:i+=1 + endwhile + + return l:output +endfunction + +" Define the languagetool linter for a given filetype. +" TODO: +" - Add language detection settings based on user env (for mothertongue) +" - Add fixer +" - Add config options for rules +function! ale#handlers#languagetool#DefineLinter(filetype) abort + call ale#linter#Define(a:filetype, { + \ 'name': 'languagetool', + \ 'executable': function('ale#handlers#languagetool#GetExecutable'), + \ 'command': function('ale#handlers#languagetool#GetCommand'), + \ 'output_stream': 'stdout', + \ 'callback': 'ale#handlers#languagetool#HandleOutput', + \ 'lint_file': 1, + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim new file mode 100644 index 00000000..6c273bd0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/markdownlint.vim @@ -0,0 +1,24 @@ +" Author: Ty-Lucas Kelley +" Description: Adds support for markdownlint + +function! ale#handlers#markdownlint#Handle(buffer, lines) abort + let l:pattern=': \?\(\d\+\)\(:\(\d\+\)\?\)\? \(MD\d\{3}/[A-Za-z0-9-/]\+\) \(.*\)$' + let l:output=[] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:result = ({ + \ 'lnum': l:match[1] + 0, + \ 'code': l:match[4], + \ 'text': l:match[5], + \ 'type': 'W', + \}) + + if len(l:match[3]) > 0 + let l:result.col = (l:match[3] + 0) + endif + + call add(l:output, l:result) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/naga.vim b/sources_non_forked/ale/autoload/ale/handlers/naga.vim new file mode 100644 index 00000000..6480aba6 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/naga.vim @@ -0,0 +1,30 @@ +" Author: rhysd +" Description: Handle errors for naga-cli. + +function! ale#handlers#naga#Handle(buffer, lines) abort + let l:errors = [] + let l:current_error = v:null + + for l:line in a:lines + if l:line =~# '^error: ' + let l:text = l:line[7:] + let l:current_error = { 'text': l:text, 'type': 'E' } + continue + endif + + if l:current_error isnot v:null + let l:matches = matchlist(l:line, '\v:(\d+):(\d+)$') + + if !empty(l:matches) + let l:current_error.lnum = str2nr(l:matches[1]) + let l:current_error.col = str2nr(l:matches[2]) + call add(l:errors, l:current_error) + let l:current_error = v:null + continue + endif + endif + endfor + + return l:errors +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim new file mode 100644 index 00000000..2738ea2b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ocamllsp.vim @@ -0,0 +1,30 @@ +" Author: Risto Stevcev +" Description: Handlers for the official OCaml language server + +let s:language_id_of_filetype = { +\ 'menhir': 'ocaml.menhir', +\ 'ocaml': 'ocaml', +\ 'ocamlinterface': 'ocaml.interface', +\ 'ocamllex': 'ocaml.lex' +\} + +function! ale#handlers#ocamllsp#GetExecutable(buffer) abort + return 'ocamllsp' +endfunction + +function! ale#handlers#ocamllsp#GetCommand(buffer) abort + let l:executable = ale#handlers#ocamllsp#GetExecutable(a:buffer) + let l:ocaml_ocamllsp_use_opam = ale#Var(a:buffer, 'ocaml_ocamllsp_use_opam') + + return l:ocaml_ocamllsp_use_opam ? 'opam config exec -- ' . l:executable : l:executable +endfunction + +function! ale#handlers#ocamllsp#GetLanguage(buffer) abort + return s:language_id_of_filetype[getbufvar(a:buffer, '&filetype')] +endfunction + +function! ale#handlers#ocamllsp#GetProjectRoot(buffer) abort + let l:dune_project_file = ale#path#FindNearestFile(a:buffer, 'dune-project') + + return !empty(l:dune_project_file) ? fnamemodify(l:dune_project_file, ':h') : '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ols.vim b/sources_non_forked/ale/autoload/ale/handlers/ols.vim new file mode 100644 index 00000000..c292c6d9 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ols.vim @@ -0,0 +1,26 @@ +" Author: Michael Jungo +" Description: Handlers for the OCaml language server + +function! ale#handlers#ols#GetExecutable(buffer) abort + let l:ols_setting = ale#handlers#ols#GetLanguage(a:buffer) . '_ols' + + return ale#path#FindExecutable(a:buffer, l:ols_setting, [ + \ 'node_modules/.bin/ocaml-language-server', + \]) +endfunction + +function! ale#handlers#ols#GetCommand(buffer) abort + let l:executable = ale#handlers#ols#GetExecutable(a:buffer) + + return ale#node#Executable(a:buffer, l:executable) . ' --stdio' +endfunction + +function! ale#handlers#ols#GetLanguage(buffer) abort + return getbufvar(a:buffer, '&filetype') +endfunction + +function! ale#handlers#ols#GetProjectRoot(buffer) abort + let l:merlin_file = ale#path#FindNearestFile(a:buffer, '.merlin') + + return !empty(l:merlin_file) ? fnamemodify(l:merlin_file, ':h') : '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/openscad.vim b/sources_non_forked/ale/autoload/ale/handlers/openscad.vim new file mode 100644 index 00000000..33eee31c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/openscad.vim @@ -0,0 +1,73 @@ +scriptencoding utf-8LE +" Description: This file defines a handler function for linting OpenSCAD files +" with SCA2D + +function! ale#handlers#openscad#SCA2D_callback(buffer, lines) abort + " Example output:: + " foo.scad:3:1: W2001: Variable `unused` overwritten within scope. + " foo.scad:1:1: F0001: Cannot read file due to syntax error: + " - No terminal matches '}' in the current parser context, at line 1 col 36 + let l:filename_re = '^\([^:]*\):' + let l:linenum_re = '\([0-9]*\):' + let l:colnum_re = '\([0-9]*\):' + let l:err_id = '\([IWEFU][0-9]\+\):' + let l:err_msg = '\(.*\)' + let l:pattern = filename_re . + \ linenum_re . + \ colnum_re . + \ ' ' . + \ err_id . + \ ' ' . + \ err_msg + + let l:result = [] + let l:idx = 0 + + for l:line in a:lines + let l:matches = matchlist(line, pattern) + + if len(matches) > 0 + " option: Info, Warning, Error, Fatal, Unknown + if index(['I', 'W'], matches[4][0]) >= 0 + let l:type = 'W' + else + let l:type = 'E' + endif + + let l:lnum = matches[2] + let l:col = matches[3] + let l:text = matches[5] + + " Better locations for some syntax errors + if matches[4][0] is# 'F' + let l:syntax_error_re = '^\(.*\), at line \([0-9]\+\) col \([0-9]\+\)$' + let l:next_line = a:lines[idx+1] + let l:syn_err_matches = matchlist(l:next_line, l:syntax_error_re) + + if len(syn_err_matches) > 0 + let l:text = l:text . l:syn_err_matches[1] + let l:lnum = l:syn_err_matches[2] + let l:col = l:syn_err_matches[3] + else + let l:text = l:next_line + endif + endif + + let l:element = { + \ 'lnum': str2nr(l:lnum), + \ 'col': str2nr(l:col), + \ 'text': l:text, + \ 'detail': l:matches[4] . ': ' . l:text, + \ 'filename': fnamemodify(matches[1], ':p'), + \ 'type': l:type + \ } + + call add(l:result, l:element) + endif + + let l:idx += 1 + endfor + + return result + +endfun diff --git a/sources_non_forked/ale/autoload/ale/handlers/pony.vim b/sources_non_forked/ale/autoload/ale/handlers/pony.vim new file mode 100644 index 00000000..ea84ac4b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/pony.vim @@ -0,0 +1,33 @@ +scriptencoding utf-8 +" Description: This file defines a handler function which ought to work for +" any program which outputs errors in the format that ponyc uses. + +function! s:RemoveUnicodeQuotes(text) abort + let l:text = a:text + let l:text = substitute(l:text, '[`´‘’]', '''', 'g') + let l:text = substitute(l:text, '\v\\u2018([^\\]+)\\u2019', '''\1''', 'g') + let l:text = substitute(l:text, '[“”]', '"', 'g') + + return l:text +endfunction + +function! ale#handlers#pony#HandlePonycFormat(buffer, lines) abort + " Look for lines like the following. + " /home/code/pony/classes/Wombat.pony:22:30: can't lookup private fields from outside the type + let l:pattern = '\v^([^:]+):(\d+):(\d+)?:? (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'filename': l:match[1], + \ 'lnum': str2nr(l:match[2]), + \ 'col': str2nr(l:match[3]), + \ 'type': 'E', + \ 'text': s:RemoveUnicodeQuotes(l:match[4]), + \} + + call add(l:output, l:item) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/redpen.vim b/sources_non_forked/ale/autoload/ale/handlers/redpen.vim new file mode 100644 index 00000000..195057ca --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/redpen.vim @@ -0,0 +1,65 @@ +" Author: rhysd https://rhysd.github.io +" Description: Redpen, a proofreading tool (http://redpen.cc) + +function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort + " Only one file was passed to redpen. So response array has only one + " element. + let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {}) + let l:output = [] + + for l:err in get(l:res, 'errors', []) + let l:item = { + \ 'text': l:err.message, + \ 'type': 'W', + \ 'code': l:err.validator, + \} + + if has_key(l:err, 'startPosition') + let l:item.lnum = l:err.startPosition.lineNum + let l:item.col = l:err.startPosition.offset + 1 + + if has_key(l:err, 'endPosition') + let l:item.end_lnum = l:err.endPosition.lineNum + let l:item.end_col = l:err.endPosition.offset + endif + else + " Fallback to a whole sentence region when a region is not + " specified by the error. + let l:item.lnum = l:err.lineNum + let l:item.col = l:err.sentenceStartColumnNum + 1 + endif + + " Adjust column number for multibyte string + let l:line = getline(l:item.lnum) + + if l:line is# '' + let l:line = l:err.sentence + endif + + let l:line = split(l:line, '\zs') + + if l:item.col >= 2 + let l:col = 0 + + for l:strlen in map(l:line[0:(l:item.col - 2)], 'strlen(v:val)') + let l:col = l:col + l:strlen + endfor + + let l:item.col = l:col + 1 + endif + + if has_key(l:item, 'end_col') + let l:col = 0 + + for l:strlen in map(l:line[0:(l:item.end_col - 1)], 'strlen(v:val)') + let l:col = l:col + l:strlen + endfor + + let l:item.end_col = l:col + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/ruby.vim b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim new file mode 100644 index 00000000..7a1c5765 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/ruby.vim @@ -0,0 +1,38 @@ +" Author: Brandon Roehl - https://github.com/BrandonRoehl, Matthias Guenther https://wikimatze.de +" +" Description: This file implements handlers specific to Ruby. + +function! s:HandleSyntaxError(buffer, lines) abort + " Matches patterns line the following: + " + " test.rb:3: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument + " test.rb:8: syntax error, unexpected keyword_end, expecting end-of-input + let l:pattern = '\v^.+:(\d+): (warning: )?(.+)$' + let l:column = '\v^(\s+)\^$' + let l:output = [] + + for l:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + let l:match = matchlist(l:line, l:column) + + if len(l:match) != 0 + let l:output[len(l:output) - 1]['col'] = len(l:match[1]) + endif + else + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': 0, + \ 'text': l:match[2] . l:match[3], + \ 'type': empty(l:match[2]) ? 'E' : 'W', + \}) + endif + endfor + + return l:output +endfunction + +function! ale#handlers#ruby#HandleSyntaxErrors(buffer, lines) abort + return s:HandleSyntaxError(a:buffer, a:lines) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/rust.vim b/sources_non_forked/ale/autoload/ale/handlers/rust.vim new file mode 100644 index 00000000..a7fac464 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/rust.vim @@ -0,0 +1,78 @@ +" Author: Daniel Schemala , +" w0rp +" +" Description: This file implements handlers specific to Rust. + +if !exists('g:ale_rust_ignore_error_codes') + let g:ale_rust_ignore_error_codes = [] +endif + +if !exists('g:ale_rust_ignore_secondary_spans') + let g:ale_rust_ignore_secondary_spans = 0 +endif + +function! s:FindSpan(buffer, span) abort + if ale#path#IsBufferPath(a:buffer, a:span.file_name) || a:span.file_name is# '' + return a:span + endif + + " Search inside the expansion of an error, as the problem for this buffer + " could lie inside a nested object. + if !empty(get(a:span, 'expansion', v:null)) + return s:FindSpan(a:buffer, a:span.expansion.span) + endif + + return {} +endfunction + +function! ale#handlers#rust#HandleRustErrors(buffer, lines) abort + let l:output = [] + + for l:errorline in a:lines + " ignore everything that is not JSON + if l:errorline !~# '^{' + continue + endif + + let l:error = json_decode(l:errorline) + + if has_key(l:error, 'message') && type(l:error.message) is v:t_dict + let l:error = l:error.message + endif + + if !has_key(l:error, 'code') + continue + endif + + if !empty(l:error.code) && index(g:ale_rust_ignore_error_codes, l:error.code.code) > -1 + continue + endif + + for l:root_span in l:error.spans + let l:span = s:FindSpan(a:buffer, l:root_span) + + if ale#Var(a:buffer, 'rust_ignore_secondary_spans') && !get(l:span, 'is_primary', 1) + continue + endif + + if !empty(l:span) + let l:output_line = { + \ 'lnum': l:span.line_start, + \ 'end_lnum': l:span.line_end, + \ 'col': l:span.column_start, + \ 'end_col': l:span.column_end-1, + \ 'text': empty(l:span.label) ? l:error.message : printf('%s: %s', l:error.message, l:span.label), + \ 'type': toupper(l:error.level[0]), + \} + + if has_key(l:error, 'rendered') && !empty(l:error.rendered) + let l:output_line.detail = l:error.rendered + endif + + call add(l:output, l:output_line) + endif + endfor + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/scala.vim b/sources_non_forked/ale/autoload/ale/handlers/scala.vim new file mode 100644 index 00000000..3fe7a12e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/scala.vim @@ -0,0 +1,37 @@ +" Author: Nils Leuzinger - https://github.com/PawkyPenguin +" Description: Scala linting handlers for scalac-like compilers. + +function! ale#handlers#scala#HandleScalacLintFormat(buffer, lines) abort + " Matches patterns line the following: + " + " /var/folders/5q/20rgxx3x1s34g3m14n5bq0x80000gn/T/vv6pSsy/0:26: error: expected class or object definition + let l:pattern = '^.\+:\(\d\+\): \(\w\+\): \(.\+\)' + let l:output = [] + let l:ln = 0 + + for l:line in a:lines + let l:ln = l:ln + 1 + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:text = l:match[3] + let l:type = l:match[2] is# 'error' ? 'E' : 'W' + let l:col = 0 + + if l:ln + 1 < len(a:lines) + let l:col = stridx(a:lines[l:ln + 1], '^') + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:col + 1, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/sh.vim b/sources_non_forked/ale/autoload/ale/handlers/sh.vim new file mode 100644 index 00000000..6ed9fea3 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/sh.vim @@ -0,0 +1,37 @@ +" Author: w0rp + +function! ale#handlers#sh#GetShellType(buffer) abort + let l:shebang = get(getbufline(a:buffer, 1), 0, '') + + let l:command = '' + + " Take the shell executable from the shebang, if we can. + if l:shebang[:1] is# '#!' + " Remove options like -e, etc. + let l:command = substitute(l:shebang, ' --\?[a-zA-Z0-9]\+', '', 'g') + endif + + " With no shebang line, attempt to use Vim's buffer-local variables. + if l:command is# '' + if getbufvar(a:buffer, 'is_bash', 0) + let l:command = 'bash' + elseif getbufvar(a:buffer, 'is_sh', 0) + let l:command = 'sh' + elseif getbufvar(a:buffer, 'is_kornshell', 0) + let l:command = 'ksh' + endif + endif + + " If we couldn't find a shebang, try the filetype + if l:command is# '' + let l:command = &filetype + endif + + for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + if l:command =~# l:possible_shell . '\s*$' + return l:possible_shell + endif + endfor + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim new file mode 100644 index 00000000..17de2912 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/shellcheck.vim @@ -0,0 +1,123 @@ +" Author: w0rp +" Description: This file adds support for using the shellcheck linter + +" Shellcheck supports shell directives to define the shell dialect for scripts +" that do not have a shebang for some reason. +" https://github.com/koalaman/shellcheck/wiki/Directive#shell +function! ale#handlers#shellcheck#GetShellcheckDialectDirective(buffer) abort + let l:linenr = 0 + let l:pattern = '\s\{-}#\s\{-}shellcheck\s\{-}shell=\(.*\)' + let l:possible_shell = ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] + + while l:linenr < min([50, line('$')]) + let l:linenr += 1 + let l:match = matchlist(getline(l:linenr), l:pattern) + + if len(l:match) > 1 && index(l:possible_shell, l:match[1]) >= 0 + return l:match[1] + endif + endwhile + + return '' +endfunction + +function! ale#handlers#shellcheck#GetDialectArgument(buffer) abort + let l:shell_type = ale#handlers#shellcheck#GetShellcheckDialectDirective(a:buffer) + + if empty(l:shell_type) + let l:shell_type = ale#handlers#sh#GetShellType(a:buffer) + endif + + if !empty(l:shell_type) + " Use the dash dialect for /bin/ash, etc. + if l:shell_type is# 'ash' + return 'dash' + endif + + return l:shell_type + endif + + return '' +endfunction + +function! ale#handlers#shellcheck#GetCwd(buffer) abort + return ale#Var(a:buffer, 'sh_shellcheck_change_directory') ? '%s:h' : '' +endfunction + +function! ale#handlers#shellcheck#GetCommand(buffer, version) abort + let l:options = ale#Var(a:buffer, 'sh_shellcheck_options') + let l:exclude_option = ale#Var(a:buffer, 'sh_shellcheck_exclusions') + let l:dialect = ale#Var(a:buffer, 'sh_shellcheck_dialect') + let l:external_option = ale#semver#GTE(a:version, [0, 4, 0]) ? ' -x' : '' + + if l:dialect is# 'auto' + let l:dialect = ale#handlers#shellcheck#GetDialectArgument(a:buffer) + endif + + return '%e' + \ . (!empty(l:dialect) ? ' -s ' . l:dialect : '') + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . (!empty(l:exclude_option) ? ' -e ' . l:exclude_option : '') + \ . l:external_option + \ . ' -f gcc -' +endfunction + +function! ale#handlers#shellcheck#Handle(buffer, lines) abort + let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+) \[([^\]]+)\]$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + if l:match[4] is# 'error' + let l:type = 'E' + elseif l:match[4] is# 'note' + let l:type = 'I' + else + let l:type = 'W' + endif + + let l:item = { + \ 'lnum': str2nr(l:match[2]), + \ 'type': l:type, + \ 'text': l:match[5], + \ 'code': l:match[6], + \} + + if !empty(l:match[3]) + let l:item.col = str2nr(l:match[3]) + endif + + " If the filename is something like , or -, then + " this is an error for the file we checked. + if l:match[1] isnot# '-' && l:match[1][0] isnot# '<' + let l:item['filename'] = l:match[1] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + +function! ale#handlers#shellcheck#DefineLinter(filetype) abort + " This global variable can be set with a string of comma-separated error + " codes to exclude from shellcheck. For example: + " let g:ale_sh_shellcheck_exclusions = 'SC2002,SC2004' + call ale#Set('sh_shellcheck_exclusions', get(g:, 'ale_linters_sh_shellcheck_exclusions', '')) + call ale#Set('sh_shellcheck_executable', 'shellcheck') + call ale#Set('sh_shellcheck_dialect', 'auto') + call ale#Set('sh_shellcheck_options', '') + call ale#Set('sh_shellcheck_change_directory', 1) + + call ale#linter#Define(a:filetype, { + \ 'name': 'shellcheck', + \ 'executable': {buffer -> ale#Var(buffer, 'sh_shellcheck_executable')}, + \ 'cwd': function('ale#handlers#shellcheck#GetCwd'), + \ 'command': {buffer -> ale#semver#RunWithVersionCheck( + \ buffer, + \ ale#Var(buffer, 'sh_shellcheck_executable'), + \ '%e --version', + \ function('ale#handlers#shellcheck#GetCommand'), + \ )}, + \ 'callback': 'ale#handlers#shellcheck#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/sml.vim b/sources_non_forked/ale/autoload/ale/handlers/sml.vim new file mode 100644 index 00000000..403b25fa --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/sml.vim @@ -0,0 +1,102 @@ +" Author: Jake Zimmerman +" Description: Shared functions for SML linters + +" The glob to use for finding the .cm file. +" +" See :help ale-sml-smlnj for more information. +call ale#Set('sml_smlnj_cm_file', '*.cm') + +function! ale#handlers#sml#GetCmFile(buffer) abort + let l:pattern = ale#Var(a:buffer, 'sml_smlnj_cm_file') + let l:as_list = 1 + + let l:cmfile = '' + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + let l:results = glob(l:path . '/' . l:pattern, 0, l:as_list) + + if len(l:results) > 0 + " If there is more than one CM file, we take the first one + " See :help ale-sml-smlnj for how to configure this. + let l:cmfile = l:results[0] + endif + endfor + + return l:cmfile +endfunction + +" Only one of smlnj or smlnj-cm can be enabled at a time. +function! s:GetExecutable(buffer, source) abort + if ale#handlers#sml#GetCmFile(a:buffer) is# '' + " No CM file found; only allow single-file mode to be enabled + if a:source is# 'smlnj-file' + return 'sml' + elseif a:source is# 'smlnj-cm' + return '' + endif + else + " Found a CM file; only allow cm-file mode to be enabled + if a:source is# 'smlnj-file' + return '' + elseif a:source is# 'smlnj-cm' + return 'sml' + endif + endif +endfunction + +function! ale#handlers#sml#GetExecutableSmlnjCm(buffer) abort + return s:GetExecutable(a:buffer, 'smlnj-cm') +endfunction + +function! ale#handlers#sml#GetExecutableSmlnjFile(buffer) abort + return s:GetExecutable(a:buffer, 'smlnj-file') +endfunction + +function! ale#handlers#sml#Handle(buffer, lines) abort + " Try to match basic sml errors + " TODO(jez) We can get better errorfmt strings from Syntastic + let l:out = [] + let l:pattern = '^\(.*\)\:\([0-9\.]\+\)\ \(\w\+\)\:\ \(.*\)' + let l:pattern2 = '^\(.*\)\:\([0-9]\+\)\.\?\([0-9]\+\).* \(\(Warning\|Error\): .*\)' + + for l:line in a:lines + let l:match2 = matchlist(l:line, l:pattern2) + + if len(l:match2) != 0 + if l:match2[1] =~# 'stdIn$' + let l:loc = {'bufnr': a:buffer} + else + let l:loc = {'filename': l:match2[1]} + endif + + call add(l:out, extend(l:loc, { + \ 'lnum': l:match2[2] + 0, + \ 'col' : l:match2[3] - 1, + \ 'text': l:match2[4], + \ 'type': l:match2[4] =~# '^Warning' ? 'W' : 'E', + \})) + continue + endif + + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) != 0 + if l:match[1] =~# 'stdIn$' + let l:loc = {'bufnr': a:buffer} + else + let l:loc = {'filename': l:match[1]} + endif + + call add(l:out, extend(l:loc, { + \ 'lnum': l:match[2] + 0, + \ 'text': l:match[3] . ': ' . l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \})) + continue + endif + endfor + + return l:out +endfunction + +" vim:ts=4:sts=4:sw=4 diff --git a/sources_non_forked/ale/autoload/ale/handlers/solhint.vim b/sources_non_forked/ale/autoload/ale/handlers/solhint.vim new file mode 100644 index 00000000..611aa7bd --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/solhint.vim @@ -0,0 +1,98 @@ +" Author: Henrique Barcelos <@hbarcelos> +" Description: Functions for working with local solhint for checking *.sol files. + +let s:executables = [ +\ 'node_modules/.bin/solhint', +\ 'node_modules/solhint/solhint.js', +\ 'solhint', +\] + +let s:sep = has('win32') ? '\' : '/' + +call ale#Set('solidity_solhint_options', '') +call ale#Set('solidity_solhint_executable', 'solhint') +call ale#Set('solidity_solhint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale#handlers#solhint#Handle(buffer, lines) abort + " Matches patterns like the following: + " /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars) + let l:output = [] + + let l:lint_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$' + + for l:match in ale#util#GetMatches(a:lines, l:lint_pattern) + let l:isError = l:match[3] is? 'error' + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'code': l:match[5], + \ 'type': l:isError ? 'E' : 'W', + \}) + endfor + + let l:syntax_pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (Parse error): (.*)$' + + for l:match in ale#util#GetMatches(a:lines, l:syntax_pattern) + let l:isError = l:match[3] is? 'error' + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[5], + \ 'code': l:match[4], + \ 'type': l:isError ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#solhint#FindConfig(buffer) abort + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + for l:basename in [ + \ '.solhintrc.js', + \ '.solhintrc.json', + \ '.solhintrc', + \] + let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep)) + + if filereadable(l:config) + return l:config + endif + endfor + endfor + + return ale#path#FindNearestFile(a:buffer, 'package.json') +endfunction + +function! ale#handlers#solhint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'solidity_solhint', s:executables) +endfunction + +" Given a buffer, return an appropriate working directory for solhint. +function! ale#handlers#solhint#GetCwd(buffer) abort + " If solhint is installed in a directory which contains the buffer, assume + " it is the solhint project root. Otherwise, use nearest node_modules. + " Note: If node_modules not present yet, can't load local deps anyway. + let l:executable = ale#path#FindNearestExecutable(a:buffer, s:executables) + + if !empty(l:executable) + let l:nmi = strridx(l:executable, 'node_modules') + let l:project_dir = l:executable[0:l:nmi - 2] + else + let l:modules_dir = ale#path#FindNearestDirectory(a:buffer, 'node_modules') + let l:project_dir = !empty(l:modules_dir) ? fnamemodify(l:modules_dir, ':h:h') : '' + endif + + return !empty(l:project_dir) ? l:project_dir : '' +endfunction + +function! ale#handlers#solhint#GetCommand(buffer) abort + let l:executable = ale#handlers#solhint#GetExecutable(a:buffer) + + let l:options = ale#Var(a:buffer, 'solidity_solhint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' --formatter compact %s' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/spectral.vim b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim new file mode 100644 index 00000000..1eb4a5de --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/spectral.vim @@ -0,0 +1,31 @@ +" Author: t2h5 +" Description: Integration of Stoplight Spectral CLI with ALE. + +function! ale#handlers#spectral#HandleSpectralOutput(buffer, lines) abort + " Matches patterns like the following: + " openapi.yml:1:1 error oas3-schema "Object should have required property `info`." + " openapi.yml:1:1 warning oas3-api-servers "OpenAPI `servers` must be present and non-empty array." + let l:pattern = '\v^.*:(\d+):(\d+) (error|warning) (.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:obj = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \ 'text': l:match[4], + \} + + let l:code_match = matchlist(l:obj.text, '\v^(.+) "(.+)"$') + + if !empty(l:code_match) + let l:obj.code = l:code_match[1] + let l:obj.text = l:code_match[2] + endif + + call add(l:output, l:obj) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/handlers/statix.vim b/sources_non_forked/ale/autoload/ale/handlers/statix.vim new file mode 100644 index 00000000..eeef4107 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/statix.vim @@ -0,0 +1,24 @@ +scriptencoding utf-8 +" Author: David Houston +" Description: This file defines a handler function for statix's errorformat +" output. + +function! ale#handlers#statix#Handle(buffer, lines) abort + " Look for lines like the following. + " + " flake.nix>46:13:W:3:This assignment is better written with `inherit` + let l:pattern = '\v^.*\>(\d+):(\d+):([A-Z]):(\d+):(.*)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'type': l:match[3], + \ 'code': l:match[4], + \ 'text': l:match[5], + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/textlint.vim b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim new file mode 100644 index 00000000..7a648617 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/textlint.vim @@ -0,0 +1,39 @@ +" Author: tokida https://rouger.info, Yasuhiro Kiyota +" Description: textlint, a proofreading tool (https://textlint.github.io/) + +call ale#Set('textlint_executable', 'textlint') +call ale#Set('textlint_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('textlint_options', '') + +function! ale#handlers#textlint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'textlint', [ + \ 'node_modules/.bin/textlint', + \ 'node_modules/textlint/bin/textlint.js', + \]) +endfunction + +function! ale#handlers#textlint#GetCommand(buffer) abort + let l:executable = ale#handlers#textlint#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'textlint_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' -f json --stdin --stdin-filename %s' +endfunction + +function! ale#handlers#textlint#HandleTextlintOutput(buffer, lines) abort + let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {'messages': []}) + let l:output = [] + + for l:err in l:res.messages + call add(l:output, { + \ 'text': l:err.message, + \ 'type': 'W', + \ 'code': l:err.ruleId, + \ 'lnum': l:err.line, + \ 'col' : l:err.column + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/tslint.vim b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim new file mode 100644 index 00000000..ee091d24 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/tslint.vim @@ -0,0 +1,13 @@ +function! ale#handlers#tslint#InitVariables() abort + call ale#Set('typescript_tslint_executable', 'tslint') + call ale#Set('typescript_tslint_config_path', '') + call ale#Set('typescript_tslint_rules_dir', '') + call ale#Set('typescript_tslint_use_global', get(g:, 'ale_use_global_executables', 0)) + call ale#Set('typescript_tslint_ignore_empty_files', 0) +endfunction + +function! ale#handlers#tslint#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'typescript_tslint', [ + \ 'node_modules/.bin/tslint', + \]) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/tsserver.vim b/sources_non_forked/ale/autoload/ale/handlers/tsserver.vim new file mode 100644 index 00000000..f78499ac --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/tsserver.vim @@ -0,0 +1,8 @@ +" Author: Derek Sifford +" Description: Handlers for tsserver + +function! ale#handlers#tsserver#GetProjectRoot(buffer) abort + let l:tsconfig_file = ale#path#FindNearestFile(a:buffer, 'tsconfig.json') + + return !empty(l:tsconfig_file) ? fnamemodify(l:tsconfig_file, ':h') : '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/unix.vim b/sources_non_forked/ale/autoload/ale/handlers/unix.vim new file mode 100644 index 00000000..f90fd591 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/unix.vim @@ -0,0 +1,26 @@ +" Author: w0rp +" Description: Error handling for errors in a Unix format. + +function! s:HandleUnixFormat(buffer, lines, type) abort + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):?(\d+)?:? ?(.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': a:type, + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#unix#HandleAsError(buffer, lines) abort + return s:HandleUnixFormat(a:buffer, a:lines, 'E') +endfunction + +function! ale#handlers#unix#HandleAsWarning(buffer, lines) abort + return s:HandleUnixFormat(a:buffer, a:lines, 'W') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/vale.vim b/sources_non_forked/ale/autoload/ale/handlers/vale.vim new file mode 100644 index 00000000..2da72fc7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/vale.vim @@ -0,0 +1,39 @@ +" Author: Johannes Wienke +" Description: output handler for the vale JSON format + +function! ale#handlers#vale#GetType(severity) abort + if a:severity is? 'warning' + return 'W' + elseif a:severity is? 'suggestion' + return 'I' + endif + + return 'E' +endfunction + +function! ale#handlers#vale#Handle(buffer, lines) abort + try + let l:errors = json_decode(join(a:lines, '')) + catch + return [] + endtry + + if empty(l:errors) + return [] + endif + + let l:output = [] + + for l:error in l:errors[keys(l:errors)[0]] + call add(l:output, { + \ 'lnum': l:error['Line'], + \ 'col': l:error['Span'][0], + \ 'end_col': l:error['Span'][1], + \ 'code': l:error['Check'], + \ 'text': l:error['Message'], + \ 'type': ale#handlers#vale#GetType(l:error['Severity']), + \}) + endfor + + return l:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/writegood.vim b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim new file mode 100644 index 00000000..b5b91b3f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/writegood.vim @@ -0,0 +1,72 @@ +" Author: Sumner Evans +" Description: Error handling for errors in the write-good format. + +function! ale#handlers#writegood#ResetOptions() abort + call ale#Set('writegood_options', '') + call ale#Set('writegood_executable', 'write-good') + call ale#Set('writegood_use_global', get(g:, 'ale_use_global_executables', 0)) +endfunction + +" Reset the options so the tests can test how they are set. +call ale#handlers#writegood#ResetOptions() + +function! ale#handlers#writegood#GetExecutable(buffer) abort + return ale#path#FindExecutable(a:buffer, 'writegood', [ + \ 'node_modules/.bin/write-good', + \ 'node_modules/write-good/bin/write-good.js', + \]) +endfunction + +function! ale#handlers#writegood#GetCommand(buffer) abort + let l:executable = ale#handlers#writegood#GetExecutable(a:buffer) + let l:options = ale#Var(a:buffer, 'writegood_options') + + return ale#node#Executable(a:buffer, l:executable) + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' %t' +endfunction + +function! ale#handlers#writegood#Handle(buffer, lines) abort + " Look for lines like the following. + " + " "it is" is wordy or unneeded on line 20 at column 53 + " "easily" can weaken meaning on line 154 at column 29 + let l:marks_pattern = '\v^ *(\^+) *$' + let l:pattern = '\v^(".*"\s.*)\son\sline\s(\d+)\sat\scolumn\s(\d+)$' + let l:output = [] + let l:last_len = 0 + + for l:match in ale#util#GetMatches(a:lines, [l:marks_pattern, l:pattern]) + if empty(l:match[2]) + let l:last_len = len(l:match[1]) + else + let l:col = l:match[3] + 1 + + " Add the linter error. Note that we need to add 1 to the col because + " write-good reports the column corresponding to the space before the + " offending word or phrase. + call add(l:output, { + \ 'text': l:match[1], + \ 'lnum': l:match[2] + 0, + \ 'col': l:col, + \ 'end_col': l:last_len ? (l:col + l:last_len - 1) : l:col, + \ 'type': 'W', + \}) + + let l:last_len = 0 + endif + endfor + + return l:output +endfunction + +" Define the writegood linter for a given filetype. +function! ale#handlers#writegood#DefineLinter(filetype) abort + call ale#linter#Define(a:filetype, { + \ 'name': 'writegood', + \ 'aliases': ['write-good'], + \ 'executable': function('ale#handlers#writegood#GetExecutable'), + \ 'command': function('ale#handlers#writegood#GetCommand'), + \ 'callback': 'ale#handlers#writegood#Handle', + \}) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/xo.vim b/sources_non_forked/ale/autoload/ale/handlers/xo.vim new file mode 100644 index 00000000..a87c6d8f --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/xo.vim @@ -0,0 +1,44 @@ +call ale#Set('javascript_xo_executable', 'xo') +call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('javascript_xo_options', '') + +call ale#Set('typescript_xo_executable', 'xo') +call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0)) +call ale#Set('typescript_xo_options', '') + +function! ale#handlers#xo#GetExecutable(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#path#FindExecutable(a:buffer, l:type . '_xo', [ + \ 'node_modules/xo/cli.js', + \ 'node_modules/.bin/xo', + \]) +endfunction + +function! ale#handlers#xo#GetLintCommand(buffer) abort + return ale#Escape(ale#handlers#xo#GetExecutable(a:buffer)) + \ . ale#Pad(ale#handlers#xo#GetOptions(a:buffer)) + \ . ' --reporter json --stdin --stdin-filename %s' +endfunction + +function! ale#handlers#xo#GetOptions(buffer) abort + let l:type = ale#handlers#xo#GetType(a:buffer) + + return ale#Var(a:buffer, l:type . '_xo_options') +endfunction + +" xo uses eslint and the output format is the same +function! ale#handlers#xo#HandleJSON(buffer, lines) abort + return ale#handlers#eslint#HandleJSON(a:buffer, a:lines) +endfunction + +function! ale#handlers#xo#GetType(buffer) abort + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:type = 'javascript' + + if l:filetype =~# 'typescript' + let l:type = 'typescript' + endif + + return l:type +endfunction diff --git a/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim new file mode 100644 index 00000000..5e04577d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/handlers/yamllint.vim @@ -0,0 +1,39 @@ +function! ale#handlers#yamllint#GetCommand(buffer) abort + return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options')) + \ . ' -f parsable %t' +endfunction + +function! ale#handlers#yamllint#Handle(buffer, lines) abort + " Matches patterns line the following: + " something.yaml:1:1: [warning] missing document start "---" (document-start) + " something.yml:2:1: [error] syntax error: expected the node content, but found '' + let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:item = { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[4], + \ 'type': l:match[3] is# 'error' ? 'E' : 'W', + \} + + let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$') + + if !empty(l:code_match) + if l:code_match[2] is# 'trailing-spaces' + \&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace') + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + let l:item.text = l:code_match[1] + let l:item.code = l:code_match[2] + endif + + call add(l:output, l:item) + endfor + + return l:output +endfunction + diff --git a/sources_non_forked/ale/autoload/ale/highlight.vim b/sources_non_forked/ale/autoload/ale/highlight.vim new file mode 100644 index 00000000..c284f5ca --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/highlight.vim @@ -0,0 +1,242 @@ +scriptencoding utf8 +" Author: w0rp +" Description: This module implements error/warning highlighting. + +if !hlexists('ALEError') + highlight link ALEError SpellBad +endif + +if !hlexists('ALEStyleError') + highlight link ALEStyleError ALEError +endif + +if !hlexists('ALEWarning') + highlight link ALEWarning SpellCap +endif + +if !hlexists('ALEStyleWarning') + highlight link ALEStyleWarning ALEWarning +endif + +if !hlexists('ALEInfo') + highlight link ALEInfo ALEWarning +endif + +if !hlexists('ALEVirtualTextError') + highlight link ALEVirtualTextError ALEError +endif + +if !hlexists('ALEVirtualTextStyleError') + highlight link ALEVirtualTextStyleError ALEVirtualTextError +endif + +if !hlexists('ALEVirtualTextWarning') + highlight link ALEVirtualTextWarning ALEWarning +endif + +if !hlexists('ALEVirtualTextStyleWarning') + highlight link ALEVirtualTextStyleWarning ALEVirtualTextWarning +endif + +if !hlexists('ALEVirtualTextInfo') + highlight link ALEVirtualTextInfo ALEVirtualTextWarning +endif + +" The maximum number of items for the second argument of matchaddpos() +let s:MAX_POS_VALUES = 8 +let s:MAX_COL_SIZE = 1073741824 " pow(2, 30) + +let s:has_nvim_highlight = exists('*nvim_buf_add_highlight') && exists('*nvim_buf_clear_namespace') + +if s:has_nvim_highlight + let s:ns_id = nvim_create_namespace('ale_highlight') +endif + +" Wrappers are necessary to test this functionality by faking the calls in tests. +function! ale#highlight#nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start, col_end) abort + " Ignore all errors for adding highlights. + try + call nvim_buf_add_highlight(a:buffer, a:ns_id, a:hl_group, a:line, a:col_start, a:col_end) + catch + endtry +endfunction + +function! ale#highlight#nvim_buf_clear_namespace(buffer, ns_id, line_start, line_end) abort + call nvim_buf_clear_namespace(a:buffer, a:ns_id, a:line_start, a:line_end) +endfunction + +function! ale#highlight#CreatePositions(line, col, end_line, end_col) abort + if a:line >= a:end_line + " For single lines, just return the one position. + return [[[a:line, a:col, a:end_col - a:col + 1]]] + endif + + " Get positions from the first line at the first column, up to a large + " integer for highlighting up to the end of the line, followed by + " the lines in-between, for highlighting entire lines, and + " a highlight for the last line, up to the end column. + let l:all_positions = + \ [[a:line, a:col, s:MAX_COL_SIZE]] + \ + range(a:line + 1, a:end_line - 1) + \ + [[a:end_line, 1, a:end_col]] + + return map( + \ range(0, len(l:all_positions) - 1, s:MAX_POS_VALUES), + \ 'l:all_positions[v:val : v:val + s:MAX_POS_VALUES - 1]', + \) +endfunction + +" Given a loclist for current items to highlight, remove all highlights +" except these which have matching loclist item entries. + +function! ale#highlight#RemoveHighlights() abort + if s:has_nvim_highlight + call ale#highlight#nvim_buf_clear_namespace(bufnr(''), s:ns_id, 0, -1) + else + for l:match in getmatches() + if l:match.group =~? '\v^ALE(Style)?(Error|Warning|Info)(Line)?$' + call matchdelete(l:match.id) + endif + endfor + endif +endfunction + +" Same semantics of matchaddpos but will use nvim_buf_add_highlight if +" available. This involves iterating over the position list, switching from +" 1-based indexing to 0-based indexing, and translating the multiple ways +" that position can be specified for matchaddpos into line + col_start + +" col_end. +function! s:matchaddpos(group, pos_list) abort + if s:has_nvim_highlight + for l:pos in a:pos_list + let l:line = type(l:pos) == v:t_number + \ ? l:pos - 1 + \ : l:pos[0] - 1 + + if type(l:pos) == v:t_number || len(l:pos) == 1 + let l:col_start = 0 + let l:col_end = s:MAX_COL_SIZE + else + let l:col_start = l:pos[1] - 1 + let l:col_end = l:col_start + get(l:pos, 2, 1) + endif + + call ale#highlight#nvim_buf_add_highlight( + \ bufnr(''), + \ s:ns_id, + \ a:group, + \ l:line, + \ l:col_start, + \ l:col_end, + \) + endfor + else + call matchaddpos(a:group, a:pos_list) + endif +endfunction + +function! s:highlight_line(bufnr, lnum, group) abort + call s:matchaddpos(a:group, [a:lnum]) +endfunction + +function! s:highlight_range(bufnr, range, group) abort + " Set all of the positions, which are chunked into Lists which + " are as large as will be accepted by matchaddpos. + call map( + \ ale#highlight#CreatePositions( + \ a:range.lnum, + \ a:range.col, + \ a:range.end_lnum, + \ a:range.end_col + \ ), + \ 's:matchaddpos(a:group, v:val)' + \) +endfunction + +function! ale#highlight#UpdateHighlights() abort + let l:item_list = get(b:, 'ale_enabled', 1) && g:ale_enabled + \ ? get(b:, 'ale_highlight_items', []) + \ : [] + + call ale#highlight#RemoveHighlights() + + for l:item in l:item_list + if l:item.type is# 'W' + if get(l:item, 'sub_type', '') is# 'style' + let l:group = 'ALEStyleWarning' + else + let l:group = 'ALEWarning' + endif + elseif l:item.type is# 'I' + let l:group = 'ALEInfo' + elseif get(l:item, 'sub_type', '') is# 'style' + let l:group = 'ALEStyleError' + else + let l:group = 'ALEError' + endif + + let l:range = { + \ 'lnum': l:item.lnum, + \ 'col': l:item.col, + \ 'end_lnum': get(l:item, 'end_lnum', l:item.lnum), + \ 'end_col': get(l:item, 'end_col', l:item.col) + \} + + call s:highlight_range(l:item.bufnr, l:range, l:group) + endfor + + " If highlights are enabled and signs are not enabled, we should still + " offer line highlights by adding a separate set of highlights. + if !g:ale_set_signs + let l:available_groups = { + \ 'ALEWarningLine': hlexists('ALEWarningLine'), + \ 'ALEInfoLine': hlexists('ALEInfoLine'), + \ 'ALEErrorLine': hlexists('ALEErrorLine'), + \} + + for l:item in l:item_list + if l:item.type is# 'W' + let l:group = 'ALEWarningLine' + elseif l:item.type is# 'I' + let l:group = 'ALEInfoLine' + else + let l:group = 'ALEErrorLine' + endif + + if l:available_groups[l:group] + call s:highlight_line(l:item.bufnr, l:item.lnum, l:group) + endif + endfor + endif +endfunction + +function! ale#highlight#BufferHidden(buffer) abort + " Remove highlights right away when buffers are hidden. + " They will be restored later when buffers are entered. + call ale#highlight#RemoveHighlights() +endfunction + +augroup ALEHighlightBufferGroup + autocmd! + autocmd BufEnter * call ale#highlight#UpdateHighlights() + autocmd BufHidden * call ale#highlight#BufferHidden(expand('')) +augroup END + +function! ale#highlight#SetHighlights(buffer, loclist) abort + let l:new_list = getbufvar(a:buffer, 'ale_enabled', 1) && g:ale_enabled + \ ? filter(copy(a:loclist), 'v:val.bufnr == a:buffer && v:val.col > 0') + \ : [] + + " Set the list in the buffer variable. + call setbufvar(str2nr(a:buffer), 'ale_highlight_items', l:new_list) + + let l:exclude_list = ale#Var(a:buffer, 'exclude_highlights') + + if !empty(l:exclude_list) + call filter(l:new_list, 'empty(ale#util#GetMatches(v:val.text, l:exclude_list))') + endif + + " Update highlights for the current buffer, which may or may not + " be the buffer we just set highlights for. + call ale#highlight#UpdateHighlights() +endfunction diff --git a/sources_non_forked/ale/autoload/ale/history.vim b/sources_non_forked/ale/autoload/ale/history.vim new file mode 100644 index 00000000..27ae74c2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/history.vim @@ -0,0 +1,62 @@ +" Author: w0rp +" Description: Tools for managing command history + +" A flag for controlling the maximum size of the command history to store. +let g:ale_max_buffer_history_size = get(g:, 'ale_max_buffer_history_size', 20) + +" Return a shallow copy of the command history for a given buffer number. +function! ale#history#Get(buffer) abort + return copy(getbufvar(a:buffer, 'ale_history', [])) +endfunction + +function! ale#history#Add(buffer, status, job_id, command) abort + if g:ale_max_buffer_history_size <= 0 + " Don't save anything if the history isn't a positive number. + call setbufvar(a:buffer, 'ale_history', []) + + return + endif + + let l:history = getbufvar(a:buffer, 'ale_history', []) + + " Remove the first item if we hit the max history size. + if len(l:history) >= g:ale_max_buffer_history_size + let l:history = l:history[1:] + endif + + call add(l:history, { + \ 'status': a:status, + \ 'job_id': a:job_id, + \ 'command': a:command, + \}) + + call setbufvar(a:buffer, 'ale_history', l:history) +endfunction + +function! s:FindHistoryItem(buffer, job_id) abort + " Search backwards to find a matching job ID. IDs might be recycled, + " so finding the last one should be good enough. + for l:obj in reverse(ale#history#Get(a:buffer)) + if l:obj.job_id == a:job_id + return l:obj + endif + endfor + + return {} +endfunction + +" Set an exit code for a command which finished. +function! ale#history#SetExitCode(buffer, job_id, exit_code) abort + let l:obj = s:FindHistoryItem(a:buffer, a:job_id) + + " If we find a match, then set the code and status. + let l:obj.exit_code = a:exit_code + let l:obj.status = 'finished' +endfunction + +" Set the output for a command which finished. +function! ale#history#RememberOutput(buffer, job_id, output) abort + let l:obj = s:FindHistoryItem(a:buffer, a:job_id) + + let l:obj.output = a:output +endfunction diff --git a/sources_non_forked/ale/autoload/ale/hover.vim b/sources_non_forked/ale/autoload/ale/hover.vim new file mode 100644 index 00000000..0954b802 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/hover.vim @@ -0,0 +1,368 @@ +" Author: w0rp +" Description: Hover support for LSP linters. + +let s:hover_map = {} + +" Used to get the hover map in tests. +function! ale#hover#GetMap() abort + return deepcopy(s:hover_map) +endfunction + +" Used to set the hover map in tests. +function! ale#hover#SetMap(map) abort + let s:hover_map = a:map +endfunction + +function! ale#hover#ClearLSPData() abort + let s:hover_map = {} +endfunction + +function! ale#hover#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') is# 'quickinfo' + \&& has_key(s:hover_map, a:response.request_seq) + let l:options = remove(s:hover_map, a:response.request_seq) + + if get(a:response, 'success', v:false) is v:true + \&& get(a:response, 'body', v:null) isnot v:null + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') + + " If we pass the show_documentation flag, we should show the full + " documentation, and always in the preview window. + if get(l:options, 'show_documentation', 0) + let l:documentation = get(a:response.body, 'documentation', '') + + " displayString is not included here, because it can be very + " noisy and run on for many lines for complex types. A less + " verbose alternative may be nice in future. + if !empty(l:documentation) + call ale#preview#Show(split(l:documentation, "\n"), { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \}) + endif + elseif get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') + call balloon_show(a:response.body.displayString) + elseif get(l:options, 'truncated_echo', 0) + if !empty(a:response.body.displayString) + call ale#cursor#TruncatedEcho(a:response.body.displayString) + endif + elseif g:ale_hover_to_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(split(a:response.body.displayString, "\n"), { + \ 'filetype': 'ale-preview.message', + \}) + elseif g:ale_hover_to_preview + call ale#preview#Show(split(a:response.body.displayString, "\n"), { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \}) + else + call ale#util#ShowMessage(a:response.body.displayString) + endif + endif + endif +endfunction + +" Convert a language name to another one. +" The language name could be an empty string or v:null +function! s:ConvertLanguageName(language) abort + return a:language +endfunction + +function! ale#hover#ParseLSPResult(contents) abort + let l:includes = {} + let l:highlights = [] + let l:lines = [] + let l:list = type(a:contents) is v:t_list ? a:contents : [a:contents] + let l:region_index = 0 + + for l:item in l:list + if !empty(l:lines) + call add(l:lines, '') + endif + + if type(l:item) is v:t_dict && has_key(l:item, 'kind') + if l:item.kind is# 'markdown' + " Handle markdown values as we handle strings below. + let l:item = get(l:item, 'value', '') + elseif l:item.kind is# 'plaintext' + " We shouldn't try to parse plaintext as markdown. + " Pass the lines on and skip parsing them. + call extend(l:lines, split(get(l:item, 'value', ''), "\n")) + + continue + endif + endif + + let l:marked_list = [] + + " If the item is a string, then we should parse it as Markdown text. + if type(l:item) is v:t_string + let l:fence_language = v:null + let l:fence_lines = [] + + for l:line in split(l:item, "\n") + if l:fence_language is v:null + " Look for the start of a code fence. (```python, etc.) + let l:match = matchlist(l:line, '^```\(.*\)$') + + if !empty(l:match) + let l:fence_language = l:match[1] + + if !empty(l:marked_list) + call add(l:fence_lines, '') + endif + else + if !empty(l:marked_list) + \&& l:marked_list[-1][0] isnot v:null + call add(l:marked_list, [v:null, ['']]) + endif + + call add(l:marked_list, [v:null, [l:line]]) + endif + elseif l:line =~# '^```$' + " When we hit the end of a code fence, pass the fenced + " lines on to the next steps below. + call add(l:marked_list, [l:fence_language, l:fence_lines]) + let l:fence_language = v:null + let l:fence_lines = [] + else + " Gather lines inside of a code fence. + call add(l:fence_lines, l:line) + endif + endfor + " If the result from the LSP server is a {language: ..., value: ...} + " Dictionary, then that should be interpreted as if it was: + " + " ```${language} + " ${value} + " ``` + elseif type(l:item) is v:t_dict + \&& has_key(l:item, 'language') + \&& type(l:item.language) is v:t_string + \&& has_key(l:item, 'value') + \&& type(l:item.value) is v:t_string + call add( + \ l:marked_list, + \ [l:item.language, split(l:item.value, "\n")], + \) + endif + + for [l:language, l:marked_lines] in l:marked_list + if l:language is v:null + " NOTE: We could handle other Markdown formatting here. + call map( + \ l:marked_lines, + \ 'substitute(v:val, ''\\_'', ''_'', ''g'')', + \) + else + let l:language = s:ConvertLanguageName(l:language) + + if !empty(l:language) + let l:includes[l:language] = printf( + \ 'syntax/%s.vim', + \ l:language, + \) + + let l:start = len(l:lines) + 1 + let l:end = l:start + len(l:marked_lines) + let l:region_index += 1 + + call add(l:highlights, 'syntax region' + \ . ' ALE_hover_' . l:region_index + \ . ' start=/\%' . l:start . 'l/' + \ . ' end=/\%' . l:end . 'l/' + \ . ' contains=@ALE_hover_' . l:language + \) + endif + endif + + call extend(l:lines, l:marked_lines) + endfor + endfor + + let l:include_commands = [] + + for [l:language, l:lang_path] in sort(items(l:includes)) + call add(l:include_commands, 'unlet! b:current_syntax') + call add( + \ l:include_commands, + \ printf('syntax include @ALE_hover_%s %s', l:language, l:lang_path), + \) + endfor + + return [l:include_commands + l:highlights, l:lines] +endfunction + +function! ale#hover#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:hover_map, a:response.id) + let l:options = remove(s:hover_map, a:response.id) + + " If the call did __not__ come from balloonexpr... + if !get(l:options, 'hover_from_balloonexpr', 0) + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:end = len(getline(l:line)) + + if l:buffer isnot l:options.buffer + \|| l:line isnot l:options.line + \|| min([l:column, l:end]) isnot min([l:options.column, l:end]) + " ... Cancel display the message if the cursor has moved. + return + endif + endif + + " The result can be a Dictionary item, a List of the same, or null. + let l:result = get(a:response, 'result', v:null) + + if l:result is v:null + return + endif + + let [l:commands, l:lines] = ale#hover#ParseLSPResult(l:result.contents) + + if !empty(l:lines) + let l:set_balloons = ale#Var(l:options.buffer, 'set_balloons') + + if get(l:options, 'hover_from_balloonexpr', 0) + \&& exists('*balloon_show') + \&& (l:set_balloons is 1 || l:set_balloons is# 'hover') + call balloon_show(join(l:lines, "\n")) + elseif get(l:options, 'truncated_echo', 0) + if type(l:lines[0]) is# v:t_list + call ale#cursor#TruncatedEcho(join(l:lines[0], '\n')) + else + call ale#cursor#TruncatedEcho(l:lines[0]) + endif + elseif g:ale_hover_to_floating_preview || g:ale_floating_preview + call ale#floating_preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'commands': l:commands, + \}) + elseif g:ale_hover_to_preview + call ale#preview#Show(l:lines, { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ 'commands': l:commands, + \}) + else + call ale#util#ShowMessage(join(l:lines, "\n"), { + \ 'commands': l:commands, + \}) + endif + endif + endif +endfunction + +function! s:OnReady(line, column, opt, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'hover') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#hover#HandleTSServerResponse') + \ : function('ale#hover#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:column = a:column + + let l:message = ale#lsp#tsserver_message#Quickinfo( + \ l:buffer, + \ a:line, + \ l:column + \) + else + " Send a message saying the buffer has changed first, or the + " hover position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:column = max([ + \ min([a:column, len(getbufline(l:buffer, a:line)[0])]), + \ 1, + \]) + + let l:message = ale#lsp#message#Hover(l:buffer, a:line, l:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:hover_map[l:request_id] = { + \ 'buffer': l:buffer, + \ 'line': a:line, + \ 'column': l:column, + \ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0), + \ 'show_documentation': get(a:opt, 'show_documentation', 0), + \ 'truncated_echo': get(a:opt, 'truncated_echo', 0), + \} +endfunction + +" Obtain Hover information for the specified position +" Pass optional arguments in the dictionary opt. +" Currently, only one key/value is useful: +" - called_from_balloonexpr, this flag marks if we want the result from this +" ale#hover#Show to display in a balloon if possible +" +" Currently, the callbacks displays the info from hover : +" - in the balloon if opt.called_from_balloonexpr and balloon_show is detected +" - as status message otherwise +function! ale#hover#Show(buffer, line, col, opt) abort + let l:show_documentation = get(a:opt, 'show_documentation', 0) + let l:Callback = function('s:OnReady', [a:line, a:col, a:opt]) + + for l:linter in ale#linter#Get(getbufvar(a:buffer, '&filetype')) + " Only tsserver supports documentation requests at the moment. + if !empty(l:linter.lsp) + \&& (!l:show_documentation || l:linter.lsp is# 'tsserver') + call ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback) + endif + endfor +endfunction + +let s:last_pos = [0, 0, 0] + +" This function implements the :ALEHover command. +function! ale#hover#ShowAtCursor() abort + let l:buffer = bufnr('') + let l:pos = getpos('.') + + call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {}) +endfunction + +function! ale#hover#ShowTruncatedMessageAtCursor() abort + let l:buffer = bufnr('') + let l:pos = getpos('.')[0:2] + + if !getbufvar(l:buffer, 'ale_enabled', 1) + return + endif + + if l:pos != s:last_pos + let s:last_pos = l:pos + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + if empty(l:loc) + call ale#hover#Show( + \ l:buffer, + \ l:pos[1], + \ l:pos[2], + \ {'truncated_echo': 1}, + \) + endif + endif +endfunction + +" This function implements the :ALEDocumentation command. +function! ale#hover#ShowDocumentationAtCursor() abort + let l:buffer = bufnr('') + let l:pos = getpos('.') + let l:options = {'show_documentation': 1} + + call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], l:options) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/java.vim b/sources_non_forked/ale/autoload/ale/java.vim new file mode 100644 index 00000000..859d938d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/java.vim @@ -0,0 +1,26 @@ +" Author: Horacio Sanson https://github.com/hsanson +" Description: Functions for integrating with Java tools + +" Find the nearest dir contining a gradle or pom file and assume it +" the root of a java app. +function! ale#java#FindProjectRoot(buffer) abort + let l:gradle_root = ale#gradle#FindProjectRoot(a:buffer) + + if !empty(l:gradle_root) + return l:gradle_root + endif + + let l:maven_pom_file = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:maven_pom_file) + return fnamemodify(l:maven_pom_file, ':h') + endif + + let l:ant_root = ale#ant#FindProjectRoot(a:buffer) + + if !empty(l:ant_root) + return l:ant_root + endif + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/job.vim b/sources_non_forked/ale/autoload/ale/job.vim new file mode 100644 index 00000000..0fc43a8c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/job.vim @@ -0,0 +1,385 @@ +" Author: w0rp +" Description: APIs for working with Asynchronous jobs, with an API normalised +" between Vim 8 and NeoVim. +" +" Important functions are described below. They are: +" +" ale#job#Start(command, options) -> job_id +" ale#job#IsRunning(job_id) -> 1 if running, 0 otherwise. +" ale#job#Stop(job_id) + +" A setting for wrapping commands. +let g:ale_command_wrapper = get(g:, 'ale_command_wrapper', '') + +if !has_key(s:, 'job_map') + let s:job_map = {} +endif + +" A map from timer IDs to jobs, for tracking jobs that need to be killed +" with SIGKILL if they don't terminate right away. +if !has_key(s:, 'job_kill_timers') + let s:job_kill_timers = {} +endif + +function! s:KillHandler(timer) abort + let l:job = remove(s:job_kill_timers, a:timer) + call job_stop(l:job, 'kill') +endfunction + +function! s:NeoVimCallback(job, data, event) abort + let l:info = s:job_map[a:job] + + if a:event is# 'stdout' + let l:info.out_cb_line = ale#util#JoinNeovimOutput( + \ a:job, + \ l:info.out_cb_line, + \ a:data, + \ l:info.mode, + \ ale#util#GetFunction(l:info.out_cb), + \) + elseif a:event is# 'stderr' + let l:info.err_cb_line = ale#util#JoinNeovimOutput( + \ a:job, + \ l:info.err_cb_line, + \ a:data, + \ l:info.mode, + \ ale#util#GetFunction(l:info.err_cb), + \) + else + if has_key(l:info, 'out_cb') && !empty(l:info.out_cb_line) + call ale#util#GetFunction(l:info.out_cb)(a:job, l:info.out_cb_line) + endif + + if has_key(l:info, 'err_cb') && !empty(l:info.err_cb_line) + call ale#util#GetFunction(l:info.err_cb)(a:job, l:info.err_cb_line) + endif + + try + call ale#util#GetFunction(l:info.exit_cb)(a:job, a:data) + finally + " Automatically forget about the job after it's done. + if has_key(s:job_map, a:job) + call remove(s:job_map, a:job) + endif + endtry + endif +endfunction + +function! s:VimOutputCallback(channel, data) abort + let l:job = ch_getjob(a:channel) + let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) + + " Only call the callbacks for jobs which are valid. + if l:job_id > 0 && has_key(s:job_map, l:job_id) + call ale#util#GetFunction(s:job_map[l:job_id].out_cb)(l:job_id, a:data) + endif +endfunction + +function! s:VimErrorCallback(channel, data) abort + let l:job = ch_getjob(a:channel) + let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) + + " Only call the callbacks for jobs which are valid. + if l:job_id > 0 && has_key(s:job_map, l:job_id) + call ale#util#GetFunction(s:job_map[l:job_id].err_cb)(l:job_id, a:data) + endif +endfunction + +function! s:VimCloseCallback(channel) abort + let l:job = ch_getjob(a:channel) + let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) + let l:info = get(s:job_map, l:job_id, {}) + + if empty(l:info) + return + endif + + " job_status() can trigger the exit handler. + " The channel can close before the job has exited. + if job_status(l:job) is# 'dead' + try + if !empty(l:info) && has_key(l:info, 'exit_cb') + " We have to remove the callback, so we don't call it twice. + call ale#util#GetFunction(remove(l:info, 'exit_cb'))(l:job_id, get(l:info, 'exit_code', 1)) + endif + finally + " Automatically forget about the job after it's done. + if has_key(s:job_map, l:job_id) + call remove(s:job_map, l:job_id) + endif + endtry + endif +endfunction + +function! s:VimExitCallback(job, exit_code) abort + let l:job_id = ale#job#ParseVim8ProcessID(string(a:job)) + let l:info = get(s:job_map, l:job_id, {}) + + if empty(l:info) + return + endif + + let l:info.exit_code = a:exit_code + + " The program can exit before the data has finished being read. + if ch_status(job_getchannel(a:job)) is# 'closed' + try + if !empty(l:info) && has_key(l:info, 'exit_cb') + " We have to remove the callback, so we don't call it twice. + call ale#util#GetFunction(remove(l:info, 'exit_cb'))(l:job_id, a:exit_code) + endif + finally + " Automatically forget about the job after it's done. + if has_key(s:job_map, l:job_id) + call remove(s:job_map, l:job_id) + endif + endtry + endif +endfunction + +function! ale#job#ParseVim8ProcessID(job_string) abort + return matchstr(a:job_string, '\d\+') + 0 +endfunction + +function! ale#job#ValidateArguments(command, options) abort + if a:options.mode isnot# 'nl' && a:options.mode isnot# 'raw' + throw 'Invalid mode: ' . a:options.mode + endif +endfunction + +function! s:PrepareWrappedCommand(original_wrapper, command) abort + let l:match = matchlist(a:command, '\v^(.*(\&\&|;)) *(.*)$') + let l:prefix = '' + let l:command = a:command + + if !empty(l:match) + let l:prefix = l:match[1] . ' ' + let l:command = l:match[3] + endif + + let l:format = a:original_wrapper + + if l:format =~# '%@' + let l:wrapped = substitute(l:format, '%@', ale#Escape(l:command), '') + else + if l:format !~# '%\*' + let l:format .= ' %*' + endif + + let l:wrapped = substitute(l:format, '%\*', l:command, '') + endif + + return l:prefix . l:wrapped +endfunction + +function! ale#job#PrepareCommand(buffer, command) abort + let l:wrapper = ale#Var(a:buffer, 'command_wrapper') + + " The command will be executed in a subshell. This fixes a number of + " issues, including reading the PATH variables correctly, %PATHEXT% + " expansion on Windows, etc. + " + " NeoVim handles this issue automatically if the command is a String, + " but we'll do this explicitly, so we use the same exact command for both + " versions. + let l:command = !empty(l:wrapper) + \ ? s:PrepareWrappedCommand(l:wrapper, a:command) + \ : a:command + + " If a custom shell is specified, use that. + if exists('b:ale_shell') + let l:ale_shell = b:ale_shell + elseif exists('g:ale_shell') + let l:ale_shell = g:ale_shell + endif + + if exists('l:ale_shell') + let l:shell_arguments = get(b:, 'ale_shell_arguments', get(g:, 'ale_shell_arguments', &shellcmdflag)) + + return split(l:ale_shell) + split(l:shell_arguments) + [l:command] + endif + + if has('win32') + return 'cmd /s/c "' . l:command . '"' + endif + + if &shell =~? 'fish$\|pwsh$' + return ['/bin/sh', '-c', l:command] + endif + + return split(&shell) + split(&shellcmdflag) + [l:command] +endfunction + +" Start a job with options which are agnostic to Vim and NeoVim. +" +" The following options are accepted: +" +" out_cb - A callback for receiving stdin. Arguments: (job_id, data) +" err_cb - A callback for receiving stderr. Arguments: (job_id, data) +" exit_cb - A callback for program exit. Arguments: (job_id, status_code) +" mode - A mode for I/O. Can be 'nl' for split lines or 'raw'. +function! ale#job#Start(command, options) abort + call ale#job#ValidateArguments(a:command, a:options) + + let l:job_info = copy(a:options) + let l:job_options = {} + + if has('nvim') + if has_key(a:options, 'out_cb') + let l:job_options.on_stdout = function('s:NeoVimCallback') + let l:job_info.out_cb_line = '' + endif + + if has_key(a:options, 'err_cb') + let l:job_options.on_stderr = function('s:NeoVimCallback') + let l:job_info.err_cb_line = '' + endif + + if has_key(a:options, 'exit_cb') + let l:job_options.on_exit = function('s:NeoVimCallback') + endif + + let l:job_info.job = jobstart(a:command, l:job_options) + let l:job_id = l:job_info.job + else + let l:job_options = { + \ 'in_mode': l:job_info.mode, + \ 'out_mode': l:job_info.mode, + \ 'err_mode': l:job_info.mode, + \} + + if has_key(a:options, 'out_cb') + let l:job_options.out_cb = function('s:VimOutputCallback') + else + " prevent buffering of output and excessive polling in case close_cb is set + let l:job_options.out_cb = {->0} + endif + + if has_key(a:options, 'err_cb') + let l:job_options.err_cb = function('s:VimErrorCallback') + else + " prevent buffering of output and excessive polling in case close_cb is set + let l:job_options.err_cb = {->0} + endif + + if has_key(a:options, 'exit_cb') + " Set a close callback to which simply calls job_status() + " when the channel is closed, which can trigger the exit callback + " earlier on. + let l:job_options.close_cb = function('s:VimCloseCallback') + let l:job_options.exit_cb = function('s:VimExitCallback') + endif + + " Use non-blocking writes for Vim versions that support the option. + if has('patch-8.1.350') + let l:job_options.noblock = 1 + endif + + " Vim 8 will read the stdin from the file's buffer. + let l:job_info.job = job_start(a:command, l:job_options) + let l:job_id = ale#job#ParseVim8ProcessID(string(l:job_info.job)) + endif + + if l:job_id > 0 + " Store the job in the map for later only if we can get the ID. + let s:job_map[l:job_id] = l:job_info + endif + + return l:job_id +endfunction + +" Force running commands in a Windows CMD command line. +" This means the same command syntax works everywhere. +function! ale#job#StartWithCmd(command, options) abort + let l:shell = &l:shell + let l:shellcmdflag = &l:shellcmdflag + let &l:shell = 'cmd' + let &l:shellcmdflag = '/c' + + try + let l:job_id = ale#job#Start(a:command, a:options) + finally + let &l:shell = l:shell + let &l:shellcmdflag = l:shellcmdflag + endtry + + return l:job_id +endfunction + +" Send raw data to the job. +function! ale#job#SendRaw(job_id, string) abort + if has('nvim') + call jobsend(a:job_id, a:string) + else + let l:job = s:job_map[a:job_id].job + + if ch_status(l:job) is# 'open' + call ch_sendraw(job_getchannel(l:job), a:string) + endif + endif +endfunction + +" Given a job ID, return 1 if the job is currently running. +" Invalid job IDs will be ignored. +function! ale#job#IsRunning(job_id) abort + if has('nvim') + try + " In NeoVim, if the job isn't running, jobpid() will throw. + call jobpid(a:job_id) + + return 1 + catch + endtry + elseif has_key(s:job_map, a:job_id) + let l:job = s:job_map[a:job_id].job + + return job_status(l:job) is# 'run' + endif + + return 0 +endfunction + +function! ale#job#HasOpenChannel(job_id) abort + if ale#job#IsRunning(a:job_id) + if has('nvim') + " TODO: Implement a check for NeoVim. + return 1 + endif + + " Check if the Job's channel can be written to. + return ch_status(s:job_map[a:job_id].job) is# 'open' + endif + + return 0 +endfunction + +" Given a Job ID, stop that job. +" Invalid job IDs will be ignored. +function! ale#job#Stop(job_id) abort + if !has_key(s:job_map, a:job_id) + return + endif + + if has('nvim') + " FIXME: NeoVim kills jobs on a timer, but will not kill any processes + " which are child processes on Unix. Some work needs to be done to + " kill child processes to stop long-running processes like pylint. + silent! call jobstop(a:job_id) + else + let l:job = s:job_map[a:job_id].job + + " We must close the channel for reading the buffer if it is open + " when stopping a job. Otherwise, we will get errors in the status line. + if ch_status(job_getchannel(l:job)) is# 'open' + call ch_close_in(job_getchannel(l:job)) + endif + + " Ask nicely for the job to stop. + call job_stop(l:job) + + if ale#job#IsRunning(l:job) + " Set a 100ms delay for killing the job with SIGKILL. + let s:job_kill_timers[timer_start(100, function('s:KillHandler'))] = l:job + endif + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/julia.vim b/sources_non_forked/ale/autoload/ale/julia.vim new file mode 100644 index 00000000..18dd9ad7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/julia.vim @@ -0,0 +1,19 @@ +" Author: Bartolomeo Stellato bartolomeo.stellato@gmail.com +" Description: Functions for integrating with Julia tools + +" Find the nearest dir containing a julia project +let s:__ale_julia_project_filenames = ['REQUIRE', 'Manifest.toml', 'Project.toml'] + +function! ale#julia#FindProjectRoot(buffer) abort + for l:project_filename in s:__ale_julia_project_filenames + let l:full_path = ale#path#FindNearestFile(a:buffer, l:project_filename) + + if !empty(l:full_path) + let l:path = fnamemodify(l:full_path, ':p:h') + + return l:path + endif + endfor + + return '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/linter.vim b/sources_non_forked/ale/autoload/ale/linter.vim new file mode 100644 index 00000000..99faa357 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/linter.vim @@ -0,0 +1,462 @@ +" Author: w0rp +" Description: Linter registration and lazy-loading +" Retrieves linters as requested by the engine, loading them if needed. + +let s:runtime_loaded_map = {} +let s:linters = {} + +" Default filetype aliases. +" The user defined aliases will be merged with this Dictionary. +" +" NOTE: Update the g:ale_linter_aliases documentation when modifying this. +let s:default_ale_linter_aliases = { +\ 'Dockerfile': 'dockerfile', +\ 'csh': 'sh', +\ 'javascriptreact': ['javascript', 'jsx'], +\ 'plaintex': 'tex', +\ 'ps1': 'powershell', +\ 'rmarkdown': 'r', +\ 'rmd': 'r', +\ 'systemverilog': 'verilog', +\ 'typescriptreact': ['typescript', 'tsx'], +\ 'vader': ['vim', 'vader'], +\ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], +\ 'vimwiki': 'markdown', +\ 'vue': ['vue', 'javascript'], +\ 'xsd': ['xsd', 'xml'], +\ 'xslt': ['xslt', 'xml'], +\ 'zsh': 'sh', +\} + +" Default linters to run for particular filetypes. +" The user defined linter selections will be merged with this Dictionary. +" +" No linters are used for plaintext files by default. +" +" Only cargo and rls are enabled for Rust by default. +" rpmlint is disabled by default because it can result in code execution. +" hhast is disabled by default because it executes code in the project root. +" +" NOTE: Update the g:ale_linters documentation when modifying this. +let s:default_ale_linters = { +\ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], +\ 'csh': ['shell'], +\ 'elixir': ['credo', 'dialyxir', 'dogma'], +\ 'go': ['gofmt', 'golint', 'gopls', 'govet'], +\ 'hack': ['hack'], +\ 'help': [], +\ 'inko': ['inko'], +\ 'json': ['jsonlint', 'spectral', 'vscodejson'], +\ 'json5': [], +\ 'jsonc': [], +\ 'perl': ['perlcritic'], +\ 'perl6': [], +\ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], +\ 'rust': ['cargo', 'rls'], +\ 'spec': [], +\ 'text': [], +\ 'vader': ['vimls'], +\ 'vue': ['eslint', 'vls'], +\ 'zsh': ['shell'], +\ 'v': ['v'], +\ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'], +\} + +" Testing/debugging helper to unload all linters. +function! ale#linter#Reset() abort + let s:runtime_loaded_map = {} + let s:linters = {} +endfunction + +" Return a reference to the linters loaded. +" This is only for tests. +" Do not call this function. +function! ale#linter#GetLintersLoaded() abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + + return s:linters +endfunction + +function! s:IsCallback(value) abort + return type(a:value) is v:t_string || type(a:value) is v:t_func +endfunction + +function! s:IsBoolean(value) abort + return type(a:value) is v:t_number && (a:value == 0 || a:value == 1) +endfunction + +function! ale#linter#PreProcess(filetype, linter) abort + if type(a:linter) isnot v:t_dict + throw 'The linter object must be a Dictionary' + endif + + let l:obj = { + \ 'name': get(a:linter, 'name'), + \ 'lsp': get(a:linter, 'lsp', ''), + \} + + if type(l:obj.name) isnot v:t_string + throw '`name` must be defined to name the linter' + endif + + let l:needs_address = l:obj.lsp is# 'socket' + let l:needs_executable = l:obj.lsp isnot# 'socket' + let l:needs_command = l:obj.lsp isnot# 'socket' + let l:needs_lsp_details = !empty(l:obj.lsp) + + if empty(l:obj.lsp) + let l:obj.callback = get(a:linter, 'callback') + + if !s:IsCallback(l:obj.callback) + throw '`callback` must be defined with a callback to accept output' + endif + endif + + if index(['', 'socket', 'stdio', 'tsserver'], l:obj.lsp) < 0 + throw '`lsp` must be either `''lsp''`, `''stdio''`, `''socket''` or `''tsserver''` if defined' + endif + + if !l:needs_executable + if has_key(a:linter, 'executable') + throw '`executable` cannot be used when lsp == ''socket''' + endif + elseif has_key(a:linter, 'executable') + let l:obj.executable = a:linter.executable + + if type(l:obj.executable) isnot v:t_string + \&& type(l:obj.executable) isnot v:t_func + throw '`executable` must be a String or Function if defined' + endif + else + throw '`executable` must be defined' + endif + + if !l:needs_command + if has_key(a:linter, 'command') + throw '`command` cannot be used when lsp == ''socket''' + endif + elseif has_key(a:linter, 'command') + let l:obj.command = a:linter.command + + if type(l:obj.command) isnot v:t_string + \&& type(l:obj.command) isnot v:t_func + throw '`command` must be a String or Function if defined' + endif + else + throw '`command` must be defined' + endif + + if !l:needs_address + if has_key(a:linter, 'address') + throw '`address` cannot be used when lsp != ''socket''' + endif + elseif has_key(a:linter, 'address') + if type(a:linter.address) isnot v:t_string + \&& type(a:linter.address) isnot v:t_func + throw '`address` must be a String or Function if defined' + endif + + let l:obj.address = a:linter.address + + if has_key(a:linter, 'cwd') + throw '`cwd` makes no sense for socket LSP connections' + endif + else + throw '`address` must be defined for getting the LSP address' + endif + + if has_key(a:linter, 'cwd') + let l:obj.cwd = a:linter.cwd + + if type(l:obj.cwd) isnot v:t_string + \&& type(l:obj.cwd) isnot v:t_func + throw '`cwd` must be a String or Function if defined' + endif + endif + + if l:needs_lsp_details + " Default to using the filetype as the language. + let l:obj.language = get(a:linter, 'language', a:filetype) + + if type(l:obj.language) isnot v:t_string + \&& type(l:obj.language) isnot v:t_func + throw '`language` must be a String or Function if defined' + endif + + if has_key(a:linter, 'project_root') + let l:obj.project_root = a:linter.project_root + + if type(l:obj.project_root) isnot v:t_string + \&& type(l:obj.project_root) isnot v:t_func + throw '`project_root` must be a String or Function' + endif + else + throw '`project_root` must be defined for LSP linters' + endif + + if has_key(a:linter, 'completion_filter') + let l:obj.completion_filter = a:linter.completion_filter + + if !s:IsCallback(l:obj.completion_filter) + throw '`completion_filter` must be a callback' + endif + endif + + if has_key(a:linter, 'initialization_options') + let l:obj.initialization_options = a:linter.initialization_options + + if type(l:obj.initialization_options) isnot v:t_dict + \&& type(l:obj.initialization_options) isnot v:t_func + throw '`initialization_options` must be a Dictionary or Function if defined' + endif + endif + + if has_key(a:linter, 'lsp_config') + if type(a:linter.lsp_config) isnot v:t_dict + \&& type(a:linter.lsp_config) isnot v:t_func + throw '`lsp_config` must be a Dictionary or Function if defined' + endif + + let l:obj.lsp_config = a:linter.lsp_config + endif + endif + + let l:obj.output_stream = get(a:linter, 'output_stream', 'stdout') + + if type(l:obj.output_stream) isnot v:t_string + \|| index(['stdout', 'stderr', 'both'], l:obj.output_stream) < 0 + throw "`output_stream` must be 'stdout', 'stderr', or 'both'" + endif + + " An option indicating that this linter should only be run against the + " file on disk. + let l:obj.lint_file = get(a:linter, 'lint_file', 0) + + if !s:IsBoolean(l:obj.lint_file) && type(l:obj.lint_file) isnot v:t_func + throw '`lint_file` must be `0`, `1`, or a Function' + endif + + " An option indicating that the buffer should be read. + let l:obj.read_buffer = get(a:linter, 'read_buffer', 1) + + if !s:IsBoolean(l:obj.read_buffer) + throw '`read_buffer` must be `0` or `1`' + endif + + let l:obj.aliases = get(a:linter, 'aliases', []) + + if type(l:obj.aliases) isnot v:t_list + \|| len(filter(copy(l:obj.aliases), 'type(v:val) isnot v:t_string')) > 0 + throw '`aliases` must be a List of String values' + endif + + return l:obj +endfunction + +function! ale#linter#Define(filetype, linter) abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + + let l:new_linter = ale#linter#PreProcess(a:filetype, a:linter) + + if !has_key(s:linters, a:filetype) + let s:linters[a:filetype] = [] + endif + + " Remove previously defined linters with the same name. + call filter(s:linters[a:filetype], 'v:val.name isnot# a:linter.name') + call add(s:linters[a:filetype], l:new_linter) +endfunction + +" Prevent any linters from being loaded for a given filetype. +function! ale#linter#PreventLoading(filetype) abort + let s:runtime_loaded_map[a:filetype] = 1 +endfunction + +function! ale#linter#GetAll(filetypes) abort + " Don't return linters in the sandbox. + " Otherwise a sandboxed script could modify them. + if ale#util#InSandbox() + return [] + endif + + let l:combined_linters = [] + + for l:filetype in a:filetypes + " Load linters from runtimepath if we haven't done that yet. + if !has_key(s:runtime_loaded_map, l:filetype) + execute 'silent! runtime! ale_linters/' . l:filetype . '/*.vim' + + let s:runtime_loaded_map[l:filetype] = 1 + endif + + call extend(l:combined_linters, get(s:linters, l:filetype, [])) + endfor + + return l:combined_linters +endfunction + +function! s:GetAliasedFiletype(original_filetype) abort + let l:buffer_aliases = get(b:, 'ale_linter_aliases', {}) + + " b:ale_linter_aliases can be set to a List or String. + if type(l:buffer_aliases) is v:t_list + \|| type(l:buffer_aliases) is v:t_string + return l:buffer_aliases + endif + + " Check for aliased filetypes first in a buffer variable, + " then the global variable, + " then in the default mapping, + " otherwise use the original filetype. + for l:dict in [ + \ l:buffer_aliases, + \ g:ale_linter_aliases, + \ s:default_ale_linter_aliases, + \] + if has_key(l:dict, a:original_filetype) + return l:dict[a:original_filetype] + endif + endfor + + return a:original_filetype +endfunction + +function! ale#linter#ResolveFiletype(original_filetype) abort + let l:filetype = s:GetAliasedFiletype(a:original_filetype) + + if type(l:filetype) isnot v:t_list + return [l:filetype] + endif + + return l:filetype +endfunction + +function! s:GetLinterNames(original_filetype) abort + let l:buffer_ale_linters = get(b:, 'ale_linters', {}) + + " b:ale_linters can be set to 'all' + if l:buffer_ale_linters is# 'all' + return 'all' + endif + + " b:ale_linters can be set to a List. + if type(l:buffer_ale_linters) is v:t_list + return l:buffer_ale_linters + endif + + " Try to get a buffer-local setting for the filetype + if has_key(l:buffer_ale_linters, a:original_filetype) + return l:buffer_ale_linters[a:original_filetype] + endif + + " Try to get a global setting for the filetype + if has_key(g:ale_linters, a:original_filetype) + return g:ale_linters[a:original_filetype] + endif + + " If the user has configured ALE to only enable linters explicitly, then + " don't enable any linters by default. + if g:ale_linters_explicit + return [] + endif + + " Try to get a default setting for the filetype + if has_key(s:default_ale_linters, a:original_filetype) + return s:default_ale_linters[a:original_filetype] + endif + + return 'all' +endfunction + +function! ale#linter#Get(original_filetypes) abort + let l:possibly_duplicated_linters = [] + + " Handle dot-separated filetypes. + for l:original_filetype in split(a:original_filetypes, '\.') + let l:filetype = ale#linter#ResolveFiletype(l:original_filetype) + let l:linter_names = s:GetLinterNames(l:original_filetype) + let l:all_linters = ale#linter#GetAll(l:filetype) + let l:filetype_linters = [] + + if type(l:linter_names) is v:t_string && l:linter_names is# 'all' + let l:filetype_linters = l:all_linters + elseif type(l:linter_names) is v:t_list + " Select only the linters we or the user has specified. + for l:linter in l:all_linters + let l:name_list = [l:linter.name] + l:linter.aliases + + for l:name in l:name_list + if index(l:linter_names, l:name) >= 0 + call add(l:filetype_linters, l:linter) + break + endif + endfor + endfor + endif + + call extend(l:possibly_duplicated_linters, l:filetype_linters) + endfor + + let l:name_list = [] + let l:combined_linters = [] + + " Make sure we override linters so we don't get two with the same name, + " like 'eslint' for both 'javascript' and 'typescript' + " + " Note that the reverse calls here modify the List variables. + for l:linter in reverse(l:possibly_duplicated_linters) + if index(l:name_list, l:linter.name) < 0 + call add(l:name_list, l:linter.name) + call add(l:combined_linters, l:linter) + endif + endfor + + return reverse(l:combined_linters) +endfunction + +function! ale#linter#RemoveIgnored(buffer, filetype, linters) abort + " Apply ignore lists for linters only if needed. + let l:ignore_config = ale#Var(a:buffer, 'linters_ignore') + let l:disable_lsp = ale#Var(a:buffer, 'disable_lsp') + + return !empty(l:ignore_config) || l:disable_lsp + \ ? ale#engine#ignore#Exclude(a:filetype, a:linters, l:ignore_config, l:disable_lsp) + \ : a:linters +endfunction + +" Given a buffer and linter, get the executable String for the linter. +function! ale#linter#GetExecutable(buffer, linter) abort + let l:Executable = a:linter.executable + + return type(l:Executable) is v:t_func + \ ? l:Executable(a:buffer) + \ : l:Executable +endfunction + +function! ale#linter#GetCwd(buffer, linter) abort + let l:Cwd = get(a:linter, 'cwd', v:null) + + return type(l:Cwd) is v:t_func ? l:Cwd(a:buffer) : l:Cwd +endfunction + +" Given a buffer and linter, get the command String for the linter. +function! ale#linter#GetCommand(buffer, linter) abort + let l:Command = a:linter.command + + return type(l:Command) is v:t_func ? l:Command(a:buffer) : l:Command +endfunction + +" Given a buffer and linter, get the address for connecting to the server. +function! ale#linter#GetAddress(buffer, linter) abort + let l:Address = a:linter.address + + return type(l:Address) is v:t_func ? l:Address(a:buffer) : l:Address +endfunction + +function! ale#linter#GetLanguage(buffer, linter) abort + let l:Language = a:linter.language + + return type(l:Language) is v:t_func ? l:Language(a:buffer) : l:Language +endfunction diff --git a/sources_non_forked/ale/autoload/ale/list.vim b/sources_non_forked/ale/autoload/ale/list.vim new file mode 100644 index 00000000..8ce8597e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/list.vim @@ -0,0 +1,274 @@ +" Author: Bjorn Neergaard , modified by Yann fery +" Description: Manages the loclist and quickfix lists + +" This flag dictates if ale open the configured loclist +let g:ale_open_list = get(g:, 'ale_open_list', 0) +" This flag dictates if ale keeps open loclist even if there is no error in loclist +let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0) +" This flag dictates that quickfix windows should be opened vertically +let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0) +" The window size to set for the quickfix and loclist windows +let g:ale_list_window_size = get(g:, 'ale_list_window_size', 10) +" A string format for the loclist messages. +let g:ale_loclist_msg_format = get(g:, 'ale_loclist_msg_format', +\ get(g:, 'ale_echo_msg_format', '%code: %%s') +\) + +if !exists('s:timer_args') + let s:timer_args = {} +endif + +" Return 1 if there is a buffer with buftype == 'quickfix' in buffer list +function! ale#list#IsQuickfixOpen() abort + let l:res = getqflist({ 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif + + let l:res = getloclist(0, { 'winid' : winnr() }) + + if has_key(l:res, 'winid') && l:res.winid > 0 + return 1 + endif + + return 0 +endfunction + +" Check if we should open the list, based on the save event being fired, and +" that setting being on, or that the error count is at least as high as the +" setting when set to an integer value. +function! s:ShouldOpen(buffer, loclist_len) abort + let l:val = ale#Var(a:buffer, 'open_list') + let l:saved = getbufvar(a:buffer, 'ale_save_event_fired', 0) + + return l:val > 0 ? a:loclist_len >= l:val : l:val is# 'on_save' && l:saved +endfunction + +" Check if we should close the list, based on the save event being fired, and +" that setting being on, or the setting just being set to an integer value. +function! s:ShouldClose(buffer) abort + let l:val = ale#Var(a:buffer, 'open_list') + let l:saved = getbufvar(a:buffer, 'ale_save_event_fired', 0) + + return !((l:val >= 1) || (l:val is# 'on_save' && l:saved)) +endfunction + +function! s:Deduplicate(list) abort + let l:list = a:list + + call sort(l:list, function('ale#util#LocItemCompareWithText')) + call uniq(l:list, function('ale#util#LocItemCompareWithText')) + + return l:list +endfunction + +function! ale#list#GetCombinedList() abort + let l:list = [] + + for l:info in values(g:ale_buffer_info) + call extend(l:list, l:info.loclist) + endfor + + return s:Deduplicate(l:list) +endfunction + +function! s:FixList(buffer, list) abort + let l:format = ale#Var(a:buffer, 'loclist_msg_format') + let l:new_list = [] + + for l:item in a:list + let l:fixed_item = copy(l:item) + + let l:fixed_item.text = ale#GetLocItemMessage(l:item, l:format) + + if l:item.bufnr == -1 + " If the buffer number is invalid, remove it. + call remove(l:fixed_item, 'bufnr') + endif + + call add(l:new_list, l:fixed_item) + endfor + + return l:new_list +endfunction + +function! s:WinFindBuf(buffer) abort + return exists('*win_findbuf') ? win_findbuf(str2nr(a:buffer)) : [0] +endfunction + +function! s:SetListsImpl(timer_id, buffer, loclist) abort + let l:title = expand('#' . a:buffer . ':p') + + if g:ale_set_quickfix + let l:quickfix_list = ale#list#GetCombinedList() + + if has('nvim') + call setqflist(s:FixList(a:buffer, l:quickfix_list), ' ', l:title) + else + call setqflist(s:FixList(a:buffer, l:quickfix_list)) + call setqflist([], 'r', {'title': l:title}) + endif + elseif g:ale_set_loclist + " If windows support is off, win_findbuf() may not exist. + " We'll set result in the current window, which might not be correct, + " but it's better than nothing. + let l:ids = s:WinFindBuf(a:buffer) + + let l:loclist = s:Deduplicate(a:loclist) + + for l:id in l:ids + if has('nvim') + call setloclist(l:id, s:FixList(a:buffer, l:loclist), ' ', l:title) + else + call setloclist(l:id, s:FixList(a:buffer, l:loclist)) + call setloclist(l:id, [], 'r', {'title': l:title}) + endif + endfor + endif + + " Save the current view before opening/closing any window + call setbufvar(a:buffer, 'ale_winview', winsaveview()) + + " Open a window to show the problems if we need to. + " + " ShouldOpen() checks if the current buffer has enough problems to be + " opened. + if s:ShouldOpen(a:buffer, len(a:loclist)) + let l:winnr = winnr() + let l:mode = mode() + + " open windows vertically instead of default horizontally + let l:open_type = '' + + if ale#Var(a:buffer, 'list_vertical') == 1 + let l:open_type = 'vert rightbelow ' + endif + + if g:ale_set_quickfix + if !ale#list#IsQuickfixOpen() + silent! execute l:open_type . 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) + endif + elseif g:ale_set_loclist + silent! execute l:open_type . 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size')) + endif + + " If focus changed, restore it (jump to the last window). + if l:winnr isnot# winnr() + wincmd p + endif + + " Return to original mode when applicable + if mode() != l:mode + if l:mode is? 'v' || l:mode is# "\" + " Reset our last visual selection + normal! gv + elseif l:mode is? 's' || l:mode is# "\" + " Reset our last character selection + normal! "\" + endif + endif + + call s:RestoreViewIfNeeded(a:buffer) + endif + + " If ALE isn't currently checking for more problems, close the window if + " needed now. This check happens inside of this timer function, so + " the window can be closed reliably. + if !ale#engine#IsCheckingBuffer(a:buffer) + call s:CloseWindowIfNeeded(a:buffer) + endif +endfunction + +" Try to restore the window view after closing any of the lists to avoid making +" the it moving around, especially useful when on insert mode +function! s:RestoreViewIfNeeded(buffer) abort + let l:saved_view = getbufvar(a:buffer, 'ale_winview', {}) + + " Saved view is empty, can't do anything + if empty(l:saved_view) + return + endif + + " Check whether the cursor has moved since linting was actually requested. If + " the user has indeed moved lines, do nothing + let l:current_view = winsaveview() + + if l:current_view['lnum'] != l:saved_view['lnum'] + return + endif + + " Anchor view by topline if the list is set to open horizontally + if ale#Var(a:buffer, 'list_vertical') == 0 + call winrestview({'topline': l:saved_view['topline']}) + endif +endfunction + +function! ale#list#SetLists(buffer, loclist) abort + if get(g:, 'ale_set_lists_synchronously') == 1 + \|| getbufvar(a:buffer, 'ale_save_event_fired', 0) + " Update lists immediately if running a test synchronously, or if the + " buffer was saved. + " + " The lists need to be updated immediately when saving a buffer so + " that we can reliably close window automatically, if so configured. + call s:SetListsImpl(-1, a:buffer, a:loclist) + else + call ale#util#StartPartialTimer( + \ 0, + \ function('s:SetListsImpl'), + \ [a:buffer, a:loclist], + \) + endif +endfunction + +function! ale#list#ForcePopulateErrorList(populate_quickfix) abort + let l:quickfix_bak = g:ale_set_quickfix + let g:ale_set_quickfix = a:populate_quickfix + let l:loclist_bak = g:ale_set_loclist + let g:ale_set_loclist = !a:populate_quickfix + let l:open_list_bak = g:ale_open_list + let g:ale_open_list = 1 + + let l:buffer = bufnr('') + let l:loclist = get(g:ale_buffer_info, l:buffer, {'loclist': []}).loclist + call s:SetListsImpl(-1, l:buffer, l:loclist) + + let g:ale_open_list = l:open_list_bak + let g:ale_set_loclist = l:loclist_bak + let g:ale_set_quickfix = l:quickfix_bak +endfunction + +function! s:CloseWindowIfNeeded(buffer) abort + if ale#Var(a:buffer, 'keep_list_window_open') || s:ShouldClose(a:buffer) + return + endif + + let l:did_close_any_list = 0 + + try + " Only close windows if the quickfix list or loclist is completely empty, + " including errors set through other means. + if g:ale_set_quickfix + if empty(getqflist()) + cclose + let l:did_close_any_list = 1 + endif + else + let l:win_ids = s:WinFindBuf(a:buffer) + + for l:win_id in l:win_ids + if g:ale_set_loclist && empty(getloclist(l:win_id)) + lclose + let l:did_close_any_list = 1 + endif + endfor + endif + " Ignore 'Cannot close last window' errors. + catch /E444/ + endtry + + if l:did_close_any_list + call s:RestoreViewIfNeeded(a:buffer) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/loclist_jumping.vim b/sources_non_forked/ale/autoload/ale/loclist_jumping.vim new file mode 100644 index 00000000..55097d12 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/loclist_jumping.vim @@ -0,0 +1,163 @@ +" Author: w0rp +" Description: This file implements functions for jumping around in a file +" based on ALE's internal loclist. + +" Search for the nearest line either before or after the current position +" in the loclist. The argument 'wrap' can be passed to enable wrapping +" around the end of the list. +" +" If there are no items or we have hit the end with wrapping off, an empty +" List will be returned, otherwise a pair of [line_number, column_number] will +" be returned. +function! ale#loclist_jumping#FindNearest(direction, wrap, ...) abort + let l:buffer = bufnr('') + let l:pos = getpos('.') + let l:info = get(g:ale_buffer_info, bufnr('%'), {'loclist': []}) + " Copy the list and filter to only the items in this buffer. + let l:loclist = filter(copy(l:info.loclist), 'v:val.bufnr == l:buffer') + let l:search_item = {'bufnr': l:buffer, 'lnum': l:pos[1], 'col': l:pos[2]} + + if a:0 > 0 + let l:filter = a:1 + else + let l:filter = 'any' + endif + + if a:0 > 1 + let l:subtype_filter = a:2 + else + let l:subtype_filter = 'any' + endif + + " When searching backwards, so we can find the next smallest match. + if a:direction is# 'before' + call reverse(l:loclist) + endif + + " Look for items before or after the current position. + for l:item in l:loclist + " Compare the cursor with a item where the column number is bounded, + " such that it's possible for the cursor to actually be on the given + " column number, without modifying the cursor number we return. This + " will allow us to move through matches, but still let us move the + " cursor to a line without changing the column, in some cases. + let l:cmp_value = ale#util#LocItemCompare( + \ { + \ 'bufnr': l:buffer, + \ 'lnum': l:item.lnum, + \ 'col': min([ + \ max([l:item.col, 1]), + \ max([len(getline(l:item.lnum)), 1]), + \ ]), + \ }, + \ l:search_item + \) + + if (l:filter is# 'any' || l:filter is# l:item.type) + \&& ( + \ l:subtype_filter is# 'any' + \ || l:subtype_filter is# get(l:item, 'sub_type', '') + \) + + if a:direction is# 'before' && l:cmp_value < 0 + return [l:item.lnum, l:item.col] + endif + + if a:direction is# 'after' && l:cmp_value > 0 + return [l:item.lnum, l:item.col] + endif + endif + endfor + + " If we found nothing, and the wrap option is set to 1, then we should + " wrap around the list of warnings/errors + if a:wrap + for l:item in l:loclist + if (l:filter is# 'any' || l:filter is# l:item.type) + \&& ( + \ l:subtype_filter is# 'any' + \ || l:subtype_filter is# get(l:item, 'sub_type', '') + \) + return [l:item.lnum, l:item.col] + endif + endfor + endif + + return [] +endfunction + +" As before, find the nearest match, but position the cursor at it. +function! ale#loclist_jumping#Jump(direction, ...) abort + if a:0 > 0 + let l:wrap = a:1 + else + let l:wrap = 0 + endif + + if a:0 > 1 + let l:filter = a:2 + else + let l:filter = 'any' + endif + + if a:0 > 2 + let l:subtype_filter = a:3 + else + let l:subtype_filter = 'any' + endif + + let l:nearest = ale#loclist_jumping#FindNearest(a:direction, + \ l:wrap, l:filter, l:subtype_filter) + + if !empty(l:nearest) + normal! m` + call cursor([l:nearest[0], max([l:nearest[1], 1])]) + endif +endfunction + +function! ale#loclist_jumping#WrapJump(direction, sargs) abort + let [l:args, l:rest] = ale#args#Parse(['error', 'warning', 'info', 'wrap', + \ 'style', 'nostyle'], a:sargs) + + let l:wrap = 0 + let l:type_filter = 'any' + let l:subtype_filter = 'any' + + if get(l:args, 'wrap', 'nil') is# '' + let l:wrap = 1 + endif + + if get(l:args, 'error', 'nil') is# '' + let l:type_filter = 'E' + elseif get(l:args, 'warning', 'nil') is# '' + let l:type_filter = 'W' + elseif get(l:args, 'info', 'nil') is# '' + let l:type_filter = 'I' + endif + + if get(l:args, 'nostyle', 'nil') is# '' + let l:subtype_filter = 'style' + elseif get(l:args, 'style', 'nil') is# '' + let l:subtype_filter = '' + endif + + call ale#loclist_jumping#Jump(a:direction, l:wrap, l:type_filter, + \ l:subtype_filter) +endfunction + +function! ale#loclist_jumping#JumpToIndex(index) abort + let l:buffer = bufnr('') + let l:info = get(g:ale_buffer_info, l:buffer, {'loclist': []}) + let l:loclist = filter(copy(l:info.loclist), 'v:val.bufnr == l:buffer') + + if empty(l:loclist) + return + endif + + let l:item = l:loclist[a:index] + + if !empty(l:item) + normal! m` + call cursor([l:item.lnum, l:item.col]) + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp.vim b/sources_non_forked/ale/autoload/ale/lsp.vim new file mode 100644 index 00000000..daaed6fa --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp.vim @@ -0,0 +1,718 @@ +" Author: w0rp +" Description: Language Server Protocol client code + +" A Dictionary for tracking connections. +let s:connections = get(s:, 'connections', {}) +let g:ale_lsp_next_message_id = 1 + +" Given an id, which can be an executable or address, and a project path, +" create a new connection if needed. Return a unique ID for the connection. +function! ale#lsp#Register(executable_or_address, project, init_options) abort + let l:conn_id = a:executable_or_address . ':' . a:project + + if !has_key(s:connections, l:conn_id) + " is_tsserver: 1 if the connection is for tsserver. + " data: The message data received so far. + " root: The project root. + " open_documents: A Dictionary mapping buffers to b:changedtick, keeping + " track of when documents were opened, and when we last changed them. + " initialized: 0 if the connection is ready, 1 otherwise. + " init_request_id: The ID for the init request. + " init_options: Options to send to the server. + " config: Configuration settings to send to the server. + " callback_list: A list of callbacks for handling LSP responses. + " capabilities_queue: The list of callbacks to call with capabilities. + " capabilities: Features the server supports. + let s:connections[l:conn_id] = { + \ 'id': l:conn_id, + \ 'is_tsserver': 0, + \ 'data': '', + \ 'root': a:project, + \ 'open_documents': {}, + \ 'initialized': 0, + \ 'init_request_id': 0, + \ 'init_options': a:init_options, + \ 'config': {}, + \ 'callback_list': [], + \ 'init_queue': [], + \ 'capabilities': { + \ 'hover': 0, + \ 'rename': 0, + \ 'filerename': 0, + \ 'references': 0, + \ 'completion': 0, + \ 'completion_trigger_characters': [], + \ 'definition': 0, + \ 'typeDefinition': 0, + \ 'implementation': 0, + \ 'symbol_search': 0, + \ 'code_actions': 0, + \ 'did_save': 0, + \ 'includeText': 0, + \ }, + \} + endif + + return l:conn_id +endfunction + +" Remove an LSP connection with a given ID. This is only for tests. +function! ale#lsp#RemoveConnectionWithID(id) abort + if has_key(s:connections, a:id) + call remove(s:connections, a:id) + endif +endfunction + +function! ale#lsp#ResetConnections() abort + let s:connections = {} +endfunction + +" Used only in tests. +function! ale#lsp#GetConnections() abort + " This command will throw from the sandbox. + let &l:equalprg=&l:equalprg + + return s:connections +endfunction + +" This is only needed for tests +function! ale#lsp#MarkDocumentAsOpen(id, buffer) abort + let l:conn = get(s:connections, a:id, {}) + + if !empty(l:conn) + let l:conn.open_documents[a:buffer] = -1 + endif +endfunction + +function! ale#lsp#GetNextMessageID() abort + " Use the current ID + let l:id = g:ale_lsp_next_message_id + + " Increment the ID variable. + let g:ale_lsp_next_message_id += 1 + + " When the ID overflows, reset it to 1. By the time we hit the initial ID + " again, the messages will be long gone. + if g:ale_lsp_next_message_id < 1 + let g:ale_lsp_next_message_id = 1 + endif + + return l:id +endfunction + +" TypeScript messages use a different format. +function! s:CreateTSServerMessageData(message) abort + let l:is_notification = a:message[0] + + let l:obj = { + \ 'seq': v:null, + \ 'type': 'request', + \ 'command': a:message[1][3:], + \} + + if !l:is_notification + let l:obj.seq = ale#lsp#GetNextMessageID() + endif + + if len(a:message) > 2 + let l:obj.arguments = a:message[2] + endif + + let l:data = json_encode(l:obj) . "\n" + + return [l:is_notification ? 0 : l:obj.seq, l:data] +endfunction + +" Given a List of one or two items, [method_name] or [method_name, params], +" return a List containing [message_id, message_data] +function! ale#lsp#CreateMessageData(message) abort + if a:message[1][:2] is# 'ts@' + return s:CreateTSServerMessageData(a:message) + endif + + let l:is_notification = a:message[0] + + let l:obj = { + \ 'method': a:message[1], + \ 'jsonrpc': '2.0', + \} + + if !l:is_notification + let l:obj.id = ale#lsp#GetNextMessageID() + endif + + if len(a:message) > 2 + let l:obj.params = a:message[2] + endif + + let l:body = json_encode(l:obj) + let l:data = 'Content-Length: ' . strlen(l:body) . "\r\n\r\n" . l:body + + return [l:is_notification ? 0 : l:obj.id, l:data] +endfunction + +function! ale#lsp#ReadMessageData(data) abort + let l:response_list = [] + let l:remainder = a:data + + while 1 + " Look for the end of the HTTP headers + let l:body_start_index = matchend(l:remainder, "\r\n\r\n") + + if l:body_start_index < 0 + " No header end was found yet. + break + endif + + " Parse the Content-Length header. + let l:header_data = l:remainder[:l:body_start_index - 4] + let l:length_match = matchlist( + \ l:header_data, + \ '\vContent-Length: *(\d+)' + \) + + if empty(l:length_match) + throw "Invalid JSON-RPC header:\n" . l:header_data + endif + + " Split the body and the remainder of the text. + let l:remainder_start_index = l:body_start_index + str2nr(l:length_match[1]) + + if len(l:remainder) < l:remainder_start_index + " We don't have enough data yet. + break + endif + + let l:body = l:remainder[l:body_start_index : l:remainder_start_index - 1] + let l:remainder = l:remainder[l:remainder_start_index :] + + " Parse the JSON object and add it to the list. + call add(l:response_list, json_decode(l:body)) + endwhile + + return [l:remainder, l:response_list] +endfunction + +" Update capabilities from the server, so we know which features the server +" supports. +function! s:UpdateCapabilities(conn, capabilities) abort + if type(a:capabilities) isnot v:t_dict + return + endif + + if get(a:capabilities, 'hoverProvider') is v:true + let a:conn.capabilities.hover = 1 + endif + + if type(get(a:capabilities, 'hoverProvider')) is v:t_dict + let a:conn.capabilities.hover = 1 + endif + + if get(a:capabilities, 'referencesProvider') is v:true + let a:conn.capabilities.references = 1 + endif + + if type(get(a:capabilities, 'referencesProvider')) is v:t_dict + let a:conn.capabilities.references = 1 + endif + + if get(a:capabilities, 'renameProvider') is v:true + let a:conn.capabilities.rename = 1 + endif + + if type(get(a:capabilities, 'renameProvider')) is v:t_dict + let a:conn.capabilities.rename = 1 + endif + + if get(a:capabilities, 'codeActionProvider') is v:true + let a:conn.capabilities.code_actions = 1 + endif + + if type(get(a:capabilities, 'codeActionProvider')) is v:t_dict + let a:conn.capabilities.code_actions = 1 + endif + + if !empty(get(a:capabilities, 'completionProvider')) + let a:conn.capabilities.completion = 1 + endif + + if type(get(a:capabilities, 'completionProvider')) is v:t_dict + let l:chars = get(a:capabilities.completionProvider, 'triggerCharacters') + + if type(l:chars) is v:t_list + let a:conn.capabilities.completion_trigger_characters = l:chars + endif + endif + + if get(a:capabilities, 'definitionProvider') is v:true + let a:conn.capabilities.definition = 1 + endif + + if type(get(a:capabilities, 'definitionProvider')) is v:t_dict + let a:conn.capabilities.definition = 1 + endif + + if get(a:capabilities, 'typeDefinitionProvider') is v:true + let a:conn.capabilities.typeDefinition = 1 + endif + + if type(get(a:capabilities, 'typeDefinitionProvider')) is v:t_dict + let a:conn.capabilities.typeDefinition = 1 + endif + + if get(a:capabilities, 'implementationProvider') is v:true + let a:conn.capabilities.implementation = 1 + endif + + if type(get(a:capabilities, 'implementationProvider')) is v:t_dict + let a:conn.capabilities.implementation = 1 + endif + + if get(a:capabilities, 'workspaceSymbolProvider') is v:true + let a:conn.capabilities.symbol_search = 1 + endif + + if type(get(a:capabilities, 'workspaceSymbolProvider')) is v:t_dict + let a:conn.capabilities.symbol_search = 1 + endif + + if type(get(a:capabilities, 'textDocumentSync')) is v:t_dict + let l:syncOptions = get(a:capabilities, 'textDocumentSync') + + if get(l:syncOptions, 'save') is v:true + let a:conn.capabilities.did_save = 1 + endif + + if type(get(l:syncOptions, 'save')) is v:t_dict + let a:conn.capabilities.did_save = 1 + + let l:saveOptions = get(l:syncOptions, 'save') + + if get(l:saveOptions, 'includeText') is v:true + let a:conn.capabilities.includeText = 1 + endif + endif + endif +endfunction + +" Update a connection's configuration dictionary and notify LSP servers +" of any changes since the last update. Returns 1 if a configuration +" update was sent; otherwise 0 will be returned. +function! ale#lsp#UpdateConfig(conn_id, buffer, config) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) || a:config ==# l:conn.config " no-custom-checks + return 0 + endif + + let l:conn.config = a:config + let l:message = ale#lsp#message#DidChangeConfiguration(a:buffer, a:config) + + call ale#lsp#Send(a:conn_id, l:message) + + return 1 +endfunction + + +function! ale#lsp#HandleInitResponse(conn, response) abort + if get(a:response, 'method', '') is# 'initialize' + let a:conn.initialized = 1 + elseif type(get(a:response, 'result')) is v:t_dict + \&& has_key(a:response.result, 'capabilities') + call s:UpdateCapabilities(a:conn, a:response.result.capabilities) + + let a:conn.initialized = 1 + endif + + if !a:conn.initialized + return + endif + + " The initialized message must be sent before everything else. + call ale#lsp#Send(a:conn.id, ale#lsp#message#Initialized()) + + " Call capabilities callbacks queued for the project. + for l:Callback in a:conn.init_queue + call l:Callback() + endfor + + let a:conn.init_queue = [] +endfunction + +function! ale#lsp#HandleMessage(conn_id, message) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return + endif + + if type(a:message) isnot v:t_string + " Ignore messages that aren't strings. + return + endif + + let l:conn.data .= a:message + + " Parse the objects now if we can, and keep the remaining text. + let [l:conn.data, l:response_list] = ale#lsp#ReadMessageData(l:conn.data) + + " Look for initialize responses first. + if !l:conn.initialized + for l:response in l:response_list + call ale#lsp#HandleInitResponse(l:conn, l:response) + endfor + endif + + " If the connection is marked as initialized, call the callbacks with the + " responses. + if l:conn.initialized + for l:response in l:response_list + " Call all of the registered handlers with the response. + for l:Callback in l:conn.callback_list + call ale#util#GetFunction(l:Callback)(a:conn_id, l:response) + endfor + endfor + endif +endfunction + +" Given a connection ID, mark it as a tsserver connection, so it will be +" handled that way. +function! ale#lsp#MarkConnectionAsTsserver(conn_id) abort + let l:conn = s:connections[a:conn_id] + let l:conn.is_tsserver = 1 + let l:conn.initialized = 1 + " Set capabilities which are supported by tsserver. + let l:conn.capabilities.hover = 1 + let l:conn.capabilities.references = 1 + let l:conn.capabilities.completion = 1 + let l:conn.capabilities.completion_trigger_characters = ['.'] + let l:conn.capabilities.definition = 1 + let l:conn.capabilities.typeDefinition = 1 + let l:conn.capabilities.implementation = 1 + let l:conn.capabilities.symbol_search = 1 + let l:conn.capabilities.rename = 1 + let l:conn.capabilities.filerename = 1 + let l:conn.capabilities.code_actions = 1 +endfunction + +function! s:SendInitMessage(conn) abort + let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( + \ ale#lsp#message#Initialize( + \ a:conn.root, + \ a:conn.init_options, + \ { + \ 'workspace': { + \ 'applyEdit': v:false, + \ 'didChangeConfiguration': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'symbol': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'workspaceFolders': v:false, + \ 'configuration': v:false, + \ }, + \ 'textDocument': { + \ 'synchronization': { + \ 'dynamicRegistration': v:false, + \ 'willSave': v:false, + \ 'willSaveWaitUntil': v:false, + \ 'didSave': v:true, + \ }, + \ 'completion': { + \ 'dynamicRegistration': v:false, + \ 'completionItem': { + \ 'snippetSupport': v:false, + \ 'commitCharactersSupport': v:false, + \ 'documentationFormat': ['plaintext'], + \ 'deprecatedSupport': v:false, + \ 'preselectSupport': v:false, + \ }, + \ 'contextSupport': v:false, + \ }, + \ 'hover': { + \ 'dynamicRegistration': v:false, + \ 'contentFormat': ['plaintext'], + \ }, + \ 'references': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'documentSymbol': { + \ 'dynamicRegistration': v:false, + \ 'hierarchicalDocumentSymbolSupport': v:false, + \ }, + \ 'definition': { + \ 'dynamicRegistration': v:false, + \ 'linkSupport': v:false, + \ }, + \ 'typeDefinition': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'implementation': { + \ 'dynamicRegistration': v:false, + \ 'linkSupport': v:false, + \ }, + \ 'publishDiagnostics': { + \ 'relatedInformation': v:true, + \ }, + \ 'codeAction': { + \ 'dynamicRegistration': v:false, + \ 'codeActionLiteralSupport': { + \ 'codeActionKind': { + \ 'valueSet': [] + \ } + \ } + \ }, + \ 'rename': { + \ 'dynamicRegistration': v:false, + \ }, + \ }, + \ }, + \ ), + \) + let a:conn.init_request_id = l:init_id + call s:SendMessageData(a:conn, l:init_data) +endfunction + +" Start a program for LSP servers. +" +" 1 will be returned if the program is running, or 0 if the program could +" not be started. +function! ale#lsp#StartProgram(conn_id, executable, command) abort + let l:conn = s:connections[a:conn_id] + let l:started = 0 + + if !has_key(l:conn, 'job_id') || !ale#job#HasOpenChannel(l:conn.job_id) + let l:options = { + \ 'mode': 'raw', + \ 'out_cb': {_, message -> ale#lsp#HandleMessage(a:conn_id, message)}, + \ 'exit_cb': { -> ale#lsp#Stop(a:conn_id) }, + \} + + if has('win32') + let l:job_id = ale#job#StartWithCmd(a:command, l:options) + else + let l:job_id = ale#job#Start(a:command, l:options) + endif + + let l:started = 1 + else + let l:job_id = l:conn.job_id + endif + + if l:job_id > 0 + let l:conn.job_id = l:job_id + endif + + if l:started && !l:conn.is_tsserver + let l:conn.initialized = 0 + call s:SendInitMessage(l:conn) + endif + + return l:job_id > 0 +endfunction + +" Connect to an LSP server via TCP. +" +" 1 will be returned if the connection is running, or 0 if the connection could +" not be opened. +function! ale#lsp#ConnectToAddress(conn_id, address) abort + let l:conn = s:connections[a:conn_id] + let l:started = 0 + + if !has_key(l:conn, 'channel_id') || !ale#socket#IsOpen(l:conn.channel_id) + let l:channel_id = ale#socket#Open(a:address, { + \ 'callback': {_, mess -> ale#lsp#HandleMessage(a:conn_id, mess)}, + \}) + + let l:started = 1 + else + let l:channel_id = l:conn.channel_id + endif + + if l:channel_id >= 0 + let l:conn.channel_id = l:channel_id + endif + + if l:started + call s:SendInitMessage(l:conn) + endif + + return l:channel_id >= 0 +endfunction + +" Given a connection ID and a callback, register that callback for handling +" messages if the connection exists. +function! ale#lsp#RegisterCallback(conn_id, callback) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if !empty(l:conn) + " Add the callback to the List if it's not there already. + call uniq(sort(add(l:conn.callback_list, a:callback))) + endif +endfunction + +" Stop a single LSP connection. +function! ale#lsp#Stop(conn_id) abort + if has_key(s:connections, a:conn_id) + let l:conn = remove(s:connections, a:conn_id) + + if has_key(l:conn, 'channel_id') + call ale#socket#Close(l:conn.channel_id) + elseif has_key(l:conn, 'job_id') + call ale#job#Stop(l:conn.job_id) + endif + endif +endfunction + +function! ale#lsp#CloseDocument(conn_id) abort +endfunction + +" Stop all LSP connections, closing all jobs and channels, and removing any +" queued messages. +function! ale#lsp#StopAll() abort + for l:conn_id in keys(s:connections) + call ale#lsp#Stop(l:conn_id) + endfor +endfunction + +function! s:SendMessageData(conn, data) abort + if has_key(a:conn, 'job_id') + call ale#job#SendRaw(a:conn.job_id, a:data) + elseif has_key(a:conn, 'channel_id') && ale#socket#IsOpen(a:conn.channel_id) + " Send the message to the server + call ale#socket#Send(a:conn.channel_id, a:data) + else + return 0 + endif + + return 1 +endfunction + +" Send a message to an LSP server. +" Notifications do not need to be handled. +" +" Returns -1 when a message is sent, but no response is expected +" 0 when the message is not sent and +" >= 1 with the message ID when a response is expected. +function! ale#lsp#Send(conn_id, message) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return 0 + endif + + if !l:conn.initialized + throw 'LSP server not initialized yet!' + endif + + let [l:id, l:data] = ale#lsp#CreateMessageData(a:message) + call s:SendMessageData(l:conn, l:data) + + return l:id == 0 ? -1 : l:id +endfunction + +" Notify LSP servers or tsserver if a document is opened, if needed. +" If a document is opened, 1 will be returned, otherwise 0 will be returned. +function! ale#lsp#OpenDocument(conn_id, buffer, language_id) abort + let l:conn = get(s:connections, a:conn_id, {}) + let l:opened = 0 + + if !empty(l:conn) && !has_key(l:conn.open_documents, a:buffer) + if l:conn.is_tsserver + let l:message = ale#lsp#tsserver_message#Open(a:buffer) + else + let l:message = ale#lsp#message#DidOpen(a:buffer, a:language_id) + endif + + call ale#lsp#Send(a:conn_id, l:message) + let l:conn.open_documents[a:buffer] = getbufvar(a:buffer, 'changedtick') + let l:opened = 1 + endif + + return l:opened +endfunction + +" Notify LSP servers or tsserver that a document is closed, if opened before. +" If a document is closed, 1 will be returned, otherwise 0 will be returned. +" +" Only the buffer number is required here. A message will be sent to every +" language server that was notified previously of the document being opened. +function! ale#lsp#CloseDocument(buffer) abort + let l:closed = 0 + + " The connection keys are sorted so the messages are easier to test, and + " so messages are sent in a consistent order. + for l:conn_id in sort(keys(s:connections)) + let l:conn = s:connections[l:conn_id] + + if l:conn.initialized && has_key(l:conn.open_documents, a:buffer) + if l:conn.is_tsserver + let l:message = ale#lsp#tsserver_message#Close(a:buffer) + else + let l:message = ale#lsp#message#DidClose(a:buffer) + endif + + call ale#lsp#Send(l:conn_id, l:message) + call remove(l:conn.open_documents, a:buffer) + let l:closed = 1 + endif + endfor + + return l:closed +endfunction + +" Notify LSP servers or tsserver that a document has changed, if needed. +" If a notification is sent, 1 will be returned, otherwise 0 will be returned. +function! ale#lsp#NotifyForChanges(conn_id, buffer) abort + let l:conn = get(s:connections, a:conn_id, {}) + let l:notified = 0 + + if !empty(l:conn) && has_key(l:conn.open_documents, a:buffer) + let l:new_tick = getbufvar(a:buffer, 'changedtick') + + if l:conn.open_documents[a:buffer] < l:new_tick + if l:conn.is_tsserver + let l:message = ale#lsp#tsserver_message#Change(a:buffer) + else + let l:message = ale#lsp#message#DidChange(a:buffer) + endif + + call ale#lsp#Send(a:conn_id, l:message) + let l:conn.open_documents[a:buffer] = l:new_tick + let l:notified = 1 + endif + endif + + return l:notified +endfunction + +" Wait for an LSP server to be initialized. +function! ale#lsp#OnInit(conn_id, Callback) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return + endif + + if l:conn.initialized + call a:Callback() + else + call add(l:conn.init_queue, a:Callback) + endif +endfunction + +" Check if an LSP has a given capability. +function! ale#lsp#HasCapability(conn_id, capability) abort + let l:conn = get(s:connections, a:conn_id, {}) + + if empty(l:conn) + return 0 + endif + + if type(get(l:conn.capabilities, a:capability, v:null)) isnot v:t_number + throw 'Invalid capability ' . a:capability + endif + + return l:conn.capabilities[a:capability] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/message.vim b/sources_non_forked/ale/autoload/ale/lsp/message.vim new file mode 100644 index 00000000..c2238dec --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp/message.vim @@ -0,0 +1,212 @@ +" Author: w0rp +" Description: Language Server Protocol message implementations +" +" Messages in this movie will be returned in the format +" [is_notification, method_name, params?] +" +" All functions which accept line and column arguments expect them to be 1-based +" (the same format as being returned by getpos() and friends), those then +" will be converted to 0-based as specified by LSP. +let g:ale_lsp_next_version_id = 1 + +" The LSP protocols demands that we send every change to a document, including +" undo, with incrementing version numbers, so we'll just use one incrementing +" ID for everything. +function! ale#lsp#message#GetNextVersionID() abort + " Use the current ID + let l:id = g:ale_lsp_next_version_id + + " Increment the ID variable. + let g:ale_lsp_next_version_id += 1 + + " When the ID overflows, reset it to 1. By the time we hit the initial ID + " again, the messages will be long gone. + if g:ale_lsp_next_version_id < 1 + let g:ale_lsp_next_version_id = 1 + endif + + return l:id +endfunction + +function! ale#lsp#message#Initialize(root_path, options, capabilities) abort + " NOTE: rootPath is deprecated in favour of rootUri + return [0, 'initialize', { + \ 'processId': getpid(), + \ 'rootPath': a:root_path, + \ 'capabilities': a:capabilities, + \ 'initializationOptions': a:options, + \ 'rootUri': ale#util#ToURI(a:root_path), + \}] +endfunction + +function! ale#lsp#message#Initialized() abort + return [1, 'initialized', {}] +endfunction + +function! ale#lsp#message#Shutdown() abort + return [0, 'shutdown'] +endfunction + +function! ale#lsp#message#Exit() abort + return [1, 'exit'] +endfunction + +function! ale#lsp#message#DidOpen(buffer, language_id) abort + let l:lines = getbufline(a:buffer, 1, '$') + + return [1, 'textDocument/didOpen', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ 'languageId': a:language_id, + \ 'version': ale#lsp#message#GetNextVersionID(), + \ 'text': join(l:lines, "\n") . "\n", + \ }, + \}] +endfunction + +function! ale#lsp#message#DidChange(buffer) abort + let l:lines = getbufline(a:buffer, 1, '$') + + " For changes, we simply send the full text of the document to the server. + return [1, 'textDocument/didChange', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ 'version': ale#lsp#message#GetNextVersionID(), + \ }, + \ 'contentChanges': [{'text': join(l:lines, "\n") . "\n"}] + \}] +endfunction + +function! ale#lsp#message#DidSave(buffer, include_text) abort + let l:response = [1, 'textDocument/didSave', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \}] + + if a:include_text + let l:response[2].textDocument.version = ale#lsp#message#GetNextVersionID() + let l:response[2].text = ale#util#GetBufferContents(a:buffer) + endif + + return l:response +endfunction + +function! ale#lsp#message#DidClose(buffer) abort + return [1, 'textDocument/didClose', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \}] +endfunction + +let s:COMPLETION_TRIGGER_INVOKED = 1 +let s:COMPLETION_TRIGGER_CHARACTER = 2 + +function! ale#lsp#message#Completion(buffer, line, column, trigger_character) abort + let l:message = [0, 'textDocument/completion', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] + + if !empty(a:trigger_character) + let l:message[2].context = { + \ 'triggerKind': s:COMPLETION_TRIGGER_CHARACTER, + \ 'triggerCharacter': a:trigger_character, + \} + endif + + return l:message +endfunction + +function! ale#lsp#message#Definition(buffer, line, column) abort + return [0, 'textDocument/definition', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#TypeDefinition(buffer, line, column) abort + return [0, 'textDocument/typeDefinition', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#Implementation(buffer, line, column) abort + return [0, 'textDocument/implementation', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#References(buffer, line, column) abort + return [0, 'textDocument/references', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \ 'context': {'includeDeclaration': v:false}, + \}] +endfunction + +function! ale#lsp#message#Symbol(query) abort + return [0, 'workspace/symbol', { + \ 'query': a:query, + \}] +endfunction + +function! ale#lsp#message#Hover(buffer, line, column) abort + return [0, 'textDocument/hover', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \}] +endfunction + +function! ale#lsp#message#DidChangeConfiguration(buffer, config) abort + return [1, 'workspace/didChangeConfiguration', { + \ 'settings': a:config, + \}] +endfunction + +function! ale#lsp#message#Rename(buffer, line, column, new_name) abort + return [0, 'textDocument/rename', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'position': {'line': a:line - 1, 'character': a:column - 1}, + \ 'newName': a:new_name, + \}] +endfunction + +function! ale#lsp#message#CodeAction(buffer, line, column, end_line, end_column, diagnostics) abort + return [0, 'textDocument/codeAction', { + \ 'textDocument': { + \ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')), + \ }, + \ 'range': { + \ 'start': {'line': a:line - 1, 'character': a:column - 1}, + \ 'end': {'line': a:end_line - 1, 'character': a:end_column}, + \ }, + \ 'context': { + \ 'diagnostics': a:diagnostics + \ }, + \}] +endfunction + +function! ale#lsp#message#ExecuteCommand(command, arguments) abort + return [0, 'workspace/executeCommand', { + \ 'command': a:command, + \ 'arguments': a:arguments, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/reset.vim b/sources_non_forked/ale/autoload/ale/lsp/reset.vim new file mode 100644 index 00000000..2fc7f0a2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp/reset.vim @@ -0,0 +1,25 @@ +" Stop all LSPs and remove all of the data for them. +function! ale#lsp#reset#StopAllLSPs() abort + call ale#lsp#StopAll() + + if exists('*ale#definition#ClearLSPData') + " Clear the mapping for connections, etc. + call ale#definition#ClearLSPData() + endif + + if exists('*ale#lsp_linter#ClearLSPData') + " Clear the mapping for connections, etc. + call ale#lsp_linter#ClearLSPData() + + " Remove the problems for all of the LSP linters in every buffer. + for l:buffer_string in keys(g:ale_buffer_info) + let l:buffer = str2nr(l:buffer_string) + + for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) + if !empty(l:linter.lsp) + call ale#engine#HandleLoclist(l:linter.name, l:buffer, [], 0) + endif + endfor + endfor + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/response.vim b/sources_non_forked/ale/autoload/ale/lsp/response.vim new file mode 100644 index 00000000..498ec508 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp/response.vim @@ -0,0 +1,152 @@ +" Author: w0rp +" Description: Parsing and transforming of LSP server responses. + +" Constants for error codes. +" Defined by JSON RPC +let s:PARSE_ERROR = -32700 +let s:INVALID_REQUEST = -32600 +let s:METHOD_NOT_FOUND = -32601 +let s:INVALID_PARAMS = -32602 +let s:INTERNAL_ERROR = -32603 +let s:SERVER_ERROR_START = -32099 +let s:SERVER_ERROR_END = -32000 +let s:SERVER_NOT_INITIALIZED = -32002 +let s:UNKNOWN_ERROR_CODE = -32001 +" Defined by the protocol. +let s:REQUEST_CANCELLED = -32800 + +" Constants for message severity codes. +let s:SEVERITY_ERROR = 1 +let s:SEVERITY_WARNING = 2 +let s:SEVERITY_INFORMATION = 3 +let s:SEVERITY_HINT = 4 + +" Parse the message for textDocument/publishDiagnostics +function! ale#lsp#response#ReadDiagnostics(response) abort + let l:loclist = [] + + for l:diagnostic in a:response.params.diagnostics + let l:severity = get(l:diagnostic, 'severity', 0) + let l:loclist_item = { + \ 'text': substitute(l:diagnostic.message, '\(\r\n\|\n\|\r\)', ' ', 'g'), + \ 'type': 'E', + \ 'lnum': l:diagnostic.range.start.line + 1, + \ 'col': l:diagnostic.range.start.character + 1, + \ 'end_lnum': l:diagnostic.range.end.line + 1, + \ 'end_col': l:diagnostic.range.end.character, + \} + + if l:severity == s:SEVERITY_WARNING + let l:loclist_item.type = 'W' + elseif l:severity == s:SEVERITY_INFORMATION + " TODO: Use 'I' here in future. + let l:loclist_item.type = 'W' + elseif l:severity == s:SEVERITY_HINT + " TODO: Use 'H' here in future + let l:loclist_item.type = 'W' + endif + + if has_key(l:diagnostic, 'code') + if type(l:diagnostic.code) == v:t_string + let l:loclist_item.code = l:diagnostic.code + elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1 + let l:loclist_item.code = string(l:diagnostic.code) + let l:loclist_item.nr = l:diagnostic.code + endif + endif + + if has_key(l:diagnostic, 'relatedInformation') + \ && l:diagnostic.relatedInformation isnot v:null + let l:related = deepcopy(l:diagnostic.relatedInformation) + call map(l:related, {key, val -> + \ ale#util#ToResource(val.location.uri) . + \ ':' . (val.location.range.start.line + 1) . + \ ':' . (val.location.range.start.character + 1) . + \ ":\n\t" . val.message + \}) + let l:loclist_item.detail = l:diagnostic.message . "\n" . join(l:related, "\n") + endif + + if has_key(l:diagnostic, 'source') + let l:loclist_item.detail = printf( + \ '[%s] %s', + \ l:diagnostic.source, + \ l:diagnostic.message + \) + endif + + call add(l:loclist, l:loclist_item) + endfor + + return l:loclist +endfunction + +function! ale#lsp#response#ReadTSServerDiagnostics(response) abort + let l:loclist = [] + + for l:diagnostic in a:response.body.diagnostics + let l:loclist_item = { + \ 'text': l:diagnostic.text, + \ 'type': 'E', + \ 'lnum': l:diagnostic.start.line, + \ 'col': l:diagnostic.start.offset, + \ 'end_lnum': l:diagnostic.end.line, + \ 'end_col': l:diagnostic.end.offset - 1, + \} + + if has_key(l:diagnostic, 'code') + if type(l:diagnostic.code) == v:t_string + let l:loclist_item.code = l:diagnostic.code + elseif type(l:diagnostic.code) == v:t_number && l:diagnostic.code != -1 + let l:loclist_item.code = string(l:diagnostic.code) + let l:loclist_item.nr = l:diagnostic.code + endif + endif + + if get(l:diagnostic, 'category') is# 'warning' + let l:loclist_item.type = 'W' + endif + + if get(l:diagnostic, 'category') is# 'suggestion' + let l:loclist_item.type = 'I' + endif + + call add(l:loclist, l:loclist_item) + endfor + + return l:loclist +endfunction + +function! ale#lsp#response#GetErrorMessage(response) abort + if type(get(a:response, 'error', 0)) isnot v:t_dict + return '' + endif + + let l:code = get(a:response.error, 'code') + + " Only report things for these error codes. + if l:code isnot s:INVALID_PARAMS && l:code isnot s:INTERNAL_ERROR + return '' + endif + + let l:message = get(a:response.error, 'message', '') + + if empty(l:message) + return '' + endif + + " Include the traceback or error data as details, if present. + let l:error_data = get(a:response.error, 'data', {}) + + if type(l:error_data) is v:t_string + let l:message .= "\n" . l:error_data + elseif type(l:error_data) is v:t_dict + let l:traceback = get(l:error_data, 'traceback', []) + + if type(l:traceback) is v:t_list && !empty(l:traceback) + let l:message .= "\n" . join(l:traceback, "\n") + endif + endif + + return l:message +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim new file mode 100644 index 00000000..02e57899 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp/tsserver_message.vim @@ -0,0 +1,165 @@ +" Author: w0rp +" Description: tsserver message implementations +" +" Messages in this movie will be returned in the format +" [is_notification, command_name, params?] +" +" Every command must begin with the string 'ts@', which will be used to +" detect the different message format for tsserver, and this string will +" be removed from the actual command name, + +function! ale#lsp#tsserver_message#Open(buffer) abort + return [1, 'ts@open', {'file': expand('#' . a:buffer . ':p')}] +endfunction + +function! ale#lsp#tsserver_message#Close(buffer) abort + return [1, 'ts@close', {'file': expand('#' . a:buffer . ':p')}] +endfunction + +function! ale#lsp#tsserver_message#Change(buffer) abort + let l:lines = getbufline(a:buffer, 1, '$') + + " We will always use a very high endLine number, so we can delete + " lines from files. tsserver will gladly accept line numbers beyond the + " end. + return [1, 'ts@change', { + \ 'file': expand('#' . a:buffer . ':p'), + \ 'line': 1, + \ 'offset': 1, + \ 'endLine': 1073741824, + \ 'endOffset': 1, + \ 'insertString': join(l:lines, "\n") . "\n", + \}] +endfunction + +function! ale#lsp#tsserver_message#Geterr(buffer) abort + return [1, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}] +endfunction + +function! ale#lsp#tsserver_message#Completions( +\ buffer, line, column, prefix, include_external) abort + return [0, 'ts@completions', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'prefix': a:prefix, + \ 'includeExternalModuleExports': a:include_external, + \}] +endfunction + +function! ale#lsp#tsserver_message#CompletionEntryDetails(buffer, line, column, entry_names) abort + return [0, 'ts@completionEntryDetails', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'entryNames': a:entry_names, + \}] +endfunction + +function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort + return [0, 'ts@definition', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort + return [0, 'ts@typeDefinition', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#Implementation(buffer, line, column) abort + return [0, 'ts@implementation', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#References(buffer, line, column) abort + return [0, 'ts@references', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#Quickinfo(buffer, line, column) abort + return [0, 'ts@quickinfo', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#Rename( +\ buffer, line, column, find_in_comments, find_in_strings) abort + return [0, 'ts@rename', { + \ 'line': a:line, + \ 'offset': a:column, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'arguments': { + \ 'findInComments': a:find_in_comments, + \ 'findInStrings': a:find_in_strings, + \ } + \}] +endfunction + +function! ale#lsp#tsserver_message#GetEditsForFileRename( +\ oldFilePath, newFilePath) abort + return [0, 'ts@getEditsForFileRename', { + \ 'oldFilePath': a:oldFilePath, + \ 'newFilePath': a:newFilePath, + \}] +endfunction + +function! ale#lsp#tsserver_message#OrganizeImports(buffer) abort + return [0, 'ts@organizeImports', { + \ 'scope': { + \ 'type': 'file', + \ 'args': { + \ 'file': expand('#' . a:buffer . ':p'), + \ }, + \ }, + \}] +endfunction + +function! ale#lsp#tsserver_message#GetCodeFixes(buffer, line, column, end_line, end_column, error_codes) abort + " The lines and columns are 1-based. + " The errors codes must be a list of tsserver error codes to fix. + return [0, 'ts@getCodeFixes', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'errorCodes': a:error_codes, + \}] +endfunction + +function! ale#lsp#tsserver_message#GetApplicableRefactors(buffer, line, column, end_line, end_column) abort + " The arguments for this request can also be just 'line' and 'offset' + return [0, 'ts@getApplicableRefactors', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \}] +endfunction + +function! ale#lsp#tsserver_message#GetEditsForRefactor(buffer, line, column, end_line, end_column, refactor, action) abort + return [0, 'ts@getEditsForRefactor', { + \ 'startLine': a:line, + \ 'startOffset': a:column, + \ 'endLine': a:end_line, + \ 'endOffset': a:end_column + 1, + \ 'file': expand('#' . a:buffer . ':p'), + \ 'refactor': a:refactor, + \ 'action': a:action, + \}] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_linter.vim b/sources_non_forked/ale/autoload/ale/lsp_linter.vim new file mode 100644 index 00000000..1c98d628 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp_linter.vim @@ -0,0 +1,547 @@ +" Author: w0rp +" Description: Integration between linters and LSP/tsserver. + +" This code isn't loaded if a user never users LSP features or linters. + +" Associates LSP connection IDs with linter names. +if !has_key(s:, 'lsp_linter_map') + let s:lsp_linter_map = {} +endif + +" A Dictionary to track one-shot handlers for custom LSP requests +let s:custom_handlers_map = get(s:, 'custom_handlers_map', {}) + +" Clear LSP linter data for the linting engine. +function! ale#lsp_linter#ClearLSPData() abort + let s:lsp_linter_map = {} + let s:custom_handlers_map = {} +endfunction + +" Only for internal use. +function! ale#lsp_linter#GetLSPLinterMap() abort + return s:lsp_linter_map +endfunction + +" Just for tests. +function! ale#lsp_linter#SetLSPLinterMap(replacement_map) abort + let s:lsp_linter_map = a:replacement_map +endfunction + +" Check if diagnostics for a particular linter should be ignored. +function! s:ShouldIgnore(buffer, linter_name) abort + " Ignore all diagnostics if LSP integration is disabled. + if ale#Var(a:buffer, 'disable_lsp') + return 1 + endif + + let l:config = ale#Var(a:buffer, 'linters_ignore') + + " Don't load code for ignoring diagnostics if there's nothing to ignore. + if empty(l:config) + return 0 + endif + + let l:filetype = getbufvar(a:buffer, '&filetype') + let l:ignore_list = ale#engine#ignore#GetList(l:filetype, l:config) + + return index(l:ignore_list, a:linter_name) >= 0 +endfunction + +function! s:HandleLSPDiagnostics(conn_id, response) abort + let l:linter_name = s:lsp_linter_map[a:conn_id] + let l:filename = ale#util#ToResource(a:response.params.uri) + let l:escaped_name = escape( + \ fnameescape(l:filename), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') + let l:info = get(g:ale_buffer_info, l:buffer, {}) + + if empty(l:info) + return + endif + + if s:ShouldIgnore(l:buffer, l:linter_name) + return + endif + + let l:loclist = ale#lsp#response#ReadDiagnostics(a:response) + + call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) +endfunction + +function! s:HandleTSServerDiagnostics(response, error_type) abort + let l:linter_name = 'tsserver' + let l:escaped_name = escape( + \ fnameescape(a:response.body.file), + \ has('win32') ? '^' : '^,}]' + \) + let l:buffer = bufnr('^' . l:escaped_name . '$') + let l:info = get(g:ale_buffer_info, l:buffer, {}) + + if empty(l:info) + return + endif + + call ale#engine#MarkLinterInactive(l:info, l:linter_name) + + if s:ShouldIgnore(l:buffer, l:linter_name) + return + endif + + let l:thislist = ale#lsp#response#ReadTSServerDiagnostics(a:response) + let l:no_changes = 0 + + " tsserver sends syntax and semantic errors in separate messages, so we + " have to collect the messages separately for each buffer and join them + " back together again. + if a:error_type is# 'syntax' + if len(l:thislist) is 0 && len(get(l:info, 'syntax_loclist', [])) is 0 + let l:no_changes = 1 + endif + + let l:info.syntax_loclist = l:thislist + elseif a:error_type is# 'semantic' + if len(l:thislist) is 0 && len(get(l:info, 'semantic_loclist', [])) is 0 + let l:no_changes = 1 + endif + + let l:info.semantic_loclist = l:thislist + else + if len(l:thislist) is 0 && len(get(l:info, 'suggestion_loclist', [])) is 0 + let l:no_changes = 1 + endif + + let l:info.suggestion_loclist = l:thislist + endif + + if l:no_changes + return + endif + + let l:loclist = get(l:info, 'semantic_loclist', []) + \ + get(l:info, 'suggestion_loclist', []) + \ + get(l:info, 'syntax_loclist', []) + + call ale#engine#HandleLoclist(l:linter_name, l:buffer, l:loclist, 0) +endfunction + +function! s:HandleLSPErrorMessage(linter_name, response) abort + if !g:ale_history_enabled || !g:ale_history_log_output + return + endif + + if empty(a:linter_name) + return + endif + + let l:message = ale#lsp#response#GetErrorMessage(a:response) + + if empty(l:message) + return + endif + + call ale#lsp_linter#AddErrorMessage(a:linter_name, l:message) +endfunction + +function! ale#lsp_linter#AddErrorMessage(linter_name, message) abort + " This global variable is set here so we don't load the debugging.vim file + " until someone uses :ALEInfo. + let g:ale_lsp_error_messages = get(g:, 'ale_lsp_error_messages', {}) + + if !has_key(g:ale_lsp_error_messages, a:linter_name) + let g:ale_lsp_error_messages[a:linter_name] = [] + endif + + call add(g:ale_lsp_error_messages[a:linter_name], a:message) +endfunction + +function! ale#lsp_linter#HandleLSPResponse(conn_id, response) abort + let l:method = get(a:response, 'method', '') + + if get(a:response, 'jsonrpc', '') is# '2.0' && has_key(a:response, 'error') + let l:linter_name = get(s:lsp_linter_map, a:conn_id, '') + + call s:HandleLSPErrorMessage(l:linter_name, a:response) + elseif l:method is# 'textDocument/publishDiagnostics' + call s:HandleLSPDiagnostics(a:conn_id, a:response) + elseif l:method is# 'window/showMessage' + call ale#lsp_window#HandleShowMessage( + \ s:lsp_linter_map[a:conn_id], + \ g:ale_lsp_show_message_format, + \ a:response.params + \) + elseif get(a:response, 'type', '') is# 'event' + \&& get(a:response, 'event', '') is# 'semanticDiag' + call s:HandleTSServerDiagnostics(a:response, 'semantic') + elseif get(a:response, 'type', '') is# 'event' + \&& get(a:response, 'event', '') is# 'syntaxDiag' + call s:HandleTSServerDiagnostics(a:response, 'syntax') + elseif get(a:response, 'type', '') is# 'event' + \&& get(a:response, 'event', '') is# 'suggestionDiag' + \&& get(g:, 'ale_lsp_suggestions', '1') == 1 + call s:HandleTSServerDiagnostics(a:response, 'suggestion') + endif +endfunction + +function! ale#lsp_linter#GetOptions(buffer, linter) abort + if has_key(a:linter, 'initialization_options_callback') + return ale#util#GetFunction(a:linter.initialization_options_callback)(a:buffer) + endif + + if has_key(a:linter, 'initialization_options') + let l:Options = a:linter.initialization_options + + if type(l:Options) is v:t_func + let l:Options = l:Options(a:buffer) + endif + + return l:Options + endif + + return {} +endfunction + +function! ale#lsp_linter#GetConfig(buffer, linter) abort + if has_key(a:linter, 'lsp_config_callback') + return ale#util#GetFunction(a:linter.lsp_config_callback)(a:buffer) + endif + + if has_key(a:linter, 'lsp_config') + let l:Config = a:linter.lsp_config + + if type(l:Config) is v:t_func + let l:Config = l:Config(a:buffer) + endif + + return l:Config + endif + + return {} +endfunction + +function! ale#lsp_linter#FindProjectRoot(buffer, linter) abort + let l:buffer_ale_root = getbufvar( + \ a:buffer, + \ 'ale_root', + \ getbufvar(a:buffer, 'ale_lsp_root', {}) + \) + + if type(l:buffer_ale_root) is v:t_string + return l:buffer_ale_root + endif + + " Try to get a buffer-local setting for the root + if has_key(l:buffer_ale_root, a:linter.name) + let l:Root = l:buffer_ale_root[a:linter.name] + + if type(l:Root) is v:t_func + return l:Root(a:buffer) + else + return l:Root + endif + endif + + let l:global_root = g:ale_root + + if empty(g:ale_root) && exists('g:ale_lsp_root') + let l:global_root = g:ale_lsp_root + endif + + " Try to get a global setting for the root + if has_key(l:global_root, a:linter.name) + let l:Root = l:global_root[a:linter.name] + + if type(l:Root) is v:t_func + return l:Root(a:buffer) + else + return l:Root + endif + endif + + " Fall back to the linter-specific configuration + if has_key(a:linter, 'project_root') + let l:Root = a:linter.project_root + + return type(l:Root) is v:t_func ? l:Root(a:buffer) : l:Root + endif + + return ale#util#GetFunction(a:linter.project_root_callback)(a:buffer) +endfunction + +" This function is accessible so tests can call it. +function! ale#lsp_linter#OnInit(linter, details, Callback) abort + let l:buffer = a:details.buffer + let l:conn_id = a:details.connection_id + let l:command = a:details.command + + let l:config = ale#lsp_linter#GetConfig(l:buffer, a:linter) + let l:language_id = ale#linter#GetLanguage(l:buffer, a:linter) + + call ale#lsp#UpdateConfig(l:conn_id, l:buffer, l:config) + + if ale#lsp#OpenDocument(l:conn_id, l:buffer, l:language_id) + if g:ale_history_enabled && !empty(l:command) + call ale#history#Add(l:buffer, 'started', l:conn_id, l:command) + endif + endif + + " The change message needs to be sent for tsserver before doing anything. + if a:linter.lsp is# 'tsserver' + call ale#lsp#NotifyForChanges(l:conn_id, l:buffer) + endif + + " Tell the relevant buffer that the LSP has started via an autocmd. + if l:buffer > 0 + if l:buffer == bufnr('') + silent doautocmd User ALELSPStarted + else + execute 'augroup ALELSPStartedGroup' . l:buffer + autocmd! + + execute printf( + \ 'autocmd BufEnter ' + \ . ' doautocmd User ALELSPStarted', + \ l:buffer + \) + + " Replicate ++once behavior for backwards compatibility. + execute printf( + \ 'autocmd BufEnter ' + \ . ' autocmd! ALELSPStartedGroup%d', + \ l:buffer, l:buffer + \) + augroup END + endif + endif + + call a:Callback(a:linter, a:details) +endfunction + +function! s:StartLSP(options, address, executable, command) abort + let l:buffer = a:options.buffer + let l:linter = a:options.linter + let l:root = a:options.root + let l:Callback = a:options.callback + + let l:init_options = ale#lsp_linter#GetOptions(l:buffer, l:linter) + + if l:linter.lsp is# 'socket' + let l:conn_id = ale#lsp#Register(a:address, l:root, l:init_options) + let l:ready = ale#lsp#ConnectToAddress(l:conn_id, a:address) + let l:command = '' + else + let l:conn_id = ale#lsp#Register(a:executable, l:root, l:init_options) + + " tsserver behaves differently, so tell the LSP API that it is tsserver. + if l:linter.lsp is# 'tsserver' + call ale#lsp#MarkConnectionAsTsserver(l:conn_id) + endif + + let l:cwd = ale#linter#GetCwd(l:buffer, l:linter) + let l:command = ale#command#FormatCommand( + \ l:buffer, + \ a:executable, + \ a:command, + \ 0, + \ v:false, + \ l:cwd, + \ ale#GetFilenameMappings(l:buffer, l:linter.name), + \)[1] + let l:command = ale#job#PrepareCommand(l:buffer, l:command) + let l:ready = ale#lsp#StartProgram(l:conn_id, a:executable, l:command) + endif + + if !l:ready + if g:ale_history_enabled && !empty(a:command) + call ale#history#Add(l:buffer, 'failed', l:conn_id, a:command) + endif + + return 0 + endif + + let l:details = { + \ 'buffer': l:buffer, + \ 'connection_id': l:conn_id, + \ 'command': l:command, + \ 'project_root': l:root, + \} + + call ale#lsp#OnInit(l:conn_id, {-> + \ ale#lsp_linter#OnInit(l:linter, l:details, l:Callback) + \}) + + return 1 +endfunction + +function! s:StartWithAddress(options, address) abort + if ale#command#IsDeferred(a:address) + let a:address.result_callback = { + \ address -> s:StartWithAddress(a:options, address) + \} + + return 1 + endif + + if empty(a:address) + return 0 + endif + + return s:StartLSP(a:options, a:address, '', '') +endfunction + +function! s:StartWithCommand(options, executable, command) abort + if ale#command#IsDeferred(a:command) + let a:command.result_callback = { + \ command -> s:StartWithCommand(a:options, a:executable, command) + \} + + return 1 + endif + + if empty(a:command) + return 0 + endif + + return s:StartLSP(a:options, '', a:executable, a:command) +endfunction + +function! s:StartIfExecutable(options, executable) abort + if ale#command#IsDeferred(a:executable) + let a:executable.result_callback = { + \ executable -> s:StartIfExecutable(a:options, executable) + \} + + return 1 + endif + + if !ale#engine#IsExecutable(a:options.buffer, a:executable) + return 0 + endif + + let l:command = ale#linter#GetCommand(a:options.buffer, a:options.linter) + + return s:StartWithCommand(a:options, a:executable, l:command) +endfunction + +" Given a buffer, an LSP linter, start up an LSP linter and get ready to +" receive messages for the document. +function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort + let l:command = '' + let l:address = '' + let l:root = ale#lsp_linter#FindProjectRoot(a:buffer, a:linter) + + if empty(l:root) && a:linter.lsp isnot# 'tsserver' + " If there's no project root, then we can't check files with LSP, + " unless we are using tsserver, which doesn't use project roots. + call ale#lsp_linter#AddErrorMessage(a:linter.name, "Failed to find project root, language server won't start.") + + return 0 + endif + + let l:options = { + \ 'buffer': a:buffer, + \ 'linter': a:linter, + \ 'callback': a:Callback, + \ 'root': l:root, + \} + + if a:linter.lsp is# 'socket' + let l:address = ale#linter#GetAddress(a:buffer, a:linter) + + return s:StartWithAddress(l:options, l:address) + endif + + let l:executable = ale#linter#GetExecutable(a:buffer, a:linter) + + return s:StartIfExecutable(l:options, l:executable) +endfunction + +function! s:CheckWithLSP(linter, details) abort + let l:buffer = a:details.buffer + let l:info = get(g:ale_buffer_info, l:buffer) + + if empty(l:info) + return + endif + + let l:id = a:details.connection_id + + " Register a callback now for handling errors now. + let l:Callback = function('ale#lsp_linter#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + " Remember the linter this connection is for. + let s:lsp_linter_map[l:id] = a:linter.name + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Geterr(l:buffer) + let l:notified = ale#lsp#Send(l:id, l:message) != 0 + + if l:notified + call ale#engine#MarkLinterActive(l:info, a:linter) + endif + else + let l:notified = ale#lsp#NotifyForChanges(l:id, l:buffer) + endif + + " If this was a file save event, also notify the server of that. + if a:linter.lsp isnot# 'tsserver' + \&& getbufvar(l:buffer, 'ale_save_event_fired', 0) + \&& ale#lsp#HasCapability(l:id, 'did_save') + let l:include_text = ale#lsp#HasCapability(l:id, 'includeText') + let l:save_message = ale#lsp#message#DidSave(l:buffer, l:include_text) + let l:notified = ale#lsp#Send(l:id, l:save_message) != 0 + endif +endfunction + +function! ale#lsp_linter#CheckWithLSP(buffer, linter) abort + return ale#lsp_linter#StartLSP(a:buffer, a:linter, function('s:CheckWithLSP')) +endfunction + +function! s:HandleLSPResponseToCustomRequests(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:custom_handlers_map, a:response.id) + let l:Handler = remove(s:custom_handlers_map, a:response.id) + call l:Handler(a:response) + endif +endfunction + +function! s:OnReadyForCustomRequests(args, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + let l:request_id = ale#lsp#Send(l:id, a:args.message) + + if l:request_id > 0 && has_key(a:args, 'handler') + let l:Callback = function('s:HandleLSPResponseToCustomRequests') + call ale#lsp#RegisterCallback(l:id, l:Callback) + let s:custom_handlers_map[l:request_id] = a:args.handler + endif +endfunction + +" Send a custom request to an LSP linter. +function! ale#lsp_linter#SendRequest(buffer, linter_name, message, ...) abort + let l:filetype = ale#linter#ResolveFiletype(getbufvar(a:buffer, '&filetype')) + let l:linter_list = ale#linter#GetAll(l:filetype) + let l:linter_list = filter(l:linter_list, {_, v -> v.name is# a:linter_name}) + + if len(l:linter_list) < 1 + throw 'Linter "' . a:linter_name . '" not found!' + endif + + let l:linter = l:linter_list[0] + + if empty(l:linter.lsp) + throw 'Linter "' . a:linter_name . '" does not support LSP!' + endif + + let l:is_notification = a:message[0] + let l:callback_args = {'message': a:message} + + if !l:is_notification && a:0 + let l:callback_args.handler = a:1 + endif + + let l:Callback = function('s:OnReadyForCustomRequests', [l:callback_args]) + + return ale#lsp_linter#StartLSP(a:buffer, l:linter, l:Callback) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/lsp_window.vim b/sources_non_forked/ale/autoload/ale/lsp_window.vim new file mode 100644 index 00000000..9a27f2f1 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/lsp_window.vim @@ -0,0 +1,58 @@ +" Author: suoto +" Description: Handling of window/* LSP methods, although right now only +" handles window/showMessage + +" Constants for message type codes +let s:LSP_MESSAGE_TYPE_DISABLED = 0 +let s:LSP_MESSAGE_TYPE_ERROR = 1 +let s:LSP_MESSAGE_TYPE_WARNING = 2 +let s:LSP_MESSAGE_TYPE_INFORMATION = 3 +let s:LSP_MESSAGE_TYPE_LOG = 4 + +" Translate strings from the user config to a number so we can check +" severities +let s:CFG_TO_LSP_SEVERITY = { +\ 'disabled': s:LSP_MESSAGE_TYPE_DISABLED, +\ 'error': s:LSP_MESSAGE_TYPE_ERROR, +\ 'warning': s:LSP_MESSAGE_TYPE_WARNING, +\ 'information': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'info': s:LSP_MESSAGE_TYPE_INFORMATION, +\ 'log': s:LSP_MESSAGE_TYPE_LOG +\} + +" Handle window/showMessage response. +" - details: dict containing linter name and format (g:ale_lsp_show_message_format) +" - params: dict with the params for the call in the form of {type: number, message: string} +function! ale#lsp_window#HandleShowMessage(linter_name, format, params) abort + let l:message = a:params.message + let l:type = a:params.type + + " Get the configured severity level threshold and check if the message + " should be displayed or not + let l:configured_severity = tolower(get(g:, 'ale_lsp_show_message_severity', 'error')) + " If the user has configured with a value we can't find on the conversion + " dict, fall back to warning + let l:cfg_severity_threshold = get(s:CFG_TO_LSP_SEVERITY, l:configured_severity, s:LSP_MESSAGE_TYPE_WARNING) + + if l:type > l:cfg_severity_threshold + return + endif + + " Severity will depend on the message type + if l:type is# s:LSP_MESSAGE_TYPE_ERROR + let l:severity = g:ale_echo_msg_error_str + elseif l:type is# s:LSP_MESSAGE_TYPE_INFORMATION + let l:severity = g:ale_echo_msg_info_str + elseif l:type is# s:LSP_MESSAGE_TYPE_LOG + let l:severity = g:ale_echo_msg_log_str + else + " Default to warning just in case + let l:severity = g:ale_echo_msg_warning_str + endif + + let l:string = substitute(a:format, '\V%severity%', l:severity, 'g') + let l:string = substitute(l:string, '\V%linter%', a:linter_name, 'g') + let l:string = substitute(l:string, '\V%s\>', l:message, 'g') + + call ale#util#ShowMessage(l:string) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/maven.vim b/sources_non_forked/ale/autoload/ale/maven.vim new file mode 100644 index 00000000..4f87ebb7 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/maven.vim @@ -0,0 +1,57 @@ +" Description: Functions for working with Maven projects. +" +" Given a buffer number, find a Maven project root. +function! ale#maven#FindProjectRoot(buffer) abort + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, 'mvnw') + + if !empty(l:wrapper_path) + return fnamemodify(l:wrapper_path, ':h') + endif + + let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml') + + if !empty(l:pom_path) + return fnamemodify(l:pom_path, ':h') + endif + + return '' +endfunction + +" Given a buffer number, find the path to the executable. +" First search on the path for 'mvnw' (mvnw.cmd on Windows), if nothing is found, +" try the global command. Returns an empty string if cannot find the executable. +function! ale#maven#FindExecutable(buffer) abort + let l:wrapper_cmd = has('unix') ? 'mvnw' : 'mvnw.cmd' + let l:wrapper_path = ale#path#FindNearestFile(a:buffer, l:wrapper_cmd) + + if !empty(l:wrapper_path) && executable(l:wrapper_path) + return l:wrapper_path + endif + + if executable('mvn') + return 'mvn' + endif + + return '' +endfunction + +" Given a buffer number, get a working directory and command to print the +" classpath of the root project. +" +" Returns an empty string for the command if Maven is not detected. +function! ale#maven#BuildClasspathCommand(buffer) abort + let l:executable = ale#maven#FindExecutable(a:buffer) + + if !empty(l:executable) + let l:project_root = ale#maven#FindProjectRoot(a:buffer) + + if !empty(l:project_root) + return [ + \ l:project_root, + \ ale#Escape(l:executable) . ' dependency:build-classpath' + \] + endif + endif + + return ['', ''] +endfunction diff --git a/sources_non_forked/ale/autoload/ale/node.vim b/sources_non_forked/ale/autoload/ale/node.vim new file mode 100644 index 00000000..9e11ca7e --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/node.vim @@ -0,0 +1,22 @@ +" Author: w0rp +" Description: Functions for working with Node executables. + +call ale#Set('windows_node_executable_path', 'node.exe') + +" Create a executable string which executes a Node.js script command with a +" Node.js executable if needed. +" +" The executable string should not be escaped before passing it to this +" function, the executable string will be escaped when returned by this +" function. +" +" The executable is only prefixed for Windows machines +function! ale#node#Executable(buffer, executable) abort + if has('win32') && a:executable =~? '\.js$' + let l:node = ale#Var(a:buffer, 'windows_node_executable_path') + + return ale#Escape(l:node) . ' ' . ale#Escape(a:executable) + endif + + return ale#Escape(a:executable) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/organize_imports.vim b/sources_non_forked/ale/autoload/ale/organize_imports.vim new file mode 100644 index 00000000..a6e77863 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/organize_imports.vim @@ -0,0 +1,65 @@ +" Author: Jerko Steiner +" Description: Organize imports support for tsserver + +function! ale#organize_imports#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'organizeImports' + return + endif + + if get(a:response, 'success', v:false) isnot v:true + return + endif + + let l:file_code_edits = a:response.body + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'Organize Imports', + \ 'changes': l:file_code_edits, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': !&hidden, + \ }, + \) +endfunction + +function! s:OnReady(linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if a:linter.lsp isnot# 'tsserver' + call ale#util#Execute('echom ''OrganizeImports currently only works with tsserver''') + + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = function('ale#organize_imports#HandleTSServerResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#tsserver_message#OrganizeImports(l:buffer) + + let l:request_id = ale#lsp#Send(l:id, l:message) +endfunction + +function! s:OrganizeImports(linter) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function('s:OnReady') + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#organize_imports#Execute() abort + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call s:OrganizeImports(l:linter) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/other_source.vim b/sources_non_forked/ale/autoload/ale/other_source.vim new file mode 100644 index 00000000..1a092034 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/other_source.vim @@ -0,0 +1,21 @@ +" Tell ALE that another source has started checking a buffer. +function! ale#other_source#StartChecking(buffer, linter_name) abort + call ale#engine#InitBufferInfo(a:buffer) + let l:list = g:ale_buffer_info[a:buffer].active_other_sources_list + + call add(l:list, a:linter_name) + call uniq(sort(l:list)) +endfunction + +" Show some results, and stop checking a buffer. +" To clear results or cancel checking a buffer, an empty List can be given. +function! ale#other_source#ShowResults(buffer, linter_name, loclist) abort + call ale#engine#InitBufferInfo(a:buffer) + let l:info = g:ale_buffer_info[a:buffer] + + " Remove this linter name from the active list. + let l:list = l:info.active_other_sources_list + call filter(l:list, 'v:val isnot# a:linter_name') + + call ale#engine#HandleLoclist(a:linter_name, a:buffer, a:loclist, 1) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/path.vim b/sources_non_forked/ale/autoload/ale/path.vim new file mode 100644 index 00000000..cc5c6658 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/path.vim @@ -0,0 +1,252 @@ +" Author: w0rp +" Description: Functions for working with paths in the filesystem. + +" simplify a path, and fix annoying issues with paths on Windows. +" +" Forward slashes are changed to back slashes so path equality works better +" on Windows. Back slashes are changed to forward slashes on Unix. +" +" Unix paths can technically contain back slashes, but in practice no path +" should, and replacing back slashes with forward slashes makes linters work +" in environments like MSYS. +" +" Paths starting with more than one forward slash are changed to only one +" forward slash, to prevent the paths being treated as special MSYS paths. +function! ale#path#Simplify(path) abort + if has('unix') + let l:unix_path = substitute(a:path, '\\', '/', 'g') + + return substitute(simplify(l:unix_path), '^//\+', '/', 'g') " no-custom-checks + endif + + let l:win_path = substitute(a:path, '/', '\\', 'g') + + return substitute(simplify(l:win_path), '^\\\+', '\', 'g') " no-custom-checks +endfunction + +" Simplify a path without a Windows drive letter. +" This function can be used for checking if paths are equal. +function! ale#path#RemoveDriveLetter(path) abort + return has('win32') && a:path[1:2] is# ':\' + \ ? ale#path#Simplify(a:path[2:]) + \ : ale#path#Simplify(a:path) +endfunction + +" Given a buffer and a filename, find the nearest file by searching upwards +" through the paths relative to the given buffer. +function! ale#path#FindNearestFile(buffer, filename) abort + let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p') + let l:buffer_filename = fnameescape(l:buffer_filename) + + let l:relative_path = findfile(a:filename, l:buffer_filename . ';') + + if !empty(l:relative_path) + return fnamemodify(l:relative_path, ':p') + endif + + return '' +endfunction + +" Given a buffer and a directory name, find the nearest directory by searching upwards +" through the paths relative to the given buffer. +function! ale#path#FindNearestDirectory(buffer, directory_name) abort + let l:buffer_filename = fnamemodify(bufname(a:buffer), ':p') + let l:buffer_filename = fnameescape(l:buffer_filename) + + let l:relative_path = finddir(a:directory_name, l:buffer_filename . ';') + + if !empty(l:relative_path) + return fnamemodify(l:relative_path, ':p') + endif + + return '' +endfunction + +" Given a buffer, a string to search for, and a global fallback for when +" the search fails, look for a file in parent paths, and if that fails, +" use the global fallback path instead. +function! ale#path#ResolveLocalPath(buffer, search_string, global_fallback) abort + " Search for a locally installed file first. + let l:path = ale#path#FindNearestFile(a:buffer, a:search_string) + + " If the search fails, try the global executable instead. + if empty(l:path) + let l:path = a:global_fallback + endif + + return l:path +endfunction + +" Given a buffer number, a base variable name, and a list of paths to search +" for in ancestor directories, detect the executable path for a program. +function! ale#path#FindNearestExecutable(buffer, path_list) abort + for l:path in a:path_list + if ale#path#IsAbsolute(l:path) + let l:executable = filereadable(l:path) ? l:path : '' + else + let l:executable = ale#path#FindNearestFile(a:buffer, l:path) + endif + + if !empty(l:executable) + return l:executable + endif + endfor + + return '' +endfunction + +" Given a buffer number, a base variable name, and a list of paths to search +" for in ancestor directories, detect the executable path for a program. +" +" The use_global and executable options for the relevant program will be used. +function! ale#path#FindExecutable(buffer, base_var_name, path_list) abort + if ale#Var(a:buffer, a:base_var_name . '_use_global') + return ale#Var(a:buffer, a:base_var_name . '_executable') + endif + + let l:nearest = ale#path#FindNearestExecutable(a:buffer, a:path_list) + + if !empty(l:nearest) + return l:nearest + endif + + return ale#Var(a:buffer, a:base_var_name . '_executable') +endfunction + +" Return 1 if a path is an absolute path. +function! ale#path#IsAbsolute(filename) abort + if has('win32') && a:filename[:0] is# '\' + return 1 + endif + + " Check for /foo and C:\foo, etc. + return a:filename[:0] is# '/' || a:filename[1:2] is# ':\' +endfunction + +let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h')) + +" Given a filename, return 1 if the file represents some temporary file +" created by Vim. +function! ale#path#IsTempName(filename) abort + return ale#path#Simplify(a:filename)[:len(s:temp_dir) - 1] is# s:temp_dir +endfunction + +" Given a base directory, which must not have a trailing slash, and a +" filename, which may have an absolute path a path relative to the base +" directory, return the absolute path to the file. +function! ale#path#GetAbsPath(base_directory, filename) abort + if ale#path#IsAbsolute(a:filename) + return ale#path#Simplify(a:filename) + endif + + let l:sep = has('win32') ? '\' : '/' + + return ale#path#Simplify(a:base_directory . l:sep . a:filename) +endfunction + +" Given a path, return the directory name for that path, with no trailing +" slashes. If the argument is empty(), return an empty string. +function! ale#path#Dirname(path) abort + if empty(a:path) + return '' + endif + + " For /foo/bar/ we need :h:h to get /foo + if a:path[-1:] is# '/' || (has('win32') && a:path[-1:] is# '\') + return fnamemodify(a:path, ':h:h') + endif + + return fnamemodify(a:path, ':h') +endfunction + +" Given a buffer number and a relative or absolute path, return 1 if the +" two paths represent the same file on disk. +function! ale#path#IsBufferPath(buffer, complex_filename) abort + " If the path is one of many different names for stdin, we have a match. + if a:complex_filename is# '-' + \|| a:complex_filename is# 'stdin' + \|| a:complex_filename[:0] is# '<' + return 1 + endif + + let l:test_filename = ale#path#Simplify(a:complex_filename) + + if l:test_filename[:1] is# './' + let l:test_filename = l:test_filename[2:] + endif + + if l:test_filename[:1] is# '..' + " Remove ../../ etc. from the front of the path. + let l:test_filename = substitute(l:test_filename, '\v^(\.\.[/\\])+', '/', '') + endif + + " Use the basename for temporary files, as they are likely our files. + if ale#path#IsTempName(l:test_filename) + let l:test_filename = fnamemodify(l:test_filename, ':t') + endif + + let l:buffer_filename = expand('#' . a:buffer . ':p') + + return l:buffer_filename is# l:test_filename + \ || l:buffer_filename[-len(l:test_filename):] is# l:test_filename +endfunction + +" Given a path, return every component of the path, moving upwards. +function! ale#path#Upwards(path) abort + let l:pattern = has('win32') ? '\v/+|\\+' : '\v/+' + let l:sep = has('win32') ? '\' : '/' + let l:parts = split(ale#path#Simplify(a:path), l:pattern) + let l:path_list = [] + + while !empty(l:parts) + call add(l:path_list, join(l:parts, l:sep)) + let l:parts = l:parts[:-2] + endwhile + + if has('win32') && a:path =~# '^[a-zA-z]:\' + " Add \ to C: for C:\, etc. + let l:path_list[-1] .= '\' + elseif a:path[0] is# '/' + " If the path starts with /, even on Windows, add / and / to all paths. + call map(l:path_list, '''/'' . v:val') + call add(l:path_list, '/') + endif + + return l:path_list +endfunction + +" Convert a filesystem path to a file:// URI +" relatives paths will not be prefixed with the protocol. +" For Windows paths, the `:` in C:\ etc. will not be percent-encoded. +function! ale#path#ToFileURI(path) abort + let l:has_drive_letter = a:path[1:2] is# ':\' + + return substitute( + \ ((l:has_drive_letter || a:path[:0] is# '/') ? 'file://' : '') + \ . (l:has_drive_letter ? '/' . a:path[:2] : '') + \ . ale#uri#Encode(l:has_drive_letter ? a:path[3:] : a:path), + \ '\\', + \ '/', + \ 'g', + \) +endfunction + +function! ale#path#FromFileURI(uri) abort + if a:uri[:6] is? 'file://' + let l:encoded_path = a:uri[7:] + elseif a:uri[:4] is? 'file:' + let l:encoded_path = a:uri[5:] + else + let l:encoded_path = a:uri + endif + + let l:path = ale#uri#Decode(l:encoded_path) + + " If the path is like /C:/foo/bar, it should be C:\foo\bar instead. + if has('win32') && l:path =~# '^/[a-zA-Z][:|]' + let l:path = substitute(l:path[1:], '/', '\\', 'g') + let l:path = l:path[0] . ':' . l:path[2:] + endif + + return l:path +endfunction diff --git a/sources_non_forked/ale/autoload/ale/pattern_options.vim b/sources_non_forked/ale/autoload/ale/pattern_options.vim new file mode 100644 index 00000000..14e2142d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/pattern_options.vim @@ -0,0 +1,47 @@ +" Author: w0rp +" Description: Set options in files based on regex patterns. + +" These variables are used to cache the sorting of patterns below. +let s:last_pattern_options = {} +let s:sorted_items = [] + +function! s:CmpPatterns(left_item, right_item) abort + if a:left_item[0] < a:right_item[0] + return -1 + endif + + if a:left_item[0] > a:right_item[0] + return 1 + endif + + return 0 +endfunction + +function! ale#pattern_options#SetOptions(buffer) abort + let l:pattern_options = get(g:, 'ale_pattern_options', {}) + + if empty(l:pattern_options) + " Stop if no options are set. + return + endif + + " The items will only be sorted whenever the patterns change. + if l:pattern_options != s:last_pattern_options + let s:last_pattern_options = deepcopy(l:pattern_options) + " The patterns are sorted, so they are applied consistently. + let s:sorted_items = sort( + \ items(l:pattern_options), + \ function('s:CmpPatterns') + \) + endif + + let l:filename = expand('#' . a:buffer . ':p') + + for [l:pattern, l:options] in s:sorted_items + if match(l:filename, l:pattern) >= 0 + for [l:key, l:value] in items(l:options) + call setbufvar(a:buffer, l:key, l:value) + endfor + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/powershell.vim b/sources_non_forked/ale/autoload/ale/powershell.vim new file mode 100644 index 00000000..8c163206 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/powershell.vim @@ -0,0 +1,32 @@ +" Author: zigford +" Description: Functions for integrating with Powershell linters. + +" Write a powershell script to a temp file for execution +" return the command used to execute it +function! s:TemporaryPSScript(buffer, input) abort + let l:filename = 'script.ps1' + " Create a temp dir to house our temp .ps1 script + " a temp dir is needed as powershell needs the .ps1 + " extension + let l:tempdir = ale#util#Tempname() . (has('win32') ? '\' : '/') + let l:tempscript = l:tempdir . l:filename + " Create the temporary directory for the file, unreadable by 'other' + " users. + call mkdir(l:tempdir, '', 0750) + " Automatically delete the directory later. + call ale#command#ManageDirectory(a:buffer, l:tempdir) + " Write the script input out to a file. + call ale#util#Writefile(a:buffer, a:input, l:tempscript) + + return l:tempscript +endfunction + +function! ale#powershell#RunPowerShell(buffer, base_var_name, command) abort + let l:executable = ale#Var(a:buffer, a:base_var_name . '_executable') + let l:tempscript = s:TemporaryPSScript(a:buffer, a:command) + + return ale#Escape(l:executable) + \ . ' -Exe Bypass -NoProfile -File ' + \ . ale#Escape(l:tempscript) + \ . ' %t' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/preview.vim b/sources_non_forked/ale/autoload/ale/preview.vim new file mode 100644 index 00000000..1aca03ea --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/preview.vim @@ -0,0 +1,137 @@ +" Author: w0rp +" Description: Preview windows for showing whatever information in. + +if !has_key(s:, 'last_list') + let s:last_list = [] +endif + +if !has_key(s:, 'last_options') + let s:last_options = {} +endif + +function! ale#preview#SetLastSelection(item_list, options) abort + let s:last_list = a:item_list + let s:last_options = { + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), + \ 'use_relative_paths': get(a:options, 'use_relative_paths', 0), + \} +endfunction + +" Open a preview window and show some lines in it. +" A second argument can be passed as a Dictionary with options. They are... +" +" filetype - The filetype to use, defaulting to 'ale-preview' +" stay_here - If 1, stay in the window you came from. +function! ale#preview#Show(lines, ...) abort + let l:options = get(a:000, 0, {}) + + silent pedit ALEPreviewWindow + wincmd P + + setlocal modifiable + setlocal noreadonly + setlocal nobuflisted + setlocal buftype=nofile + setlocal bufhidden=wipe + :%d + call setline(1, a:lines) + setlocal nomodifiable + setlocal readonly + let &l:filetype = get(l:options, 'filetype', 'ale-preview') + + for l:command in get(l:options, 'commands', []) + call execute(l:command) + endfor + + if get(l:options, 'stay_here') + wincmd p + endif +endfunction + +" Close the preview window if the filetype matches the given one. +function! ale#preview#CloseIfTypeMatches(filetype) abort + for l:win in getwininfo() + let l:wintype = gettabwinvar(l:win.tabnr, l:win.winnr, '&filetype') + + if l:wintype is# a:filetype + silent! pclose! + endif + endfor +endfunction + +" Show a location selection preview window, given some items. +" Each item should have 'filename', 'line', and 'column' keys. +function! ale#preview#ShowSelection(item_list, ...) abort + let l:options = get(a:000, 0, {}) + let l:sep = has('win32') ? '\' : '/' + let l:lines = [] + + " Create lines to display to users. + for l:item in a:item_list + let l:match = get(l:item, 'match', '') + let l:filename = l:item.filename + + if get(l:options, 'use_relative_paths') + let l:cwd = getcwd() " no-custom-checks + let l:filename = substitute(l:filename, '^' . l:cwd . l:sep, '', '') + endif + + call add( + \ l:lines, + \ l:filename + \ . ':' . l:item.line + \ . ':' . l:item.column + \ . (!empty(l:match) ? ' ' . l:match : ''), + \) + endfor + + call ale#preview#Show(l:lines, {'filetype': 'ale-preview-selection'}) + let b:ale_preview_item_list = a:item_list + let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer') + + " Jump to an index for a previous selection, if set. + if has_key(l:options, 'jump_to_index') + let l:pos = getpos('.') + let l:pos[1] = l:options.jump_to_index + 1 + call setpos('.', l:pos) + endif + + " Remember preview state, so we can repeat it later. + call ale#preview#SetLastSelection(a:item_list, l:options) +endfunction + +function! ale#preview#RepeatSelection() abort + if !empty(s:last_list) + call ale#preview#ShowSelection(s:last_list, s:last_options) + endif +endfunction + +function! s:Open(open_in) abort + let l:item_list = get(b:, 'ale_preview_item_list', []) + let l:index = getpos('.')[1] - 1 + let l:item = get(l:item_list, l:index, {}) + + if empty(l:item) + return + endif + + " Remember an index to jump to when repeating a selection. + let s:last_options.jump_to_index = l:index + + :q! + + call ale#util#Open( + \ l:item.filename, + \ l:item.line, + \ l:item.column, + \ {'open_in': a:open_in}, + \) +endfunction + +function! ale#preview#OpenSelection() abort + call s:Open(b:ale_preview_item_open_in) +endfunction + +function! ale#preview#OpenSelectionInTab() abort + call s:Open('tab') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/python.vim b/sources_non_forked/ale/autoload/ale/python.vim new file mode 100644 index 00000000..7a998414 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/python.vim @@ -0,0 +1,170 @@ +" Author: w0rp +" Description: Functions for integrating with Python linters. + +call ale#Set('python_auto_pipenv', '0') +call ale#Set('python_auto_poetry', '0') + +let s:sep = has('win32') ? '\' : '/' +" bin is used for Unix virtualenv directories, and Scripts is for Windows. +let s:bin_dir = has('unix') ? 'bin' : 'Scripts' +let g:ale_virtualenv_dir_names = get(g:, 'ale_virtualenv_dir_names', [ +\ '.env', +\ '.venv', +\ 'env', +\ 've-py3', +\ 've', +\ 'virtualenv', +\ 'venv', +\]) + +function! ale#python#FindProjectRootIni(buffer) abort + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + " If you change this, update ale-python-root documentation. + if filereadable(l:path . '/MANIFEST.in') + \|| filereadable(l:path . '/setup.cfg') + \|| filereadable(l:path . '/pytest.ini') + \|| filereadable(l:path . '/tox.ini') + \|| filereadable(l:path . '/.pyre_configuration.local') + \|| filereadable(l:path . '/mypy.ini') + \|| filereadable(l:path . '/.mypy.ini') + \|| filereadable(l:path . '/pycodestyle.cfg') + \|| filereadable(l:path . '/.flake8') + \|| filereadable(l:path . '/.flake8rc') + \|| filereadable(l:path . '/pylama.ini') + \|| filereadable(l:path . '/pylintrc') + \|| filereadable(l:path . '/.pylintrc') + \|| filereadable(l:path . '/pyrightconfig.json') + \|| filereadable(l:path . '/pyrightconfig.toml') + \|| filereadable(l:path . '/Pipfile') + \|| filereadable(l:path . '/Pipfile.lock') + \|| filereadable(l:path . '/poetry.lock') + \|| filereadable(l:path . '/pyproject.toml') + \|| filereadable(l:path . '/.tool-versions') + return l:path + endif + endfor + + return '' +endfunction + +" Given a buffer number, find the project root directory for Python. +" The root directory is defined as the first directory found while searching +" upwards through paths, including the current directory, until a path +" containing an init file (one from MANIFEST.in, setup.cfg, pytest.ini, +" tox.ini) is found. If it is not possible to find the project root directory +" via init file, then it will be defined as the first directory found +" searching upwards through paths, including the current directory, until no +" __init__.py files is found. +function! ale#python#FindProjectRoot(buffer) abort + let l:ini_root = ale#python#FindProjectRootIni(a:buffer) + + if !empty(l:ini_root) + return l:ini_root + endif + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + if !filereadable(l:path . '/__init__.py') + return l:path + endif + endfor + + return '' +endfunction + +" Given a buffer number, find a virtualenv path for Python. +function! ale#python#FindVirtualenv(buffer) abort + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + " Skip empty path components returned in MSYS. + if empty(l:path) + continue + endif + + for l:dirname in ale#Var(a:buffer, 'virtualenv_dir_names') + let l:venv_dir = ale#path#Simplify( + \ join([l:path, l:dirname], s:sep) + \) + let l:script_filename = ale#path#Simplify( + \ join([l:venv_dir, s:bin_dir, 'activate'], s:sep) + \) + + if filereadable(l:script_filename) + return l:venv_dir + endif + endfor + endfor + + return $VIRTUAL_ENV +endfunction + +" Given a buffer number and a command name, find the path to the executable. +" First search on a virtualenv for Python, if nothing is found, try the global +" command. Returns an empty string if cannot find the executable +function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort + if ale#Var(a:buffer, a:base_var_name . '_use_global') + return ale#Var(a:buffer, a:base_var_name . '_executable') + endif + + let l:virtualenv = ale#python#FindVirtualenv(a:buffer) + + if !empty(l:virtualenv) + for l:path in a:path_list + let l:ve_executable = ale#path#Simplify( + \ join([l:virtualenv, s:bin_dir, l:path], s:sep) + \) + + if executable(l:ve_executable) + return l:ve_executable + endif + endfor + endif + + return ale#Var(a:buffer, a:base_var_name . '_executable') +endfunction + +" Handle traceback.print_exception() output starting in the first a:limit lines. +function! ale#python#HandleTraceback(lines, limit) abort + let l:nlines = len(a:lines) + let l:limit = a:limit > l:nlines ? l:nlines : a:limit + let l:start = 0 + + while l:start < l:limit + if a:lines[l:start] is# 'Traceback (most recent call last):' + break + endif + + let l:start += 1 + endwhile + + if l:start >= l:limit + return [] + endif + + let l:end = l:start + 1 + + " Traceback entries are always prefixed with 2 spaces. + " SyntaxError marker (if present) is prefixed with at least 4 spaces. + " Final exc line starts with exception class name (never a space). + while l:end < l:nlines && a:lines[l:end][0] is# ' ' + let l:end += 1 + endwhile + + let l:exc_line = l:end < l:nlines + \ ? a:lines[l:end] + \ : 'An exception was thrown.' + + return [{ + \ 'lnum': 1, + \ 'text': l:exc_line . ' (See :ALEDetail)', + \ 'detail': join(a:lines[(l:start):(l:end)], "\n"), + \}] +endfunction + +" Detects whether a pipenv environment is present. +function! ale#python#PipenvPresent(buffer) abort + return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' +endfunction + +" Detects whether a poetry environment is present. +function! ale#python#PoetryPresent(buffer) abort + return findfile('poetry.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# '' +endfunction diff --git a/sources_non_forked/ale/autoload/ale/racket.vim b/sources_non_forked/ale/autoload/ale/racket.vim new file mode 100644 index 00000000..ff896108 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/racket.vim @@ -0,0 +1,12 @@ +function! ale#racket#FindProjectRoot(buffer) abort + let l:cwd = expand('#' . a:buffer . ':p:h') + let l:highest_init = l:cwd + + for l:path in ale#path#Upwards(l:cwd) + if filereadable(l:path.'/init.rkt') + let l:highest_init = l:path + endif + endfor + + return l:highest_init +endfunction diff --git a/sources_non_forked/ale/autoload/ale/references.vim b/sources_non_forked/ale/autoload/ale/references.vim new file mode 100644 index 00000000..c32663fe --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/references.vim @@ -0,0 +1,187 @@ +let g:ale_default_navigation = get(g:, 'ale_default_navigation', 'buffer') + +let s:references_map = {} + +" Used to get the references map in tests. +function! ale#references#GetMap() abort + return deepcopy(s:references_map) +endfunction + +" Used to set the references map in tests. +function! ale#references#SetMap(map) abort + let s:references_map = a:map +endfunction + +function! ale#references#ClearLSPData() abort + let s:references_map = {} +endfunction + +function! ale#references#FormatTSResponseItem(response_item, options) abort + if get(a:options, 'open_in') is# 'quickfix' + return { + \ 'filename': a:response_item.file, + \ 'lnum': a:response_item.start.line, + \ 'col': a:response_item.start.offset, + \} + else + return { + \ 'filename': a:response_item.file, + \ 'line': a:response_item.start.line, + \ 'column': a:response_item.start.offset, + \ 'match': substitute(a:response_item.lineText, '^\s*\(.\{-}\)\s*$', '\1', ''), + \} + endif +endfunction + +function! ale#references#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') is# 'references' + \&& has_key(s:references_map, a:response.request_seq) + let l:options = remove(s:references_map, a:response.request_seq) + + if get(a:response, 'success', v:false) is v:true + let l:item_list = [] + + for l:response_item in a:response.body.refs + call add( + \ l:item_list, + \ ale#references#FormatTSResponseItem(l:response_item, l:options) + \) + endfor + + if empty(l:item_list) + call ale#util#Execute('echom ''No references found.''') + else + if get(l:options, 'open_in') is# 'quickfix' + call setqflist([], 'r') + call setqflist(l:item_list, 'a') + call ale#util#Execute('cc 1') + else + call ale#preview#ShowSelection(l:item_list, l:options) + endif + endif + endif + endif +endfunction + +function! ale#references#FormatLSPResponseItem(response_item, options) abort + if get(a:options, 'open_in') is# 'quickfix' + return { + \ 'filename': ale#util#ToResource(a:response_item.uri), + \ 'lnum': a:response_item.range.start.line + 1, + \ 'col': a:response_item.range.start.character + 1, + \} + else + return { + \ 'filename': ale#util#ToResource(a:response_item.uri), + \ 'line': a:response_item.range.start.line + 1, + \ 'column': a:response_item.range.start.character + 1, + \} + endif +endfunction + +function! ale#references#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:references_map, a:response.id) + let l:options = remove(s:references_map, a:response.id) + + " The result can be a Dictionary item, a List of the same, or null. + let l:result = get(a:response, 'result', []) + let l:item_list = [] + + if type(l:result) is v:t_list + for l:response_item in l:result + call add(l:item_list, + \ ale#references#FormatLSPResponseItem(l:response_item, l:options) + \) + endfor + endif + + if empty(l:item_list) + call ale#util#Execute('echom ''No references found.''') + else + if get(l:options, 'open_in') is# 'quickfix' + call setqflist([], 'r') + call setqflist(l:item_list, 'a') + call ale#util#Execute('cc 1') + else + call ale#preview#ShowSelection(l:item_list, l:options) + endif + endif + endif +endfunction + +function! s:OnReady(line, column, options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'references') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#references#HandleTSServerResponse') + \ : function('ale#references#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#References( + \ l:buffer, + \ a:line, + \ a:column + \) + else + " Send a message saying the buffer has changed first, or the + " references position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:message = ale#lsp#message#References(l:buffer, a:line, a:column) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:references_map[l:request_id] = { + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0, + \ 'open_in': get(a:options, 'open_in', 'current-buffer'), + \} +endfunction + +function! ale#references#Find(...) abort + let l:options = {} + + if len(a:000) > 0 + for l:option in a:000 + if l:option is? '-relative' + let l:options.use_relative_paths = 1 + elseif l:option is? '-tab' + let l:options.open_in = 'tab' + elseif l:option is? '-split' + let l:options.open_in = 'split' + elseif l:option is? '-vsplit' + let l:options.open_in = 'vsplit' + elseif l:option is? '-quickfix' + let l:options.open_in = 'quickfix' + endif + endfor + endif + + if !has_key(l:options, 'open_in') + let l:default_navigation = ale#Var(bufnr(''), 'default_navigation') + + if index(['tab', 'split', 'vsplit'], l:default_navigation) >= 0 + let l:options.open_in = l:default_navigation + endif + endif + + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + let l:column = min([l:column, len(getline(l:line))]) + let l:Callback = function('s:OnReady', [l:line, l:column, l:options]) + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/rename.vim b/sources_non_forked/ale/autoload/ale/rename.vim new file mode 100644 index 00000000..a722cc94 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/rename.vim @@ -0,0 +1,210 @@ +" Author: Jerko Steiner +" Description: Rename symbol support for LSP / tsserver + +let s:rename_map = {} + +" Used to get the rename map in tests. +function! ale#rename#GetMap() abort + return deepcopy(s:rename_map) +endfunction + +" Used to set the rename map in tests. +function! ale#rename#SetMap(map) abort + let s:rename_map = a:map +endfunction + +function! ale#rename#ClearLSPData() abort + let s:rename_map = {} +endfunction + +let g:ale_rename_tsserver_find_in_comments = get(g:, 'ale_rename_tsserver_find_in_comments') +let g:ale_rename_tsserver_find_in_strings = get(g:, 'ale_rename_tsserver_find_in_strings') + +function! s:message(message) abort + call ale#util#Execute('echom ' . string(a:message)) +endfunction + +function! ale#rename#HandleTSServerResponse(conn_id, response) abort + if get(a:response, 'command', '') isnot# 'rename' + return + endif + + if !has_key(s:rename_map, a:response.request_seq) + return + endif + + let l:options = remove(s:rename_map, a:response.request_seq) + + let l:old_name = l:options.old_name + let l:new_name = l:options.new_name + + if get(a:response, 'success', v:false) is v:false + let l:message = get(a:response, 'message', 'unknown') + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name + \ . '". Reason: ' . l:message) + + return + endif + + let l:changes = [] + + for l:response_item in a:response.body.locs + let l:filename = l:response_item.file + let l:text_changes = [] + + for l:loc in l:response_item.locs + call add(l:text_changes, { + \ 'start': { + \ 'line': l:loc.start.line, + \ 'offset': l:loc.start.offset, + \ }, + \ 'end': { + \ 'line': l:loc.end.line, + \ 'offset': l:loc.end.offset, + \ }, + \ 'newText': l:new_name, + \}) + endfor + + call add(l:changes, { + \ 'fileName': l:filename, + \ 'textChanges': l:text_changes, + \}) + endfor + + if empty(l:changes) + call s:message('Error renaming "' . l:old_name . '" to: "' . l:new_name . '"') + + return + endif + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': !&hidden, + \ }, + \) +endfunction + +function! ale#rename#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:rename_map, a:response.id) + let l:options = remove(s:rename_map, a:response.id) + + if !has_key(a:response, 'result') + call s:message('No rename result received from server') + + return + endif + + let l:changes_map = ale#code_action#GetChanges(a:response.result) + + if empty(l:changes_map) + call s:message('No changes received from server') + + return + endif + + let l:changes = ale#code_action#BuildChangesList(l:changes_map) + + call ale#code_action#HandleCodeAction( + \ { + \ 'description': 'rename', + \ 'changes': l:changes, + \ }, + \ { + \ 'conn_id': a:conn_id, + \ 'should_save': !&hidden, + \ }, + \) + endif +endfunction + +function! s:OnReady(line, column, options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'rename') + return + endif + + let l:buffer = a:lsp_details.buffer + + let l:Callback = a:linter.lsp is# 'tsserver' + \ ? function('ale#rename#HandleTSServerResponse') + \ : function('ale#rename#HandleLSPResponse') + + call ale#lsp#RegisterCallback(l:id, l:Callback) + + if a:linter.lsp is# 'tsserver' + let l:message = ale#lsp#tsserver_message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ g:ale_rename_tsserver_find_in_comments, + \ g:ale_rename_tsserver_find_in_strings, + \) + else + " Send a message saying the buffer has changed first, or the + " rename position probably won't make sense. + call ale#lsp#NotifyForChanges(l:id, l:buffer) + + let l:message = ale#lsp#message#Rename( + \ l:buffer, + \ a:line, + \ a:column, + \ a:options.new_name + \) + endif + + let l:request_id = ale#lsp#Send(l:id, l:message) + + let s:rename_map[l:request_id] = a:options +endfunction + +function! s:ExecuteRename(linter, options) abort + let l:buffer = bufnr('') + let [l:line, l:column] = getpos('.')[1:2] + + if a:linter.lsp isnot# 'tsserver' + let l:column = min([l:column, len(getline(l:line))]) + endif + + let l:Callback = function('s:OnReady', [l:line, l:column, a:options]) + call ale#lsp_linter#StartLSP(l:buffer, a:linter, l:Callback) +endfunction + +function! ale#rename#Execute() abort + let l:lsp_linters = [] + + for l:linter in ale#linter#Get(&filetype) + if !empty(l:linter.lsp) + call add(l:lsp_linters, l:linter) + endif + endfor + + if empty(l:lsp_linters) + call s:message('No active LSPs') + + return + endif + + let l:old_name = expand('') + let l:new_name = ale#util#Input('New name: ', l:old_name) + + if empty(l:new_name) + call s:message('New name cannot be empty!') + + return + endif + + for l:lsp_linter in l:lsp_linters + call s:ExecuteRename(l:lsp_linter, { + \ 'old_name': l:old_name, + \ 'new_name': l:new_name, + \}) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/ruby.vim b/sources_non_forked/ale/autoload/ale/ruby.vim new file mode 100644 index 00000000..d941bb2c --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/ruby.vim @@ -0,0 +1,83 @@ +" Author: Eddie Lebow https://github.com/elebow +" Description: Functions for integrating with Ruby tools + +" Find the nearest dir containing "app", "db", and "config", and assume it is +" the root of a Rails app. +function! ale#ruby#FindRailsRoot(buffer) abort + for l:name in ['app', 'config', 'db'] + let l:dir = fnamemodify( + \ ale#path#FindNearestDirectory(a:buffer, l:name), + \ ':h:h' + \) + + if l:dir isnot# '.' + \&& isdirectory(l:dir . '/app') + \&& isdirectory(l:dir . '/config') + \&& isdirectory(l:dir . '/db') + return l:dir + endif + endfor + + return '' +endfunction + +" Find the nearest dir containing a potential ruby project. +function! ale#ruby#FindProjectRoot(buffer) abort + let l:dir = ale#ruby#FindRailsRoot(a:buffer) + + if isdirectory(l:dir) + return l:dir + endif + + for l:name in ['.solargraph.yml', 'Rakefile', 'Gemfile'] + let l:dir = fnamemodify( + \ ale#path#FindNearestFile(a:buffer, l:name), + \ ':h' + \) + + if l:dir isnot# '.' && isdirectory(l:dir) + return l:dir + endif + endfor + + return '' +endfunction + +" Handle output from rubocop and linters that depend on it (e.b. standardrb) +function! ale#ruby#HandleRubocopOutput(buffer, lines) abort + try + let l:errors = json_decode(a:lines[0]) + catch + return [] + endtry + + if !has_key(l:errors, 'summary') + \|| l:errors['summary']['offense_count'] == 0 + \|| empty(l:errors['files']) + return [] + endif + + let l:output = [] + + for l:error in l:errors['files'][0]['offenses'] + let l:start_col = l:error['location']['column'] + 0 + call add(l:output, { + \ 'lnum': l:error['location']['line'] + 0, + \ 'col': l:start_col, + \ 'end_col': l:start_col + l:error['location']['length'] - 1, + \ 'code': l:error['cop_name'], + \ 'text': l:error['message'], + \ 'type': ale_linters#ruby#rubocop#GetType(l:error['severity']), + \}) + endfor + + return l:output +endfunction + +function! ale#ruby#EscapeExecutable(executable, bundle_exec) abort + let l:exec_args = a:executable =~? 'bundle' + \ ? ' exec ' . a:bundle_exec + \ : '' + + return ale#Escape(a:executable) . l:exec_args +endfunction diff --git a/sources_non_forked/ale/autoload/ale/semver.vim b/sources_non_forked/ale/autoload/ale/semver.vim new file mode 100644 index 00000000..e3eb49c0 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/semver.vim @@ -0,0 +1,78 @@ +let s:version_cache = {} + +" Reset the version cache used for parsing the version. +function! ale#semver#ResetVersionCache() abort + let s:version_cache = {} +endfunction + +function! ale#semver#ParseVersion(version_lines) abort + for l:line in a:version_lines + let l:match = matchlist(l:line, '\v(\d+)\.(\d+)(\.(\d+))?') + + if !empty(l:match) + return [l:match[1] + 0, l:match[2] + 0, l:match[4] + 0] + endif + endfor + + return [] +endfunction + +" Given an executable name and some lines of output, which can be empty, +" parse the version from the lines of output, or return the cached version +" triple [major, minor, patch] +" +" If the version cannot be found, an empty List will be returned instead. +function! s:GetVersion(executable, version_lines) abort + let l:version = get(s:version_cache, a:executable, []) + let l:parsed_version = ale#semver#ParseVersion(a:version_lines) + + if !empty(l:parsed_version) + let l:version = l:parsed_version + let s:version_cache[a:executable] = l:version + endif + + return l:version +endfunction + +function! ale#semver#RunWithVersionCheck(buffer, executable, command, Callback) abort + if empty(a:executable) + return '' + endif + + let l:cache = s:version_cache + + if has_key(s:version_cache, a:executable) + return a:Callback(a:buffer, s:version_cache[a:executable]) + endif + + return ale#command#Run( + \ a:buffer, + \ a:command, + \ {_, output -> a:Callback(a:buffer, s:GetVersion(a:executable, output))}, + \ {'output_stream': 'both', 'executable': a:executable} + \) +endfunction + +" Given two triples of integers [major, minor, patch], compare the triples +" and return 1 if the LHS is greater than or equal to the RHS. +" +" Pairs of [major, minor] can also be used for either argument. +" +" 0 will be returned if the LHS is an empty List. +function! ale#semver#GTE(lhs, rhs) abort + if empty(a:lhs) + return 0 + endif + + if a:lhs[0] > a:rhs[0] + return 1 + elseif a:lhs[0] == a:rhs[0] + if a:lhs[1] > a:rhs[1] + return 1 + elseif a:lhs[1] == a:rhs[1] + return get(a:lhs, 2) >= get(a:rhs, 2) + endif + endif + + return 0 +endfunction diff --git a/sources_non_forked/ale/autoload/ale/sign.vim b/sources_non_forked/ale/autoload/ale/sign.vim new file mode 100644 index 00000000..21e06313 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/sign.vim @@ -0,0 +1,496 @@ +scriptencoding utf8 +" Author: w0rp +" Description: Draws error and warning signs into signcolumn + +" This flag can be set to some integer to control the maximum number of signs +" that ALE will set. +let g:ale_max_signs = get(g:, 'ale_max_signs', -1) +" This flag can be set to 1 to enable changing the sign column colors when +" there are errors. +let g:ale_change_sign_column_color = get(g:, 'ale_change_sign_column_color', 0) +" These variables dictate what signs are used to indicate errors and warnings. +let g:ale_sign_error = get(g:, 'ale_sign_error', '>>') +let g:ale_sign_style_error = get(g:, 'ale_sign_style_error', g:ale_sign_error) +let g:ale_sign_warning = get(g:, 'ale_sign_warning', '--') +let g:ale_sign_style_warning = get(g:, 'ale_sign_style_warning', g:ale_sign_warning) +let g:ale_sign_info = get(g:, 'ale_sign_info', g:ale_sign_warning) +let g:ale_sign_priority = get(g:, 'ale_sign_priority', 30) +" This variable sets an offset which can be set for sign IDs. +" This ID can be changed depending on what IDs are set for other plugins. +" The dummy sign will use the ID exactly equal to the offset. +let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000) +" This flag can be set to 1 to keep sign gutter always open +let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0) +let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0) + +let s:supports_sign_groups = has('nvim-0.4.2') || has('patch-8.1.614') + +if !hlexists('ALEErrorSign') + highlight link ALEErrorSign error +endif + +if !hlexists('ALEStyleErrorSign') + highlight link ALEStyleErrorSign ALEErrorSign +endif + +if !hlexists('ALEWarningSign') + highlight link ALEWarningSign todo +endif + +if !hlexists('ALEStyleWarningSign') + highlight link ALEStyleWarningSign ALEWarningSign +endif + +if !hlexists('ALEInfoSign') + highlight link ALEInfoSign ALEWarningSign +endif + +if !hlexists('ALESignColumnWithErrors') + highlight link ALESignColumnWithErrors error +endif + +function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort + let l:verbose = &verbose + set verbose=0 + let l:output = execute('highlight SignColumn', 'silent') + let &verbose = l:verbose + + let l:highlight_syntax = join(split(l:output)[2:]) + let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$') + + if !empty(l:match) + execute 'highlight link ALESignColumnWithoutErrors ' . l:match[1] + elseif l:highlight_syntax isnot# 'cleared' + execute 'highlight ALESignColumnWithoutErrors ' . l:highlight_syntax + endif +endfunction + +if !hlexists('ALESignColumnWithoutErrors') + call ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() +endif + +" Spaces and backslashes need to be escaped for signs. +function! s:EscapeSignText(sign_text) abort + return substitute(substitute(a:sign_text, ' *$', '', ''), '\\\| ', '\\\0', 'g') +endfunction + +" Signs show up on the left for error markers. +execute 'sign define ALEErrorSign text=' . s:EscapeSignText(g:ale_sign_error) +\ . ' texthl=ALEErrorSign linehl=ALEErrorLine' +execute 'sign define ALEStyleErrorSign text=' . s:EscapeSignText(g:ale_sign_style_error) +\ . ' texthl=ALEStyleErrorSign linehl=ALEErrorLine' +execute 'sign define ALEWarningSign text=' . s:EscapeSignText(g:ale_sign_warning) +\ . ' texthl=ALEWarningSign linehl=ALEWarningLine' +execute 'sign define ALEStyleWarningSign text=' . s:EscapeSignText(g:ale_sign_style_warning) +\ . ' texthl=ALEStyleWarningSign linehl=ALEWarningLine' +execute 'sign define ALEInfoSign text=' . s:EscapeSignText(g:ale_sign_info) +\ . ' texthl=ALEInfoSign linehl=ALEInfoLine' +sign define ALEDummySign text=\ texthl=SignColumn + +if g:ale_sign_highlight_linenrs && has('nvim-0.3.2') + if !hlexists('ALEErrorSignLineNr') + highlight link ALEErrorSignLineNr CursorLineNr + endif + + if !hlexists('ALEStyleErrorSignLineNr') + highlight link ALEStyleErrorSignLineNr CursorLineNr + endif + + if !hlexists('ALEWarningSignLineNr') + highlight link ALEWarningSignLineNr CursorLineNr + endif + + if !hlexists('ALEStyleWarningSignLineNr') + highlight link ALEStyleWarningSignLineNr CursorLineNr + endif + + if !hlexists('ALEInfoSignLineNr') + highlight link ALEInfoSignLineNr CursorLineNr + endif + + sign define ALEErrorSign numhl=ALEErrorSignLineNr + sign define ALEStyleErrorSign numhl=ALEStyleErrorSignLineNr + sign define ALEWarningSign numhl=ALEWarningSignLineNr + sign define ALEStyleWarningSign numhl=ALEStyleWarningSignLineNr + sign define ALEInfoSign numhl=ALEInfoSignLineNr +endif + +function! ale#sign#GetSignName(sublist) abort + let l:priority = g:ale#util#style_warning_priority + + " Determine the highest priority item for the line. + for l:item in a:sublist + let l:item_priority = ale#util#GetItemPriority(l:item) + + if l:item_priority > l:priority + let l:priority = l:item_priority + endif + endfor + + if l:priority is# g:ale#util#error_priority + return 'ALEErrorSign' + endif + + if l:priority is# g:ale#util#warning_priority + return 'ALEWarningSign' + endif + + if l:priority is# g:ale#util#style_error_priority + return 'ALEStyleErrorSign' + endif + + if l:priority is# g:ale#util#style_warning_priority + return 'ALEStyleWarningSign' + endif + + if l:priority is# g:ale#util#info_priority + return 'ALEInfoSign' + endif + + " Use the error sign for invalid severities. + return 'ALEErrorSign' +endfunction + +function! s:PriorityCmd() abort + if s:supports_sign_groups + return ' priority=' . g:ale_sign_priority . ' ' + else + return '' + endif +endfunction + +function! s:GroupCmd() abort + if s:supports_sign_groups + return ' group=ale ' + else + return ' ' + endif +endfunction + +" Read sign data for a buffer to a list of lines. +function! ale#sign#ReadSigns(buffer) abort + let l:output = execute( + \ 'sign place ' . s:GroupCmd() . s:PriorityCmd() + \ . ' buffer=' . a:buffer + \ ) + + return split(l:output, "\n") +endfunction + +function! ale#sign#ParsePattern() abort + if s:supports_sign_groups + " Matches output like : + " line=4 id=1 group=ale name=ALEErrorSign + " строка=1 id=1000001 группа=ale имя=ALEErrorSign + " 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign + " línea=12 id=1000001 grupo=ale nombre=ALEWarningSign + " riga=1 id=1000001 gruppo=ale nome=ALEWarningSign + " Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=ale>.*\=(ALE[a-zA-Z]+Sign)' + else + " Matches output like : + " line=4 id=1 name=ALEErrorSign + " строка=1 id=1000001 имя=ALEErrorSign + " 行=1 識別子=1000001 名前=ALEWarningSign + " línea=12 id=1000001 nombre=ALEWarningSign + " riga=1 id=1000001 nome=ALEWarningSign + " Zeile=235 id=1000001 Name=ALEErrorSign + let l:pattern = '\v^.*\=(\d+).*\=(\d+).*\=(ALE[a-zA-Z]+Sign)' + endif + + return l:pattern +endfunction + +" Given a buffer number, return a List of placed signs [line, id, group] +function! ale#sign#ParseSignsWithGetPlaced(buffer) abort + let l:signs = sign_getplaced(a:buffer, { 'group': s:supports_sign_groups ? 'ale' : '' })[0].signs + let l:result = [] + let l:is_dummy_sign_set = 0 + + for l:sign in l:signs + if l:sign['name'] is# 'ALEDummySign' + let l:is_dummy_sign_set = 1 + else + call add(l:result, [ + \ str2nr(l:sign['lnum']), + \ str2nr(l:sign['id']), + \ l:sign['name'], + \]) + endif + endfor + + return [l:is_dummy_sign_set, l:result] +endfunction + +" Given a list of lines for sign output, return a List of [line, id, group] +function! ale#sign#ParseSigns(line_list) abort + let l:pattern =ale#sign#ParsePattern() + let l:result = [] + let l:is_dummy_sign_set = 0 + + for l:line in a:line_list + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) > 0 + if l:match[3] is# 'ALEDummySign' + let l:is_dummy_sign_set = 1 + else + call add(l:result, [ + \ str2nr(l:match[1]), + \ str2nr(l:match[2]), + \ l:match[3], + \]) + endif + endif + endfor + + return [l:is_dummy_sign_set, l:result] +endfunction + +function! ale#sign#FindCurrentSigns(buffer) abort + if exists('*sign_getplaced') + return ale#sign#ParseSignsWithGetPlaced(a:buffer) + else + let l:line_list = ale#sign#ReadSigns(a:buffer) + + return ale#sign#ParseSigns(l:line_list) + endif +endfunction + +" Given a loclist, group the List into with one List per line. +function! s:GroupLoclistItems(buffer, loclist) abort + let l:grouped_items = [] + let l:last_lnum = -1 + + for l:obj in a:loclist + if l:obj.bufnr != a:buffer + continue + endif + + " Create a new sub-List when we hit a new line. + if l:obj.lnum != l:last_lnum + call add(l:grouped_items, []) + endif + + call add(l:grouped_items[-1], l:obj) + let l:last_lnum = l:obj.lnum + endfor + + return l:grouped_items +endfunction + +function! s:UpdateLineNumbers(buffer, current_sign_list, loclist) abort + let l:line_map = {} + let l:line_numbers_changed = 0 + + for [l:line, l:sign_id, l:name] in a:current_sign_list + let l:line_map[l:sign_id] = l:line + endfor + + for l:item in a:loclist + if l:item.bufnr == a:buffer + let l:lnum = get(l:line_map, get(l:item, 'sign_id', 0), 0) + + if l:lnum && l:item.lnum != l:lnum + let l:item.lnum = l:lnum + let l:line_numbers_changed = 1 + endif + endif + endfor + + " When the line numbers change, sort the list again + if l:line_numbers_changed + call sort(a:loclist, 'ale#util#LocItemCompare') + endif +endfunction + +function! s:BuildSignMap(buffer, current_sign_list, grouped_items) abort + let l:max_signs = ale#Var(a:buffer, 'max_signs') + + if l:max_signs is 0 + let l:selected_grouped_items = [] + elseif type(l:max_signs) is v:t_number && l:max_signs > 0 + let l:selected_grouped_items = a:grouped_items[:l:max_signs - 1] + else + let l:selected_grouped_items = a:grouped_items + endif + + let l:sign_map = {} + let l:sign_offset = g:ale_sign_offset + + for [l:line, l:sign_id, l:name] in a:current_sign_list + let l:sign_info = get(l:sign_map, l:line, { + \ 'current_id_list': [], + \ 'current_name_list': [], + \ 'new_id': 0, + \ 'new_name': '', + \ 'items': [], + \}) + + " Increment the sign offset for new signs, by the maximum sign ID. + if l:sign_id > l:sign_offset + let l:sign_offset = l:sign_id + endif + + " Remember the sign names and IDs in separate Lists, so they are easy + " to work with. + call add(l:sign_info.current_id_list, l:sign_id) + call add(l:sign_info.current_name_list, l:name) + + let l:sign_map[l:line] = l:sign_info + endfor + + for l:group in l:selected_grouped_items + let l:line = l:group[0].lnum + let l:sign_info = get(l:sign_map, l:line, { + \ 'current_id_list': [], + \ 'current_name_list': [], + \ 'new_id': 0, + \ 'new_name': '', + \ 'items': [], + \}) + + let l:sign_info.new_name = ale#sign#GetSignName(l:group) + let l:sign_info.items = l:group + + let l:index = index( + \ l:sign_info.current_name_list, + \ l:sign_info.new_name + \) + + if l:index >= 0 + " We have a sign with this name already, so use the same ID. + let l:sign_info.new_id = l:sign_info.current_id_list[l:index] + else + " This sign name replaces the previous name, so use a new ID. + let l:sign_info.new_id = l:sign_offset + 1 + let l:sign_offset += 1 + endif + + let l:sign_map[l:line] = l:sign_info + endfor + + return l:sign_map +endfunction + +function! ale#sign#GetSignCommands(buffer, was_sign_set, sign_map) abort + let l:command_list = [] + let l:is_dummy_sign_set = a:was_sign_set + + " Set the dummy sign if we need to. + " The dummy sign is needed to keep the sign column open while we add + " and remove signs. + if !l:is_dummy_sign_set && (!empty(a:sign_map) || g:ale_sign_column_always) + call add(l:command_list, 'sign place ' + \ . g:ale_sign_offset + \ . s:GroupCmd() + \ . s:PriorityCmd() + \ . ' line=1 name=ALEDummySign ' + \ . ' buffer=' . a:buffer + \) + let l:is_dummy_sign_set = 1 + endif + + " Place new items first. + for [l:line_str, l:info] in items(a:sign_map) + if l:info.new_id + " Save the sign IDs we are setting back on our loclist objects. + " These IDs will be used to preserve items which are set many times. + for l:item in l:info.items + let l:item.sign_id = l:info.new_id + endfor + + if index(l:info.current_id_list, l:info.new_id) < 0 + call add(l:command_list, 'sign place ' + \ . (l:info.new_id) + \ . s:GroupCmd() + \ . s:PriorityCmd() + \ . ' line=' . l:line_str + \ . ' name=' . (l:info.new_name) + \ . ' buffer=' . a:buffer + \) + endif + endif + endfor + + " Remove signs without new IDs. + for l:info in values(a:sign_map) + for l:current_id in l:info.current_id_list + if l:current_id isnot l:info.new_id + call add(l:command_list, 'sign unplace ' + \ . l:current_id + \ . s:GroupCmd() + \ . ' buffer=' . a:buffer + \) + endif + endfor + endfor + + " Remove the dummy sign to close the sign column if we need to. + if l:is_dummy_sign_set && !g:ale_sign_column_always + call add(l:command_list, 'sign unplace ' + \ . g:ale_sign_offset + \ . s:GroupCmd() + \ . ' buffer=' . a:buffer + \) + endif + + return l:command_list +endfunction + +" This function will set the signs which show up on the left. +function! ale#sign#SetSigns(buffer, loclist) abort + if !bufexists(str2nr(a:buffer)) + " Stop immediately when attempting to set signs for a buffer which + " does not exist. + return + endif + + " Find the current markers + let [l:is_dummy_sign_set, l:current_sign_list] = + \ ale#sign#FindCurrentSigns(a:buffer) + + " Update the line numbers for items from before which may have moved. + call s:UpdateLineNumbers(a:buffer, l:current_sign_list, a:loclist) + + " Group items after updating the line numbers. + let l:grouped_items = s:GroupLoclistItems(a:buffer, a:loclist) + + " Build a map of current and new signs, with the lines as the keys. + let l:sign_map = s:BuildSignMap( + \ a:buffer, + \ l:current_sign_list, + \ l:grouped_items, + \) + + let l:command_list = ale#sign#GetSignCommands( + \ a:buffer, + \ l:is_dummy_sign_set, + \ l:sign_map, + \) + + " Change the sign column color if the option is on. + if g:ale_change_sign_column_color && !empty(a:loclist) + highlight clear SignColumn + highlight link SignColumn ALESignColumnWithErrors + endif + + for l:command in l:command_list + silent! execute l:command + endfor + + " Reset the sign column color when there are no more errors. + if g:ale_change_sign_column_color && empty(a:loclist) + highlight clear SignColumn + highlight link SignColumn ALESignColumnWithoutErrors + endif +endfunction + +" Remove all signs. +function! ale#sign#Clear() abort + if s:supports_sign_groups + sign unplace group=ale * + else + sign unplace * + endif +endfunction diff --git a/sources_non_forked/ale/autoload/ale/socket.vim b/sources_non_forked/ale/autoload/ale/socket.vim new file mode 100644 index 00000000..61f11e70 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/socket.vim @@ -0,0 +1,151 @@ +" Author: w0rp +" Description: APIs for working with asynchronous sockets, with an API +" normalised between Vim 8 and NeoVim. Socket connections only work in NeoVim +" 0.3+, and silently do nothing in earlier NeoVim versions. +" +" Important functions are described below. They are: +" +" ale#socket#Open(address, options) -> channel_id (>= 0 if successful) +" ale#socket#IsOpen(channel_id) -> 1 if open, 0 otherwise +" ale#socket#Close(channel_id) +" ale#socket#Send(channel_id, data) +" ale#socket#GetAddress(channel_id) -> Return the address for a job + +let s:channel_map = get(s:, 'channel_map', {}) + +function! s:VimOutputCallback(channel, data) abort + let l:channel_id = ch_info(a:channel).id + + " Only call the callbacks for jobs which are valid. + if l:channel_id >= 0 && has_key(s:channel_map, l:channel_id) + call ale#util#GetFunction(s:channel_map[l:channel_id].callback)(l:channel_id, a:data) + endif +endfunction + +function! s:NeoVimOutputCallback(channel_id, data, event) abort + let l:info = s:channel_map[a:channel_id] + + if a:event is# 'data' + let l:info.last_line = ale#util#JoinNeovimOutput( + \ a:channel_id, + \ l:info.last_line, + \ a:data, + \ l:info.mode, + \ ale#util#GetFunction(l:info.callback), + \) + endif +endfunction + +" Open a socket for a given address. The following options are accepted: +" +" callback - A callback for receiving input. (required) +" +" A non-negative number representing a channel ID will be returned is the +" connection was successful. 0 is a valid channel ID in Vim, so test if the +" connection ID is >= 0. +function! ale#socket#Open(address, options) abort + let l:mode = get(a:options, 'mode', 'raw') + let l:Callback = a:options.callback + + let l:channel_info = { + \ 'address': a:address, + \ 'mode': l:mode, + \ 'callback': a:options.callback, + \} + + if !has('nvim') + " Vim + let l:channel_options = { + \ 'mode': l:mode, + \ 'waittime': 0, + \ 'callback': function('s:VimOutputCallback'), + \} + + " Use non-blocking writes for Vim versions that support the option. + if has('patch-8.1.350') + let l:channel_options.noblock = 1 + endif + + let l:channel_info.channel = ch_open(a:address, l:channel_options) + let l:vim_info = ch_info(l:channel_info.channel) + let l:channel_id = !empty(l:vim_info) ? l:vim_info.id : -1 + elseif exists('*chansend') && exists('*sockconnect') + " NeoVim 0.3+ + try + let l:channel_id = sockconnect(stridx(a:address, ':') != -1 ? 'tcp' : 'pipe', + \ a:address, {'on_data': function('s:NeoVimOutputCallback')}) + let l:channel_info.last_line = '' + catch /connection failed/ + let l:channel_id = -1 + endtry + + " 0 means the connection failed some times in NeoVim, so make the ID + " invalid to match Vim. + if l:channel_id is 0 + let l:channel_id = -1 + endif + + let l:channel_info.channel = l:channel_id + else + " Other Vim versions. + let l:channel_id = -1 + endif + + if l:channel_id >= 0 + let s:channel_map[l:channel_id] = l:channel_info + endif + + return l:channel_id +endfunction + +" Return 1 is a channel is open, 0 otherwise. +function! ale#socket#IsOpen(channel_id) abort + if !has_key(s:channel_map, a:channel_id) + return 0 + endif + + if has('nvim') + " In NeoVim, we have to check if this channel is in the global list. + return index(map(nvim_list_chans(), 'v:val.id'), a:channel_id) >= 0 + endif + + let l:channel = s:channel_map[a:channel_id].channel + + return ch_status(l:channel) is# 'open' +endfunction + +" Close a socket, if it's still open. +function! ale#socket#Close(channel_id) abort + " IsRunning isn't called here, so we don't check nvim_list_chans() + if !has_key(s:channel_map, a:channel_id) + return 0 + endif + + let l:channel = remove(s:channel_map, a:channel_id).channel + + if has('nvim') + silent! call chanclose(l:channel) + elseif ch_status(l:channel) is# 'open' + call ch_close(l:channel) + endif +endfunction + +" Send some data to a socket. +function! ale#socket#Send(channel_id, data) abort + if !has_key(s:channel_map, a:channel_id) + return + endif + + let l:channel = s:channel_map[a:channel_id].channel + + if has('nvim') + call chansend(l:channel, a:data) + else + call ch_sendraw(l:channel, a:data) + endif +endfunction + +" Get an address for a channel, or an empty string. +function! ale#socket#GetAddress(channel_id) abort + return get(get(s:channel_map, a:channel_id, {}), 'address', '') +endfunction diff --git a/sources_non_forked/ale/autoload/ale/statusline.vim b/sources_non_forked/ale/autoload/ale/statusline.vim new file mode 100644 index 00000000..6b93ba51 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/statusline.vim @@ -0,0 +1,135 @@ +" Author: KabbAmine +" Additions by: petpetpetpet +" Description: Statusline related function(s) + +function! s:CreateCountDict() abort + " Keys 0 and 1 are for backwards compatibility. + " The count object used to be a List of [error_count, warning_count]. + return { + \ '0': 0, + \ '1': 0, + \ 'error': 0, + \ 'warning': 0, + \ 'info': 0, + \ 'style_error': 0, + \ 'style_warning': 0, + \ 'total': 0, + \} +endfunction + +" Update the buffer error/warning count with data from loclist. +function! ale#statusline#Update(buffer, loclist) abort + if !exists('g:ale_buffer_info') || !has_key(g:ale_buffer_info, a:buffer) + return + endif + + let l:loclist = filter(copy(a:loclist), 'v:val.bufnr == a:buffer') + let l:count = s:CreateCountDict() + let l:count.total = len(l:loclist) + + " Allows easy access to the first instance of each problem type. + let l:first_problems = {} + + for l:entry in l:loclist + if l:entry.type is# 'W' + if get(l:entry, 'sub_type', '') is# 'style' + let l:count.style_warning += 1 + + if l:count.style_warning == 1 + let l:first_problems.style_warning = l:entry + endif + else + let l:count.warning += 1 + + if l:count.warning == 1 + let l:first_problems.warning = l:entry + endif + endif + elseif l:entry.type is# 'I' + let l:count.info += 1 + + if l:count.info == 1 + let l:first_problems.info = l:entry + endif + elseif get(l:entry, 'sub_type', '') is# 'style' + let l:count.style_error += 1 + + if l:count.style_error == 1 + let l:first_problems.style_error = l:entry + endif + else + let l:count.error += 1 + + if l:count.error == 1 + let l:first_problems.error = l:entry + endif + endif + endfor + + " Set keys for backwards compatibility. + let l:count[0] = l:count.error + l:count.style_error + let l:count[1] = l:count.total - l:count[0] + + let g:ale_buffer_info[a:buffer].count = l:count + let g:ale_buffer_info[a:buffer].first_problems = l:first_problems +endfunction + +" Get the counts for the buffer, and update the counts if needed. +function! s:UpdateCacheIfNecessary(buffer) abort + " Cache is cold, so manually ask for an update. + if !has_key(g:ale_buffer_info[a:buffer], 'count') + call ale#statusline#Update( + \ a:buffer, + \ g:ale_buffer_info[a:buffer].loclist + \) + endif +endfunction + +function! s:BufferCacheExists(buffer) abort + if !exists('g:ale_buffer_info') || !has_key(g:ale_buffer_info, a:buffer) + return 0 + endif + + return 1 +endfunction + +" Get the counts for the buffer, and update the counts if needed. +function! s:GetCounts(buffer) abort + if !s:BufferCacheExists(a:buffer) + return s:CreateCountDict() + endif + + call s:UpdateCacheIfNecessary(a:buffer) + + return g:ale_buffer_info[a:buffer].count +endfunction + +" Get the dict of first_problems, update the buffer info cache if necessary. +function! s:GetFirstProblems(buffer) abort + if !s:BufferCacheExists(a:buffer) + return {} + endif + + call s:UpdateCacheIfNecessary(a:buffer) + + return g:ale_buffer_info[a:buffer].first_problems +endfunction + +" Returns a Dictionary with counts for use in third party integrations. +function! ale#statusline#Count(buffer) abort + " The Dictionary is copied here before exposing it to other plugins. + return copy(s:GetCounts(a:buffer)) +endfunction + +" Returns a copy of the *first* locline instance of the specified problem +" type. (so this would allow an external integration to know all the info +" about the first style warning in the file, for example.) +function! ale#statusline#FirstProblem(buffer, type) abort + let l:first_problems = s:GetFirstProblems(a:buffer) + + if !empty(l:first_problems) && has_key(l:first_problems, a:type) + return copy(l:first_problems[a:type]) + endif + + return {} +endfunction diff --git a/sources_non_forked/ale/autoload/ale/swift.vim b/sources_non_forked/ale/autoload/ale/swift.vim new file mode 100644 index 00000000..3232d42a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/swift.vim @@ -0,0 +1,70 @@ +" Author: Dan Loman +" Description: Functions for integrating with Swift tools + +" Find the nearest dir containing a Package.swift file and assume it is the root of the Swift project. +function! ale#swift#FindProjectRoot(buffer) abort + let l:swift_config = ale#path#FindNearestFile(a:buffer, 'Package.swift') + + if !empty(l:swift_config) + return fnamemodify(l:swift_config, ':h') + endif + + return '' +endfunction + +" Support Apple Swift Format {{{1 + +call ale#Set('swift_appleswiftformat_executable', 'swift-format') +call ale#Set('swift_appleswiftformat_use_swiftpm', 0) + +" Return the executable depending on whether or not to use Swift Package Manager. +" +" If not asked to use Swift Package Manager (use_swiftpm = 0), the returned +" value is the global executable, else the returned value is 'swift' because +" the final command line will be `swift run swift-format ...`. +" +" Failure is expected if use_swiftpm is `1` but no Package.swift can be located. +function! ale#swift#GetAppleSwiftFormatExecutable(buffer) abort + if !ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + return ale#Var(a:buffer, 'swift_appleswiftformat_executable') + endif + + if ale#path#FindNearestFile(a:buffer, 'Package.swift') is# '' + " If there is no Package.swift file, we don't use swift-format even if it exists, + " so we return '' to indicate failure. + return '' + endif + + return 'swift' +endfunction + +" Return the command depending on whether or not to use Swift Package Manager. +" +" If asked to use Swift Package Manager (use_swiftpm = 1), the command +" arguments are prefixed with 'swift run'. +" +" In either case, the configuration file is located and added to the command. +function! ale#swift#GetAppleSwiftFormatCommand(buffer) abort + let l:executable = ale#swift#GetAppleSwiftFormatExecutable(a:buffer) + let l:command_args = '' + + if ale#Var(a:buffer, 'swift_appleswiftformat_use_swiftpm') + let l:command_args = ' ' . 'run swift-format' + endif + + return ale#Escape(l:executable) . l:command_args +endfunction + +" Locate the nearest '.swift-format' configuration file, and return the +" arguments, else return an empty string. +function! ale#swift#GetAppleSwiftFormatConfigArgs(buffer) abort + let l:config_filepath = ale#path#FindNearestFile(a:buffer, '.swift-format') + + if l:config_filepath isnot# '' + return '--configuration' . ' ' . l:config_filepath + endif + + return '' +endfunction + +" }}} diff --git a/sources_non_forked/ale/autoload/ale/symbol.vim b/sources_non_forked/ale/autoload/ale/symbol.vim new file mode 100644 index 00000000..6c65f1b2 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/symbol.vim @@ -0,0 +1,110 @@ +let s:symbol_map = {} + +" Used to get the symbol map in tests. +function! ale#symbol#GetMap() abort + return deepcopy(s:symbol_map) +endfunction + +" Used to set the symbol map in tests. +function! ale#symbol#SetMap(map) abort + let s:symbol_map = a:map +endfunction + +function! ale#symbol#ClearLSPData() abort + let s:symbol_map = {} +endfunction + +function! ale#symbol#HandleLSPResponse(conn_id, response) abort + if has_key(a:response, 'id') + \&& has_key(s:symbol_map, a:response.id) + let l:options = remove(s:symbol_map, a:response.id) + + let l:result = get(a:response, 'result', v:null) + let l:item_list = [] + + if type(l:result) is v:t_list + " Each item looks like this: + " { + " 'name': 'foo', + " 'kind': 123, + " 'deprecated': v:false, + " 'location': { + " 'uri': 'file://...', + " 'range': { + " 'start': {'line': 0, 'character': 0}, + " 'end': {'line': 0, 'character': 0}, + " }, + " }, + " 'containerName': 'SomeContainer', + " } + for l:response_item in l:result + let l:location = l:response_item.location + + call add(l:item_list, { + \ 'filename': ale#util#ToResource(l:location.uri), + \ 'line': l:location.range.start.line + 1, + \ 'column': l:location.range.start.character + 1, + \ 'match': l:response_item.name, + \}) + endfor + endif + + if empty(l:item_list) + call ale#util#Execute('echom ''No symbols found.''') + else + call ale#preview#ShowSelection(l:item_list, l:options) + endif + endif +endfunction + +function! s:OnReady(query, options, linter, lsp_details) abort + let l:id = a:lsp_details.connection_id + + if !ale#lsp#HasCapability(l:id, 'symbol_search') + return + endif + + let l:buffer = a:lsp_details.buffer + + " If we already made a request, stop here. + if getbufvar(l:buffer, 'ale_symbol_request_made', 0) + return + endif + + let l:Callback = function('ale#symbol#HandleLSPResponse') + call ale#lsp#RegisterCallback(l:id, l:Callback) + + let l:message = ale#lsp#message#Symbol(a:query) + let l:request_id = ale#lsp#Send(l:id, l:message) + + call setbufvar(l:buffer, 'ale_symbol_request_made', 1) + let s:symbol_map[l:request_id] = { + \ 'buffer': l:buffer, + \ 'use_relative_paths': has_key(a:options, 'use_relative_paths') ? a:options.use_relative_paths : 0 + \} +endfunction + +function! ale#symbol#Search(args) abort + let [l:opts, l:query] = ale#args#Parse(['relative'], a:args) + + if empty(l:query) + throw 'A non-empty string must be provided!' + endif + + let l:buffer = bufnr('') + let l:options = {} + + if has_key(l:opts, 'relative') + let l:options.use_relative_paths = 1 + endif + + " Set a flag so we only make one request. + call setbufvar(l:buffer, 'ale_symbol_request_made', 0) + let l:Callback = function('s:OnReady', [l:query, l:options]) + + for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) + if !empty(l:linter.lsp) && l:linter.lsp isnot# 'tsserver' + call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback) + endif + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/ale/test.vim b/sources_non_forked/ale/autoload/ale/test.vim new file mode 100644 index 00000000..e03ecb65 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/test.vim @@ -0,0 +1,205 @@ +" Author: w0rp +" Description: Functions for making testing ALE easier. +" +" This file should not typically be loaded during the normal execution of ALE. + +" Change the directory for checking things in particular test directories +" +" This function will set the g:dir variable, which represents the working +" directory after changing the path. This variable allows a test to change +" directories, and then switch back to a directory at the start of the test +" run. +" +" This function should be run in a Vader Before: block. +function! ale#test#SetDirectory(docker_path) abort + if a:docker_path[:len('/testplugin/') - 1] isnot# '/testplugin/' + throw 'docker_path must start with /testplugin/!' + endif + + " Try to switch directory, which will fail when running tests directly, + " and not through the Docker image. + silent! execute 'cd ' . fnameescape(a:docker_path) + let g:dir = getcwd() " no-custom-checks +endfunction + +" When g:dir is defined, switch back to the directory we saved, and then +" delete that variable. +" +" The filename will be reset to dummy.txt +" +" This function should be run in a Vader After: block. +function! ale#test#RestoreDirectory() abort + call ale#test#SetFilename('dummy.txt') + silent execute 'cd ' . fnameescape(g:dir) + unlet! g:dir +endfunction + +" Get a filename for the current buffer using a relative path to the script. +" +" If a g:dir variable is set, it will be used as the path to the directory +" containing the test file. +function! ale#test#GetFilename(path) abort + let l:dir = get(g:, 'dir', '') + + if empty(l:dir) + let l:dir = getcwd() " no-custom-checks + endif + + let l:full_path = ale#path#IsAbsolute(a:path) + \ ? a:path + \ : l:dir . '/' . a:path + + return ale#path#Simplify(l:full_path) +endfunction + +" Change the filename for the current buffer using a relative path to +" the script without running autocmd commands. +" +" If a g:dir variable is set, it will be used as the path to the directory +" containing the test file. +function! ale#test#SetFilename(path) abort + let l:full_path = ale#test#GetFilename(a:path) + silent! noautocmd execute 'file ' . fnameescape(l:full_path) +endfunction + +function! RemoveNewerKeys(results) abort + for l:item in a:results + if has_key(l:item, 'module') + call remove(l:item, 'module') + endif + + if has_key(l:item, 'end_col') + call remove(l:item, 'end_col') + endif + + if has_key(l:item, 'end_lnum') + call remove(l:item, 'end_lnum') + endif + endfor +endfunction + +" Return loclist data with only the keys supported by the lowest Vim versions. +function! ale#test#GetLoclistWithoutNewerKeys() abort + let l:results = getloclist(0) + call RemoveNewerKeys(l:results) + + return l:results +endfunction + +" Return quickfix data with only the keys supported by the lowest Vim versions. +function! ale#test#GetQflistWithoutNewerKeys() abort + let l:results = getqflist() + call RemoveNewerKeys(l:results) + + return l:results +endfunction + +function! ale#test#GetPreviewWindowText() abort + for l:window in range(1, winnr('$')) + if getwinvar(l:window, '&previewwindow', 0) + let l:buffer = winbufnr(l:window) + + return getbufline(l:buffer, 1, '$') + endif + endfor +endfunction + +" This function can be called with a timeout to wait for all jobs to finish. +" If the jobs to not finish in the given number of milliseconds, +" an exception will be thrown. +" +" The time taken will be a very rough approximation, and more time may be +" permitted than is specified. +function! ale#test#WaitForJobs(deadline) abort + let l:start_time = ale#events#ClockMilliseconds() + + if l:start_time == 0 + throw 'Failed to read milliseconds from the clock!' + endif + + let l:job_list = [] + + " Gather all of the jobs from every buffer. + for [l:buffer, l:data] in items(ale#command#GetData()) + call extend(l:job_list, map(keys(l:data.jobs), 'str2nr(v:val)')) + endfor + + " NeoVim has a built-in API for this, so use that. + if has('nvim') + let l:nvim_code_list = jobwait(l:job_list, a:deadline) + + if index(l:nvim_code_list, -1) >= 0 + throw 'Jobs did not complete on time!' + endif + + return + endif + + let l:should_wait_more = 1 + + while l:should_wait_more + let l:should_wait_more = 0 + + for l:job_id in l:job_list + if ale#job#IsRunning(l:job_id) + let l:now = ale#events#ClockMilliseconds() + + if l:now - l:start_time > a:deadline + " Stop waiting after a timeout, so we don't wait forever. + throw 'Jobs did not complete on time!' + endif + + " Wait another 10 milliseconds + let l:should_wait_more = 1 + sleep 10ms + break + endif + endfor + endwhile + + " Sleep for a small amount of time after all jobs finish. + " This seems to be enough to let handlers after jobs end run, and + " prevents the occasional failure where this function exits after jobs + " end, but before handlers are run. + sleep 10ms + + " We must check the buffer data again to see if new jobs started for + " linters with chained commands. + let l:has_new_jobs = 0 + + " Check again to see if any jobs are running. + for l:info in values(g:ale_buffer_info) + for [l:job_id, l:linter] in get(l:info, 'job_list', []) + if ale#job#IsRunning(l:job_id) + let l:has_new_jobs = 1 + break + endif + endfor + endfor + + if l:has_new_jobs + " We have to wait more. Offset the timeout by the time taken so far. + let l:now = ale#events#ClockMilliseconds() + let l:new_deadline = a:deadline - (l:now - l:start_time) + + if l:new_deadline <= 0 + " Enough time passed already, so stop immediately. + throw 'Jobs did not complete on time!' + endif + + call ale#test#WaitForJobs(l:new_deadline) + endif +endfunction + +function! ale#test#FlushJobs() abort + " The variable is checked for in a loop, as calling one series of + " callbacks can trigger a further series of callbacks. + while exists('g:ale_run_synchronously_callbacks') + let l:callbacks = g:ale_run_synchronously_callbacks + unlet g:ale_run_synchronously_callbacks + + for l:Callback in l:callbacks + call l:Callback() + endfor + endwhile +endfunction diff --git a/sources_non_forked/ale/autoload/ale/toggle.vim b/sources_non_forked/ale/autoload/ale/toggle.vim new file mode 100644 index 00000000..7f8957d4 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/toggle.vim @@ -0,0 +1,101 @@ +function! s:EnablePreamble() abort + " Set pattern options again, if enabled. + if get(g:, 'ale_pattern_options_enabled', 0) + call ale#pattern_options#SetOptions(bufnr('')) + endif + + " Lint immediately, including running linters against the file. + call ale#Queue(0, 'lint_file') +endfunction + +function! s:DisablePostamble() abort + " Remove highlights for the current buffer now. + if g:ale_set_highlights + call ale#highlight#UpdateHighlights() + endif + + if g:ale_virtualtext_cursor == 1 + call ale#virtualtext#Clear(bufnr('')) + endif +endfunction + +function! ale#toggle#Toggle() abort + let g:ale_enabled = !get(g:, 'ale_enabled') + + if g:ale_enabled + call s:EnablePreamble() + + if g:ale_set_balloons + call ale#balloon#Enable() + endif + else + call ale#engine#CleanupEveryBuffer() + call s:DisablePostamble() + + if exists('*ale#balloon#Disable') + call ale#balloon#Disable() + endif + endif + + call ale#events#Init() +endfunction + +function! ale#toggle#Enable() abort + if !g:ale_enabled + call ale#toggle#Toggle() + endif +endfunction + +function! ale#toggle#Disable() abort + if g:ale_enabled + call ale#toggle#Toggle() + endif +endfunction + +function! ale#toggle#Reset() abort + call ale#engine#CleanupEveryBuffer() + call ale#highlight#UpdateHighlights() +endfunction + +function! ale#toggle#ToggleBuffer(buffer) abort + " Get the new value for the toggle. + let l:enabled = !getbufvar(a:buffer, 'ale_enabled', 1) + + " Disabling ALE globally removes autocmd events, so we cannot enable + " linting locally when linting is disabled globally + if l:enabled && !g:ale_enabled + " no-custom-checks + echom 'ALE cannot be enabled locally when disabled globally' + + return + endif + + call setbufvar(a:buffer, 'ale_enabled', l:enabled) + + if l:enabled + call s:EnablePreamble() + else + " Stop all jobs and clear the results for everything, and delete + " all of the data we stored for the buffer. + call ale#engine#Cleanup(a:buffer) + call s:DisablePostamble() + endif +endfunction + +function! ale#toggle#EnableBuffer(buffer) abort + " ALE is enabled by default for all buffers. + if !getbufvar(a:buffer, 'ale_enabled', 1) + call ale#toggle#ToggleBuffer(a:buffer) + endif +endfunction + +function! ale#toggle#DisableBuffer(buffer) abort + if getbufvar(a:buffer, 'ale_enabled', 1) + call ale#toggle#ToggleBuffer(a:buffer) + endif +endfunction + +function! ale#toggle#ResetBuffer(buffer) abort + call ale#engine#Cleanup(a:buffer) + call ale#highlight#UpdateHighlights() +endfunction diff --git a/sources_non_forked/ale/autoload/ale/uri.vim b/sources_non_forked/ale/autoload/ale/uri.vim new file mode 100644 index 00000000..d696f03d --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/uri.vim @@ -0,0 +1,43 @@ +function! s:EncodeChar(char) abort + let l:result = '' + + for l:index in range(strlen(a:char)) + let l:result .= printf('%%%02x', char2nr(a:char[l:index])) + endfor + + return l:result +endfunction + +function! ale#uri#Encode(value) abort + return substitute( + \ a:value, + \ '\([^a-zA-Z0-9\\/$\-_.!*''(),]\)', + \ '\=s:EncodeChar(submatch(1))', + \ 'g' + \) +endfunction + +function! ale#uri#Decode(value) abort + return substitute( + \ a:value, + \ '%\(\x\x\)', + \ '\=printf("%c", str2nr(submatch(1), 16))', + \ 'g' + \) +endfunction + +let s:uri_handlers = { +\ 'jdt': { +\ 'OpenURILink': function('ale#uri#jdt#OpenJDTLink'), +\ } +\} + +function! ale#uri#GetURIHandler(uri) abort + for l:scheme in keys(s:uri_handlers) + if a:uri =~# '^'.l:scheme.'://' + return s:uri_handlers[scheme] + endif + endfor + + return v:null +endfunction diff --git a/sources_non_forked/ale/autoload/ale/uri/jdt.vim b/sources_non_forked/ale/autoload/ale/uri/jdt.vim new file mode 100644 index 00000000..46cea268 --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/uri/jdt.vim @@ -0,0 +1,110 @@ +" Author: yoshi1123 +" Description: Functions for working with jdt:// URIs. + +function! s:OpenJDTLink(root, uri, line, column, options, result) abort + if has_key(a:result, 'error') + " no-custom-checks + echoerr a:result.error.message + + return + endif + + let l:contents = a:result['result'] + + if type(l:contents) is# type(v:null) + " no-custom-checks + echoerr 'File content not found' + endif + + " disable autocmd when opening buffer + autocmd! AleURISchemes + call ale#util#Open(a:uri, a:line, a:column, a:options) + autocmd AleURISchemes BufNewFile,BufReadPre jdt://** call ale#uri#jdt#ReadJDTLink(expand('')) + + if !empty(getbufvar(bufnr(''), 'ale_lsp_root', '')) + return + endif + + let b:ale_lsp_root = a:root + set filetype=java + + call setline(1, split(l:contents, '\n')) + call cursor(a:line, a:column) + normal! zz + + setlocal buftype=nofile nomodified nomodifiable readonly +endfunction + +" Load new buffer with jdt:// contents and jump to line and column. +function! ale#uri#jdt#OpenJDTLink(encoded_uri, line, column, options, conn_id) abort + let l:found_eclipselsp = v:false + + for l:linter in ale#linter#Get('java') + if l:linter.name is# 'eclipselsp' + let l:found_eclipselsp = v:true + endif + endfor + + if !l:found_eclipselsp + throw 'eclipselsp not running' + endif + + let l:root = a:conn_id[stridx(a:conn_id, ':')+1:] + let l:uri = a:encoded_uri + call ale#lsp_linter#SendRequest( + \ bufnr(''), + \ 'eclipselsp', + \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}], + \ function('s:OpenJDTLink', [l:root, l:uri, a:line, a:column, a:options]) + \) +endfunction + +function! s:ReadClassFileContents(uri, result) abort + if has_key(a:result, 'error') + " no-custom-checks + echoerr a:result.error.message + + return + endif + + let l:contents = a:result['result'] + + if type(l:contents) is# type(v:null) + " no-custom-checks + echoerr 'File content not found' + endif + + call setline(1, split(l:contents, '\n')) + + setlocal buftype=nofile nomodified nomodifiable readonly +endfunction + +" Read jdt:// contents, as part of current project, into current buffer. +function! ale#uri#jdt#ReadJDTLink(encoded_uri) abort + if !empty(getbufvar(bufnr(''), 'ale_lsp_root', '')) + return + endif + + let l:linter_map = ale#lsp_linter#GetLSPLinterMap() + + for l:conn_id in keys(l:linter_map) + if l:linter_map[l:conn_id] is# 'eclipselsp' + let l:root = l:conn_id[stridx(l:conn_id, ':')+1:] + endif + endfor + + if l:root is# v:null + throw 'eclipselsp not running' + endif + + let l:uri = a:encoded_uri + let b:ale_lsp_root = l:root + set filetype=java + + call ale#lsp_linter#SendRequest( + \ bufnr(''), + \ 'eclipselsp', + \ [0, 'java/classFileContents', {'uri': ale#util#ToURI(l:uri)}], + \ function('s:ReadClassFileContents', [l:uri]) + \) +endfunction diff --git a/sources_non_forked/ale/autoload/ale/util.vim b/sources_non_forked/ale/autoload/ale/util.vim new file mode 100644 index 00000000..c884076a --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/util.vim @@ -0,0 +1,574 @@ +" Author: w0rp +" Description: Contains miscellaneous functions + +" A wrapper function for mode() so we can test calls for it. +function! ale#util#Mode(...) abort + return call('mode', a:000) +endfunction + +" A wrapper function for feedkeys so we can test calls for it. +function! ale#util#FeedKeys(...) abort + return call('feedkeys', a:000) +endfunction + +" Show a message in as small a window as possible. +" +" Vim 8 does not support echoing long messages from asynchronous callbacks, +" but NeoVim does. Small messages can be echoed in Vim 8, and larger messages +" have to be shown in preview windows. +function! ale#util#ShowMessage(string, ...) abort + let l:options = get(a:000, 0, {}) + + if !has('nvim') + call ale#preview#CloseIfTypeMatches('ale-preview.message') + endif + + " We have to assume the user is using a monospace font. + if has('nvim') || (a:string !~? "\n" && len(a:string) < &columns) + " no-custom-checks + echo a:string + else + call ale#preview#Show(split(a:string, "\n"), extend( + \ { + \ 'filetype': 'ale-preview.message', + \ 'stay_here': 1, + \ }, + \ l:options, + \)) + endif +endfunction + +" A wrapper function for execute, so we can test executing some commands. +function! ale#util#Execute(expr) abort + execute a:expr +endfunction + +if !exists('g:ale#util#nul_file') + " A null file for sending output to nothing. + let g:ale#util#nul_file = '/dev/null' + + if has('win32') + let g:ale#util#nul_file = 'nul' + endif +endif + +" Given a job, a buffered line of data, a list of parts of lines, a mode data +" is being read in, and a callback, join the lines of output for a NeoVim job +" or socket together, and call the callback with the joined output. +" +" Note that jobs and IDs are the same thing on NeoVim. +function! ale#util#JoinNeovimOutput(job, last_line, data, mode, callback) abort + if a:mode is# 'raw' + call a:callback(a:job, join(a:data, "\n")) + + return '' + endif + + let l:lines = a:data[:-2] + + if len(a:data) > 1 + let l:lines[0] = a:last_line . l:lines[0] + let l:new_last_line = a:data[-1] + else + let l:new_last_line = a:last_line . get(a:data, 0, '') + endif + + for l:line in l:lines + call a:callback(a:job, l:line) + endfor + + return l:new_last_line +endfunction + +" Return the number of lines for a given buffer. +function! ale#util#GetLineCount(buffer) abort + return len(getbufline(a:buffer, 1, '$')) +endfunction + +function! ale#util#GetFunction(string_or_ref) abort + if type(a:string_or_ref) is v:t_string + return function(a:string_or_ref) + endif + + return a:string_or_ref +endfunction + +" Open the file (at the given line). +" options['open_in'] can be: +" current-buffer (default) +" tab +" split +" vsplit +function! ale#util#Open(filename, line, column, options) abort + let l:open_in = get(a:options, 'open_in', 'current-buffer') + let l:args_to_open = '+' . a:line . ' ' . fnameescape(a:filename) + + if l:open_in is# 'tab' + call ale#util#Execute('tabedit ' . l:args_to_open) + elseif l:open_in is# 'split' + call ale#util#Execute('split ' . l:args_to_open) + elseif l:open_in is# 'vsplit' + call ale#util#Execute('vsplit ' . l:args_to_open) + elseif bufnr(a:filename) isnot bufnr('') + " Open another file only if we need to. + call ale#util#Execute('edit ' . l:args_to_open) + else + normal! m` + endif + + call cursor(a:line, a:column) + normal! zz +endfunction + +let g:ale#util#error_priority = 5 +let g:ale#util#warning_priority = 4 +let g:ale#util#info_priority = 3 +let g:ale#util#style_error_priority = 2 +let g:ale#util#style_warning_priority = 1 + +function! ale#util#GetItemPriority(item) abort + if a:item.type is# 'I' + return g:ale#util#info_priority + endif + + if a:item.type is# 'W' + if get(a:item, 'sub_type', '') is# 'style' + return g:ale#util#style_warning_priority + endif + + return g:ale#util#warning_priority + endif + + if get(a:item, 'sub_type', '') is# 'style' + return g:ale#util#style_error_priority + endif + + return g:ale#util#error_priority +endfunction + +" Compare two loclist items for ALE, sorted by their buffers, filenames, and +" line numbers and column numbers. +function! ale#util#LocItemCompare(left, right) abort + if a:left.bufnr < a:right.bufnr + return -1 + endif + + if a:left.bufnr > a:right.bufnr + return 1 + endif + + if a:left.bufnr == -1 + if a:left.filename < a:right.filename + return -1 + endif + + if a:left.filename > a:right.filename + return 1 + endif + endif + + if a:left.lnum < a:right.lnum + return -1 + endif + + if a:left.lnum > a:right.lnum + return 1 + endif + + if a:left.col < a:right.col + return -1 + endif + + if a:left.col > a:right.col + return 1 + endif + + " When either of the items lacks a problem type, then the two items should + " be considered equal. This is important for loclist jumping. + if !has_key(a:left, 'type') || !has_key(a:right, 'type') + return 0 + endif + + let l:left_priority = ale#util#GetItemPriority(a:left) + let l:right_priority = ale#util#GetItemPriority(a:right) + + if l:left_priority < l:right_priority + return -1 + endif + + if l:left_priority > l:right_priority + return 1 + endif + + return 0 +endfunction + +" Compare two loclist items, including the text for the items. +" +" This function can be used for de-duplicating lists. +function! ale#util#LocItemCompareWithText(left, right) abort + let l:cmp_value = ale#util#LocItemCompare(a:left, a:right) + + if l:cmp_value + return l:cmp_value + endif + + if a:left.text < a:right.text + return -1 + endif + + if a:left.text > a:right.text + return 1 + endif + + return 0 +endfunction + +" This function will perform a binary search and a small sequential search +" on the list to find the last problem in the buffer and line which is +" on or before the column. The index of the problem will be returned. +" +" -1 will be returned if nothing can be found. +function! ale#util#BinarySearch(loclist, buffer, line, column) abort + let l:min = 0 + let l:max = len(a:loclist) - 1 + + while 1 + if l:max < l:min + return -1 + endif + + let l:mid = (l:min + l:max) / 2 + let l:item = a:loclist[l:mid] + + " Binary search for equal buffers, equal lines, then near columns. + if l:item.bufnr < a:buffer + let l:min = l:mid + 1 + elseif l:item.bufnr > a:buffer + let l:max = l:mid - 1 + elseif l:item.lnum < a:line + let l:min = l:mid + 1 + elseif l:item.lnum > a:line + let l:max = l:mid - 1 + else + " This part is a small sequential search. + let l:index = l:mid + + " Search backwards to find the first problem on the line. + while l:index > 0 + \&& a:loclist[l:index - 1].bufnr == a:buffer + \&& a:loclist[l:index - 1].lnum == a:line + let l:index -= 1 + endwhile + + " Find the last problem on or before this column. + while l:index < l:max + \&& a:loclist[l:index + 1].bufnr == a:buffer + \&& a:loclist[l:index + 1].lnum == a:line + \&& a:loclist[l:index + 1].col <= a:column + let l:index += 1 + endwhile + + " Scan forwards to find the last item on the column for the item + " we found, which will have the most serious problem. + let l:item_column = a:loclist[l:index].col + + while l:index < l:max + \&& a:loclist[l:index + 1].bufnr == a:buffer + \&& a:loclist[l:index + 1].lnum == a:line + \&& a:loclist[l:index + 1].col == l:item_column + let l:index += 1 + endwhile + + return l:index + endif + endwhile +endfunction + +" A function for testing if a function is running inside a sandbox. +" See :help sandbox +function! ale#util#InSandbox() abort + try + let &l:equalprg=&l:equalprg + catch /E48/ + " E48 is the sandbox error. + return 1 + endtry + + return 0 +endfunction + +function! ale#util#Tempname() abort + let l:clear_tempdir = 0 + + if exists('$TMPDIR') && empty($TMPDIR) + let l:clear_tempdir = 1 + let $TMPDIR = '/tmp' + endif + + try + let l:name = tempname() " no-custom-checks + finally + if l:clear_tempdir + let $TMPDIR = '' + endif + endtry + + return l:name +endfunction + +" Given a single line, or a List of lines, and a single pattern, or a List +" of patterns, return all of the matches for the lines(s) from the given +" patterns, using matchlist(). +" +" Only the first pattern which matches a line will be returned. +function! ale#util#GetMatches(lines, patterns) abort + let l:matches = [] + let l:lines = type(a:lines) is v:t_list ? a:lines : [a:lines] + let l:patterns = type(a:patterns) is v:t_list ? a:patterns : [a:patterns] + + for l:line in l:lines + for l:pattern in l:patterns + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + call add(l:matches, l:match) + break + endif + endfor + endfor + + return l:matches +endfunction + +" Given a single line, or a List of lines, and a single pattern, or a List of +" patterns, and a callback function for mapping the items matches, return the +" result of mapping all of the matches for the lines from the given patterns, +" using matchlist() +" +" Only the first pattern which matches a line will be returned. +function! ale#util#MapMatches(lines, patterns, Callback) abort + return map(ale#util#GetMatches(a:lines, a:patterns), 'a:Callback(v:val)') +endfunction + +function! s:LoadArgCount(function) abort + try + let l:output = execute('function a:function') + catch /E123/ + return 0 + endtry + + let l:match = matchstr(split(l:output, "\n")[0], '\v\([^)]+\)')[1:-2] + let l:arg_list = filter(split(l:match, ', '), 'v:val isnot# ''...''') + + return len(l:arg_list) +endfunction + +" Given the name of a function, a Funcref, or a lambda, return the number +" of named arguments for a function. +function! ale#util#FunctionArgCount(function) abort + let l:Function = ale#util#GetFunction(a:function) + let l:count = s:LoadArgCount(l:Function) + + " If we failed to get the count, forcibly load the autoload file, if the + " function is an autoload function. autoload functions aren't normally + " defined until they are called. + if l:count == 0 + let l:function_name = matchlist(string(l:Function), 'function([''"]\(.\+\)[''"])')[1] + + if l:function_name =~# '#' + execute 'runtime autoload/' . join(split(l:function_name, '#')[:-2], '/') . '.vim' + let l:count = s:LoadArgCount(l:Function) + endif + endif + + return l:count +endfunction + +" Escape a string so the characters in it will be safe for use inside of PCRE +" or RE2 regular expressions without characters having special meanings. +function! ale#util#EscapePCRE(unsafe_string) abort + return substitute(a:unsafe_string, '\([\-\[\]{}()*+?.^$|]\)', '\\\1', 'g') +endfunction + +" Escape a string so that it can be used as a literal string inside an evaled +" vim command. +function! ale#util#EscapeVim(unsafe_string) abort + return "'" . substitute(a:unsafe_string, "'", "''", 'g') . "'" +endfunction + + +" Given a String or a List of String values, try and decode the string(s) +" as a JSON value which can be decoded with json_decode. If the JSON string +" is invalid, the default argument value will be returned instead. +" +" This function is useful in code where the data can't be trusted to be valid +" JSON, and where throwing exceptions is mostly just irritating. +function! ale#util#FuzzyJSONDecode(data, default) abort + if empty(a:data) + return a:default + endif + + let l:str = type(a:data) is v:t_string ? a:data : join(a:data, '') + + try + let l:result = json_decode(l:str) + + " Vim 8 only uses the value v:none for decoding blank strings. + if !has('nvim') && l:result is v:none + return a:default + endif + + return l:result + catch /E474\|E491/ + return a:default + endtry +endfunction + +" Write a file, including carriage return characters for DOS files. +" +" The buffer number is required for determining the fileformat setting for +" the buffer. +function! ale#util#Writefile(buffer, lines, filename) abort + let l:corrected_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' + \ ? map(copy(a:lines), 'substitute(v:val, ''\r*$'', ''\r'', '''')') + \ : a:lines + + " Set binary flag if buffer doesn't have eol and nofixeol to avoid appending newline + let l:flags = !getbufvar(a:buffer, '&eol') && exists('+fixeol') && !&fixeol ? 'bS' : 'S' + + call writefile(l:corrected_lines, a:filename, l:flags) " no-custom-checks +endfunction + +if !exists('s:patial_timers') + let s:partial_timers = {} +endif + +function! s:ApplyPartialTimer(timer_id) abort + if has_key(s:partial_timers, a:timer_id) + let [l:Callback, l:args] = remove(s:partial_timers, a:timer_id) + call call(l:Callback, [a:timer_id] + l:args) + endif +endfunction + +" Given a delay, a callback, a List of arguments, start a timer with +" timer_start() and call the callback provided with [timer_id] + args. +" +" The timer must not be stopped with timer_stop(). +" Use ale#util#StopPartialTimer() instead, which can stop any timer, and will +" clear any arguments saved for executing callbacks later. +function! ale#util#StartPartialTimer(delay, callback, args) abort + let l:timer_id = timer_start(a:delay, function('s:ApplyPartialTimer')) + let s:partial_timers[l:timer_id] = [a:callback, a:args] + + return l:timer_id +endfunction + +function! ale#util#StopPartialTimer(timer_id) abort + call timer_stop(a:timer_id) + + if has_key(s:partial_timers, a:timer_id) + call remove(s:partial_timers, a:timer_id) + endif +endfunction + +" Given a possibly multi-byte string and a 1-based character position on a +" line, return the 1-based byte position on that line. +function! ale#util#Col(str, chr) abort + if a:chr < 2 + return a:chr + endif + + return strlen(join(split(a:str, '\zs')[0:a:chr - 2], '')) + 1 +endfunction + +function! ale#util#FindItemAtCursor(buffer) abort + let l:info = get(g:ale_buffer_info, a:buffer, {}) + let l:loclist = get(l:info, 'loclist', []) + let l:pos = getpos('.') + let l:index = ale#util#BinarySearch(l:loclist, a:buffer, l:pos[1], l:pos[2]) + let l:loc = l:index >= 0 ? l:loclist[l:index] : {} + + return [l:info, l:loc] +endfunction + +function! ale#util#Input(message, value, ...) abort + if a:0 > 0 + return input(a:message, a:value, a:1) + else + return input(a:message, a:value) + endif +endfunction + +function! ale#util#HasBuflineApi() abort + return exists('*deletebufline') && exists('*setbufline') +endfunction + +" Sets buffer contents to lines +function! ale#util#SetBufferContents(buffer, lines) abort + let l:has_bufline_api = ale#util#HasBuflineApi() + + if !l:has_bufline_api && a:buffer isnot bufnr('') + return + endif + + " If the file is in DOS mode, we have to remove carriage returns from + " the ends of lines before calling setline(), or we will see them + " twice. + let l:new_lines = getbufvar(a:buffer, '&fileformat') is# 'dos' + \ ? map(copy(a:lines), 'substitute(v:val, ''\r\+$'', '''', '''')') + \ : a:lines + let l:first_line_to_remove = len(l:new_lines) + 1 + + " Use a Vim API for setting lines in other buffers, if available. + if l:has_bufline_api + call setbufline(a:buffer, 1, l:new_lines) + call deletebufline(a:buffer, l:first_line_to_remove, '$') + " Fall back on setting lines the old way, for the current buffer. + else + let l:old_line_length = line('$') + + if l:old_line_length >= l:first_line_to_remove + let l:save = winsaveview() + silent execute + \ l:first_line_to_remove . ',' . l:old_line_length . 'd_' + call winrestview(l:save) + endif + + call setline(1, l:new_lines) + endif + + return l:new_lines +endfunction + +function! ale#util#GetBufferContents(buffer) abort + return join(getbufline(a:buffer, 1, '$'), '\n') . '\n' +endfunction + +function! ale#util#ToURI(resource) abort + let l:uri_handler = ale#uri#GetURIHandler(a:resource) + + if l:uri_handler is# v:null + " resource is a filesystem path + let l:uri = ale#path#ToFileURI(a:resource) + else + " resource is a URI + let l:uri = a:resource + endif + + return l:uri +endfunction + +function! ale#util#ToResource(uri) abort + let l:uri_handler = ale#uri#GetURIHandler(a:uri) + + if l:uri_handler is# v:null + " resource is a filesystem path + let l:resource = ale#path#FromFileURI(a:uri) + else + " resource is a URI + let l:resource = a:uri + endif + + return l:resource +endfunction diff --git a/sources_non_forked/ale/autoload/ale/virtualtext.vim b/sources_non_forked/ale/autoload/ale/virtualtext.vim new file mode 100644 index 00000000..5fade39b --- /dev/null +++ b/sources_non_forked/ale/autoload/ale/virtualtext.vim @@ -0,0 +1,187 @@ +scriptencoding utf-8 +" Author: w0rp +" Author: Luan Santos +" Description: Shows lint message for the current line as virtualtext, if any + +" Controls the milliseconds delay before showing a message. +let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10) +let s:cursor_timer = -1 +let s:last_pos = [0, 0, 0] +let s:has_virt_text = 0 +let s:emulate_virt = 0 + +if has('nvim-0.3.2') + let s:ns_id = nvim_create_namespace('ale') + let s:has_virt_text = 1 +elseif has('textprop') && has('popupwin') + let s:has_virt_text = 1 + let s:emulate_virt = !has('patch-9.0.0297') + let s:hl_list = [] + + if s:emulate_virt + call prop_type_add('ale', {}) + let s:last_virt = -1 + endif +endif + +function! ale#virtualtext#Clear(buf) abort + if !s:has_virt_text + return + endif + + if has('nvim') + call nvim_buf_clear_namespace(a:buf, s:ns_id, 0, -1) + else + if s:emulate_virt && s:last_virt != -1 + call prop_remove({'type': 'ale'}) + call popup_close(s:last_virt) + let s:last_virt = -1 + elseif !empty(s:hl_list) + call prop_remove({ + \ 'types': s:hl_list, + \ 'all': 1, + \ 'bufnr': a:buf}) + endif + endif +endfunction + +function! ale#virtualtext#ShowMessage(message, hl_group, buf, line) abort + if !s:has_virt_text || !bufexists(str2nr(a:buf)) + return + endif + + let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ') + let l:msg = l:prefix.trim(substitute(a:message, '\n', ' ', 'g')) + + if has('nvim') + call nvim_buf_set_virtual_text(a:buf, s:ns_id, a:line-1, [[l:msg, a:hl_group]], {}) + elseif s:emulate_virt + let l:left_pad = col('$') + call prop_add(a:line, l:left_pad, { + \ 'type': 'ale', + \}) + let s:last_virt = popup_create(l:msg, { + \ 'line': -1, + \ 'padding': [0, 0, 0, 1], + \ 'mask': [[1, 1, 1, 1]], + \ 'textprop': 'ale', + \ 'highlight': a:hl_group, + \ 'fixed': 1, + \ 'wrap': 0, + \ 'zindex': 2 + \}) + else + let type = prop_type_get(a:hl_group) + + if type == {} + call add(s:hl_list, a:hl_group) + call prop_type_add(a:hl_group, {'highlight': a:hl_group}) + endif + + call prop_add(a:line, 0, { + \ 'type': a:hl_group, + \ 'text': ' ' . l:msg, + \ 'bufnr': a:buf + \}) + endif +endfunction + +function! s:StopCursorTimer() abort + if s:cursor_timer != -1 + call timer_stop(s:cursor_timer) + let s:cursor_timer = -1 + endif +endfunction + +function! ale#virtualtext#GetHlGroup(type, style) abort + if a:type is# 'E' + if a:style is# 'style' + return 'ALEVirtualTextStyleError' + else + return 'ALEVirtualTextError' + endif + elseif a:type is# 'W' + if a:style is# 'style' + return 'ALEVirtualTextStyleWarning' + else + return 'ALEVirtualTextWarning' + endif + else + return 'ALEVirtualTextInfo' + endif +endfunction + +function! ale#virtualtext#ShowCursorWarning(...) abort + if g:ale_virtualtext_cursor != 1 + return + endif + + let l:buffer = bufnr('') + + if mode(1) isnot# 'n' + return + endif + + if ale#ShouldDoNothing(l:buffer) + return + endif + + let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer) + + call ale#virtualtext#Clear(l:buffer) + + if !empty(l:loc) + let l:msg = l:loc.text + let l:type = get(l:loc, 'type', 'E') + let l:style = get(l:loc, 'sub_type', '') + let l:hl_group = ale#virtualtext#GetHlGroup(l:type, l:style) + call ale#virtualtext#ShowMessage(l:msg, l:hl_group, l:buffer, line('.')) + endif +endfunction + +function! ale#virtualtext#ShowCursorWarningWithDelay() abort + let l:buffer = bufnr('') + + if g:ale_virtualtext_cursor != 1 + return + endif + + if mode(1) isnot# 'n' + return + endif + + call s:StopCursorTimer() + + let l:pos = getpos('.')[0:2] + + " Check the current buffer, line, and column number against the last + " recorded position. If the position has actually changed, *then* + " we should show something. Otherwise we can end up doing processing + " the show message far too frequently. + if l:pos != s:last_pos + let l:delay = ale#Var(l:buffer, 'virtualtext_delay') + + let s:last_pos = l:pos + let s:cursor_timer = timer_start( + \ l:delay, + \ function('ale#virtualtext#ShowCursorWarning') + \) + endif +endfunction + +function! ale#virtualtext#SetTexts(buf, loclist) abort + if !has('nvim') && s:emulate_virt + return + endif + + call ale#virtualtext#Clear(a:buf) + + for l in a:loclist + if l['bufnr'] != a:buf + continue + endif + + let hl = ale#virtualtext#GetHlGroup(l['type'], get(l, 'sub_type', '')) + call ale#virtualtext#ShowMessage(l['text'], hl, a:buf, l['lnum']) + endfor +endfunction diff --git a/sources_non_forked/ale/autoload/asyncomplete/sources/ale.vim b/sources_non_forked/ale/autoload/asyncomplete/sources/ale.vim new file mode 100644 index 00000000..ce793773 --- /dev/null +++ b/sources_non_forked/ale/autoload/asyncomplete/sources/ale.vim @@ -0,0 +1,26 @@ +function! asyncomplete#sources#ale#get_source_options(...) abort + let l:default = extend({ + \ 'name': 'ale', + \ 'completor': function('asyncomplete#sources#ale#completor'), + \ 'whitelist': ['*'], + \ 'triggers': asyncomplete#sources#ale#get_triggers(), + \ }, a:0 >= 1 ? a:1 : {}) + + return extend(l:default, {'refresh_pattern': '\k\+$'}) +endfunction + +function! asyncomplete#sources#ale#get_triggers() abort + let l:triggers = ale#completion#GetAllTriggers() + let l:triggers['*'] = l:triggers[''] + + return l:triggers +endfunction + +function! asyncomplete#sources#ale#completor(options, context) abort + let l:keyword = matchstr(a:context.typed, '\w\+$') + let l:startcol = a:context.col - len(l:keyword) + + call ale#completion#GetCompletions('ale-callback', { 'callback': {completions -> + \ asyncomplete#complete(a:options.name, a:context, l:startcol, completions) + \ }}) +endfunction diff --git a/sources_non_forked/ale/doc/ale-ada.txt b/sources_non_forked/ale/doc/ale-ada.txt new file mode 100644 index 00000000..80321dbb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ada.txt @@ -0,0 +1,71 @@ +=============================================================================== +ALE Ada Integration *ale-ada-options* + + +=============================================================================== +cspell *ale-ada-cspell* + +See |ale-cspell-options| + +=============================================================================== +gcc *ale-ada-gcc* + +g:ale_ada_gcc_executable *g:ale_ada_gcc_executable* + *b:ale_ada_gcc_executable* + Type: |String| + Default: `'gcc'` + +This variable can be changed to use a different executable for gcc. + + +g:ale_ada_gcc_options *g:ale_ada_gcc_options* + *b:ale_ada_gcc_options* + Type: |String| + Default: `'-gnatwa -gnatq'` + + This variable can be set to pass additional options to gcc. + + +=============================================================================== +gnatpp *ale-ada-gnatpp* + +g:ale_ada_gnatpp_options *g:ale_ada_gnatpp_options* + *b:ale_ada_gnatpp_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to the gnatpp fixer. + + +=============================================================================== +ada-language-server *ale-ada-language-server* + +g:ale_ada_adals_executable *g:ale_ada_adals_executable* + *b:ale_ada_adals_executable* + Type: |String| + Default: `'ada_language_server'` + + This variable can be changed to use a different executable for Ada Language + Server. + + +g:ale_ada_adals_project *g:ale_ada_adals_project* + *b:ale_ada_adals_project* + Type: |String| + Default: `'default.gpr'` + +This variable can be changed to use a different GPR file for +Ada Language Server. + + +g:ale_ada_adals_encoding *g:ale_ada_adals_encoding* + *b:ale_ada_adals_encoding* + Type: |String| + Default: `'utf-8'` + +This variable can be changed to use a different file encoding for +Ada Language Server. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ansible.txt b/sources_non_forked/ale/doc/ale-ansible.txt new file mode 100644 index 00000000..3a4efaa5 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ansible.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Ansible Integration *ale-ansible-options* + + +=============================================================================== +ansible-lint *ale-ansible-ansible-lint* + +g:ale_ansible_ansible_lint_executable *g:ale_ansible_ansible_lint_executable* + *b:ale_ansible_ansible_lint_executable* + Type: |String| + Default: `'ansible-lint'` + + This variable can be changed to modify the executable used for ansible-lint. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-apkbuild.txt b/sources_non_forked/ale/doc/ale-apkbuild.txt new file mode 100644 index 00000000..05261400 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-apkbuild.txt @@ -0,0 +1,30 @@ +=============================================================================== +ALE APKBUILD Integration *ale-apkbuild-options* + + +=============================================================================== +apkbuild-lint *ale-apkbuild-apkbuild-lint* + +g:ale_apkbuild_apkbuild_lint_executable + *g:ale_apkbuild_apkbuild_lint_executable* + *b:ale_apkbuild_apkbuild_lint_executable* + + Type: |String| + Default: `'apkbuild-lint'` + + This variable can be set to change the path to apkbuild-lint + +=============================================================================== +secfixes-check *ale-apkbuild-secfixes-check* + +g:ale_apkbuild_secfixes_check_executable + *g:ale_apkbuild_secfixes_check_executable* + *b:ale_apkbuild_secfixes_check_executable* + + Type: |String| + Default: `'secfixes-check'` + + This variable can be set to change the path to secfixes-check + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-asciidoc.txt b/sources_non_forked/ale/doc/ale-asciidoc.txt new file mode 100644 index 00000000..dd8b12ff --- /dev/null +++ b/sources_non_forked/ale/doc/ale-asciidoc.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE AsciiDoc Integration *ale-asciidoc-options* + + +=============================================================================== +cspell *ale-asciidoc-cspell* + +See |ale-cspell-options| + + +=============================================================================== +write-good *ale-asciidoc-write-good* + +See |ale-write-good-options| + + +=============================================================================== +textlint *ale-asciidoc-textlint* + +See |ale-text-textlint| + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-asm.txt b/sources_non_forked/ale/doc/ale-asm.txt new file mode 100644 index 00000000..a97c6d00 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-asm.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE ASM Integration *ale-asm-options* + + +=============================================================================== +gcc *ale-asm-gcc* + +g:ale_asm_gcc_executable *g:ale_asm_gcc_executable* + *b:ale_asm_gcc_executable* + Type: |String| + Default: `'gcc'` + +This variable can be changed to use a different executable for gcc. + + +g:ale_asm_gcc_options *g:ale_asm_gcc_options* + *b:ale_asm_gcc_options* + Type: |String| + Default: `'-Wall'` + + This variable can be set to pass additional options to gcc. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-avra.txt b/sources_non_forked/ale/doc/ale-avra.txt new file mode 100644 index 00000000..a61913ad --- /dev/null +++ b/sources_non_forked/ale/doc/ale-avra.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE AVRA Integration *ale-avra-options* + + +=============================================================================== +avra *ale-avra-avra* + +g:ale_avra_avra_executable *g:ale_avra_avra_executable* + *b:ale_avra_avra_executable* + + Type: |String| + Default `'avra'` + + This variable can be changed to use different executable for AVRA. + + +g:ale_avra_avra_options *g:ale_avra_avra_options* + *b:ale_avra_avra_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to AVRA. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-awk.txt b/sources_non_forked/ale/doc/ale-awk.txt new file mode 100644 index 00000000..b9c5c34e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-awk.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE Awk Integration *ale-awk-options* + + +=============================================================================== +gawk *ale-awk-gawk* + +g:ale_awk_gawk_executable *g:ale_awk_gawk_executable* + *b:ale_awk_gawk_executable* + Type: |String| + Default: `'gawk'` + + This variable sets executable used for gawk. + + +g:ale_awk_gawk_options *g:ale_awk_gawk_options* + *b:ale_awk_gawk_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for gawk + for invocation. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bats.txt b/sources_non_forked/ale/doc/ale-bats.txt new file mode 100644 index 00000000..cf2199ec --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bats.txt @@ -0,0 +1,13 @@ +=============================================================================== +ALE Bats Integration *ale-bats-options* + + +=============================================================================== +shellcheck *ale-bats-shellcheck* + +The `shellcheck` linter for Bats uses the sh options for `shellcheck`; see: +|ale-sh-shellcheck|. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bazel.txt b/sources_non_forked/ale/doc/ale-bazel.txt new file mode 100644 index 00000000..e2922aaf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bazel.txt @@ -0,0 +1,28 @@ +=============================================================================== +ALE Bazel Integration *ale-bazel-options* + +=============================================================================== +buildifier *ale-bazel-buildifier* + +g:ale_bazel_buildifier_executable *g:ale_bazel_buildifier_executable* + *b:ale_bazel_buildifier_executable* + Type: |String| + Default: `'buildifier'` + + See |ale-integrations-local-executables| + + +g:ale_bazel_buildifier_options *g:ale_bazel_buildifier_options* + *b:ale_bazel_buildifier_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to buildifier. + + +g:ale_bazel_buildifier_use_global *g:ale_bazel_buildifier_use_global* + *b:ale_bazel_buildifier_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| diff --git a/sources_non_forked/ale/doc/ale-bib.txt b/sources_non_forked/ale/doc/ale-bib.txt new file mode 100644 index 00000000..35998c30 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bib.txt @@ -0,0 +1,19 @@ +=============================================================================== +ALE BibTeX Integration *ale-bib-options* + + +=============================================================================== +bibclean *ale-bib-bibclean* + +g:ale_bib_bibclean_executable *g:ale_bib_bibclean_executable* + + Type: |String| + Default: `'bibclean'` + +g:ale_bib_bibclean_options *g:ale_bib_bibclean_options* + + Type: |String| + Default: `'-align-equals'` + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bicep.txt b/sources_non_forked/ale/doc/ale-bicep.txt new file mode 100644 index 00000000..d26d67bc --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bicep.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Bicep Integration *ale-bicep-options* + + +=============================================================================== +bicep *ale-bicep-bicep* + +g:ale_bicep_bicep_executable *g:ale_bicep_bicep_executable* + *b:ale_bicep_bicep_executable* + Type: |String| + Default: `'bicep'` + + This variable can be set to change the path to bicep. + + +g:ale_bicep_bicep_options *g:ale_bicep_bicep_options* + *b:ale_bicep_bicep_options* + Type: |String| + Default: `'build --outfile /dev/null'` + + This variable can be set to pass additional options to bicep. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-bitbake.txt b/sources_non_forked/ale/doc/ale-bitbake.txt new file mode 100644 index 00000000..4c480fd4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-bitbake.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE BitBake Integration *ale-bitbake-options* + + +=============================================================================== +oelint-adv *ale-bitbake-oelint_adv* + +g:ale_bitbake_oelint_adv_executable *g:ale_bitbake_oelint_adv_executable* + + Type: |String| + Default: `'oelint-adv'` + + This variable can be changed to use a different executable for oelint-adv. + +g:ale_bitbake_oelint_adv_options *g:ale_bitbake_oelint_adv_options* + + Type: |String| + Default: `''` + + This variable can be set to pass additional options to oelint-adv. + + g:ale_bitbake_oelint_adv_config *g:ale_bitbake_oelint_adv_config* + + Type: |String| + Default: `'.oelint.cfg'` + + This variable can be set to use a different config file. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-c.txt b/sources_non_forked/ale/doc/ale-c.txt new file mode 100644 index 00000000..29933861 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-c.txt @@ -0,0 +1,451 @@ +=============================================================================== +ALE C Integration *ale-c-options* + +For basic checking of problems with C files, ALE offers the `cc` linter, which +runs either `clang`, or `gcc`. See |ale-c-cc|. + + +=============================================================================== +Global Options + +g:ale_c_always_make *g:ale_c_always_make* + *b:ale_c_always_make* + Type: |Number| + Default: `has('unix') && !has('macunix')` + + If set to `1`, use `--always-make` for `make`, which means that output will + always be parsed from `make` dry runs with GNU make. BSD `make` does not + support this option, so you probably want to turn this option off when using + a BSD variant. + + +g:ale_c_build_dir_names *g:ale_c_build_dir_names* + *b:ale_c_build_dir_names* + + Type: |List| + Default: `['build', 'bin']` + + A list of directory names to be used when searching upwards from cpp files + to discover compilation databases with. For directory named `'foo'`, ALE + will search for `'foo/compile_commands.json'` in all directories on and + above the directory containing the cpp file to find path to compilation + database. This feature is useful for the clang tools wrapped around + LibTooling (namely here, clang-tidy) + + +g:ale_c_build_dir *g:ale_c_build_dir* + *b:ale_c_build_dir* + + Type: |String| + Default: `''` + + For programs that can read `compile_commands.json` files, this option can be + set to the directory containing the file for the project. ALE will try to + determine the location of `compile_commands.json` automatically, but if your + file exists in some other directory, you can set this option so ALE will + know where it is. + + This directory will be searched instead of |g:ale_c_build_dir_names|. + + +g:ale_c_parse_compile_commands *g:ale_c_parse_compile_commands* + *b:ale_c_parse_compile_commands* + Type: |Number| + Default: `1` + + If set to `1`, ALE will parse `compile_commands.json` files to automatically + determine flags for C or C++ compilers. ALE will first search for the + nearest `compile_commands.json` file, and then look for + `compile_commands.json` files in the directories for + |g:ale_c_build_dir_names|. + + +g:ale_c_parse_makefile *g:ale_c_parse_makefile* + *b:ale_c_parse_makefile* + Type: |Number| + Default: `0` + + If set to `1`, ALE will run `make -n` to automatically determine flags to + set for C or C++ compilers. This can make it easier to determine the correct + build flags to use for different files. + + NOTE: When using this option on BSD, you may need to set + |g:ale_c_always_make| to `0`, and `make -n` will not provide consistent + results if binaries have already been built, so use `make clean` when + editing your files. + + WARNING: Running `make -n` automatically can execute arbitrary code, even + though it's supposed to be a dry run, so enable this option with care. You + might prefer to use the buffer-local version of the option instead with + |g:ale_pattern_options|, or you own code for checking which project you're + in. + + You might want to disable this option if `make -n` takes too long to run for + projects you work on. + + If |g:ale_c_parse_compile_commands| or |b:ale_c_parse_compile_commands| is + set to `1`, flags taken from `compile_commands.json` will be preferred over + `make -n` output. + + +=============================================================================== +astyle *ale-c-astyle* + +g:ale_c_astyle_executable *g:ale_c_astyle_executable* + *b:ale_c_astyle_executable* + Type: |String| + Default: `'astyle'` + + This variable can be changed to use a different executable for astyle. + + +g:ale_c_astyle_project_options *g:ale_c_astyle_project_options* + *b:ale_c_astyle_project_options* + Type: |String| + Default: `''` + + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-c-cc* + *ale-c-gcc* + *ale-c-clang* + +g:ale_c_cc_executable *g:ale_c_cc_executable* + *b:ale_c_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C compiler. + + ALE will try to use `clang` if Clang is available, otherwise ALE will + default to checking C code with `gcc`. + + +g:ale_c_cc_options *g:ale_c_cc_options* + *b:ale_c_cc_options* + Type: |String| + Default: `'-std=c11 -Wall'` + + This variable can be changed to modify flags given to the C compiler. + + +g:ale_c_cc_use_header_lang_flag *g:ale_c_cc_use_header_lang_flag* + *b:ale_c_cc_use_header_lang_flag* + Type: |Number| + Default: `-1` + + By default, ALE will use `'-x c-header'` instead of `'-x c'` for header files + when using Clang. + + This variable can be changed to manually activate or deactivate this flag + for header files. + + - When set to `-1`, the default beviour is used, `'-x c-header'` is used with + Clang and `'-x c'` is used with other compilers. + - When set to `0`, the flag is deactivated, `'-x c'` is always used + independently of the compiler. + - When set to `1`, the flag is activated, `'-x c-header'` is always used + independently of the compiler. + + Gcc does not support `'-x c-header'` when using `'-'` as input filename, + which is what ALE does. This why, by default, ALE only uses `'-x c-header'` + with Clang. + + +g:ale_c_cc_header_exts *g:ale_c_cc_header_exts* + *b:ale_c_cc_header_exts* + Type: |List| + Default: `['h']` + + This variable can be changed to modify the list of extensions of the files + considered as header files. + + This variable is only used when `'-x c-header'` is used instead of `'-x c'`, + see |ale_c_cc_use_header_lang_flag|. + + +=============================================================================== +ccls *ale-c-ccls* + +g:ale_c_ccls_executable *g:ale_c_ccls_executable* + *b:ale_c_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_c_ccls_init_options *g:ale_c_ccls_init_options* + *b:ale_c_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + +=============================================================================== +clangd *ale-c-clangd* + +g:ale_c_clangd_executable *g:ale_c_clangd_executable* + *b:ale_c_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_c_clangd_options *g:ale_c_clangd_options* + *b:ale_c_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + +=============================================================================== +clang-format *ale-c-clangformat* + +g:ale_c_clangformat_executable *g:ale_c_clangformat_executable* + *b:ale_c_clangformat_executable* + Type: |String| + Default: `'clang-format'` + + This variable can be changed to use a different executable for clang-format. + + +g:ale_c_clangformat_options *g:ale_c_clangformat_options* + *b:ale_c_clangformat_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clang-format. + + +g:ale_c_clangformat_style_option *g:ale_c_clangformat_style_option* + *b:ale_c_clangformat_style_option* + Type: |String| + Default: `''` + + This variable can be changed to modify only the style flag given to + clang-format. The contents of the variable are passed directly to the -style + flag of clang-format. + + Example: > + { + \ BasedOnStyle: Microsoft, + \ ColumnLimit: 80, + \ AllowShortBlocksOnASingleLine: Always, + \ AllowShortFunctionsOnASingleLine: Inline, + \ } +< + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. + + +g:ale_c_clangformat_use_local_file *g:ale_c_clangformat_use_local_file* + *b:ale_c_clangformat_use_local_file* + Type: |Number| + Default: `0` + + This variable can be changed to modify whether to use a local .clang-format + file. If the file is found, the flag '-style=file' is passed to clang-format + and any options configured via |g:ale_c_clangformat_style_option| are not + passed. + + If this option is enabled but no .clang-format file is found, default back to + |g:ale_c_clangformat_style_option|, if it set. + + If you set this variable, ensure you don't modify -style in + |g:ale_c_clangformat_options|, as this will cause clang-format to error. + + +=============================================================================== +clangtidy *ale-c-clangtidy* + +`clang-tidy` will be run only when files are saved to disk, so that +`compile_commands.json` files can be used. It is recommended to use this +linter in combination with `compile_commands.json` files. +Therefore, `clang-tidy` linter reads the options |g:ale_c_build_dir| and +|g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually +overrides |g:ale_c_build_dir_names|. + + +g:ale_c_clangtidy_checks *g:ale_c_clangtidy_checks* + *b:ale_c_clangtidy_checks* + Type: |List| + Default: `[]` + + The checks to enable for clang-tidy with the `-checks` argument. + + All options will be joined with commas, and escaped appropriately for + the shell. The `-checks` flag can be removed entirely by setting this + option to an empty List. + + Not all of clangtidy checks are applicable for C. You should consult the + clang documentation for an up-to-date list of compatible checks: + http://clang.llvm.org/extra/clang-tidy/checks/list.html + + +g:ale_c_clangtidy_executable *g:ale_c_clangtidy_executable* + *b:ale_c_clangtidy_executable* + Type: |String| + Default: `'clang-tidy'` + + This variable can be changed to use a different executable for clangtidy. + + +g:ale_c_clangtidy_options *g:ale_c_clangtidy_options* + *b:ale_c_clangtidy_options* + Type: |String| + Default: `''` + + This variable can be changed to modify compiler flags given to clang-tidy. + + - Setting this variable to a non-empty string, + - and working in a buffer where no compilation database is found using + |g:ale_c_build_dir_names| or |g:ale_c_build_dir|, + will cause the `--` argument to be passed to `clang-tidy`, which will mean + that detection of `compile_commands.json` files for compile command + databases will be disabled. + Only set this option if you want to control compiler flags + entirely manually, and no `compile_commands.json` file is in one + of the |g:ale_c_build_dir_names| directories of the project tree. + + +g:ale_c_clangtidy_extra_options *g:ale_c_clangtidy_extra_options* + *b:ale_c_clangtidy_extra_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clang-tidy. + + +g:ale_c_clangtidy_fix_errors *g:ale_c_clangtidy_fix_errors* + *b:ale_c_clangtidy_fix_errors* + Type: |Number| + Default: `1` + + This variable can be changed to disable the `-fix-errors` option for the + |clangtidy| fixer. + + +=============================================================================== +cppcheck *ale-c-cppcheck* + +g:ale_c_cppcheck_executable *g:ale_c_cppcheck_executable* + *b:ale_c_cppcheck_executable* + Type: |String| + Default: `'cppcheck'` + + This variable can be changed to use a different executable for cppcheck. + + +g:ale_c_cppcheck_options *g:ale_c_cppcheck_options* + *b:ale_c_cppcheck_options* + Type: |String| + Default: `'--enable=style'` + + This variable can be changed to modify flags given to cppcheck. + + +=============================================================================== +cquery *ale-c-cquery* + +g:ale_c_cquery_executable *g:ale_c_cquery_executable* + *b:ale_c_cquery_executable* + Type: |String| + Default: `'cquery'` + + This variable can be changed to use a different executable for cquery. + + +g:ale_cpp_cquery_cache_directory *g:ale_c_cquery_cache_directory* + *b:ale_c_cquery_cache_directory* + Type: |String| + Default: `'~/.cache/cquery'` + + This variable can be changed to decide which directory cquery uses for its +cache. + + +=============================================================================== +cspell *ale-c-cspell* + +See |ale-cspell-options| + + +=============================================================================== +flawfinder *ale-c-flawfinder* + +g:ale_c_flawfinder_executable *g:ale_c_flawfinder_executable* + *b:ale_c_flawfinder_executable* + Type: |String| + Default: `'flawfinder'` + + This variable can be changed to use a different executable for flawfinder. + + +g:ale_c_flawfinder_minlevel *g:ale_c_flawfinder_minlevel* + *b:ale_c_flawfinder_minlevel* + Type: |Number| + Default: `1` + + This variable can be changed to ignore risks under the given risk threshold. + + +g:ale_c_flawfinder_options *g:ale-c-flawfinder* + *b:ale-c-flawfinder* + Type: |String| + Default: `''` + + This variable can be used to pass extra options into the flawfinder command. + +g:ale_c_flawfinder_error_severity *g:ale_c_flawfinder_error_severity* + *b:ale_c_flawfinder_error_severity* + Type: |Number| + Default: `6` + + This variable can be changed to set the minimum severity to be treated as an + error. This setting also applies to flawfinder for c++. + + +=============================================================================== +uncrustify *ale-c-uncrustify* + +g:ale_c_uncrustify_executable *g:ale_c_uncrustify_executable* + *b:ale_c_uncrustify_executable* + Type: |String| + Default: `'uncrustify'` + + This variable can be changed to use a different executable for uncrustify. + + +g:ale_c_uncrustify_options *g:ale_c_uncrustify_options* + *b:ale_c_uncrustify_options* + Type: |String| + Default: `''` + + This variable can be change to modify flags given to uncrustify. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cairo.txt b/sources_non_forked/ale/doc/ale-cairo.txt new file mode 100644 index 00000000..0a78e68a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cairo.txt @@ -0,0 +1,15 @@ +=============================================================================== +ALE Cairo Integration *ale-cairo-options* + + +=============================================================================== +starknet *ale-cairo-starknet* + +g:ale_cairo_starknet_executable *g:ale_cairo_starknet_executable* + *b:ale_cairo_starknet_executable* + + Default: `'starknet-compile'` + + Overrides the starknet-compile binary after installing the cairo-language. + + For more information read 'https://starknet.io/docs/quickstart.html' diff --git a/sources_non_forked/ale/doc/ale-chef.txt b/sources_non_forked/ale/doc/ale-chef.txt new file mode 100644 index 00000000..75e144ec --- /dev/null +++ b/sources_non_forked/ale/doc/ale-chef.txt @@ -0,0 +1,46 @@ +=============================================================================== +ALE Chef Integration *ale-chef-options* + + +=============================================================================== +cookstyle *ale-chef-cookstyle* + +g:ale_chef_cookstyle_options *g:ale_chef_cookstyle_options* + *b:ale_chef_cookstyle_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to cookstyle. + + +g:ale_chef_cookstyle_executable *g:ale_chef_cookstyle_executable* + *b:ale_chef_cookstyle_executable* + Type: |String| + Default: `'cookstyle'` + + This variable can be changed to point to the cookstyle binary in case it's + not on the $PATH or a specific version/path must be used. + + +=============================================================================== +foodcritic *ale-chef-foodcritic* + +g:ale_chef_foodcritic_options *g:ale_chef_foodcritic_options* + *b:ale_chef_foodcritic_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to foodcritic. + + +g:ale_chef_foodcritic_executable *g:ale_chef_foodcritic_executable* + *b:ale_chef_foodcritic_executable* + Type: |String| + Default: `'foodcritic'` + + This variable can be changed to point to the foodcritic binary in case it's + not on the $PATH or a specific version/path must be used. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-clojure.txt b/sources_non_forked/ale/doc/ale-clojure.txt new file mode 100644 index 00000000..3ff367f6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-clojure.txt @@ -0,0 +1,36 @@ +=============================================================================== +ALE Clojure Integration *ale-clojure-options* + + +=============================================================================== +clj-kondo *ale-clojure-clj-kondo* + +A minimal and opinionated linter for code that sparks joy. + +https://github.com/borkdude/clj-kondo + +g:ale_clojure_clj_kondo_options *g:ale_clojure_clj_kondo_options* + *b:ale_clojure_clj_kondo_options* + Type: |String| + Default: `'--cache'` + + This variable can be changed to modify options passed to clj-kondo. + + +=============================================================================== +joker *ale-clojure-joker* + +Joker is a small Clojure interpreter and linter written in Go. + +https://github.com/candid82/joker + +Linting options are not configurable by ale, but instead are controlled by a +`.joker` file in same directory as the file (or current working directory if +linting stdin), a parent directory relative to the file, or the users home +directory. + +see https://github.com/candid82/joker#linter-mode for more information. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-cloudformation.txt b/sources_non_forked/ale/doc/ale-cloudformation.txt new file mode 100644 index 00000000..9724403b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cloudformation.txt @@ -0,0 +1,46 @@ +=============================================================================== +ALE CloudFormation Integration *ale-cloudformation-options* + + +=============================================================================== +cfn-python-lint *ale-cloudformation-cfn-python-lint* + +cfn-python-lint is a linter for AWS CloudFormation template file. + +Website: https://github.com/awslabs/cfn-python-lint + +Installation +------------------------------------------------------------------------------- + + +Install cfn-python-lint using either pip or brew: > + +`pip install cfn-lint`. If pip is not available, run +`python setup.py clean --all` then `python setup.py install`. + + Homebrew (macOS): + +`brew install cfn-lint` + +< +Configuration +------------------------------------------------------------------------------- + +To get cloudformation linter to work on only CloudFormation files we must set +the buffer |filetype| to yaml.cloudformation. +This causes ALE to lint the file with linters configured for cloudformation and +yaml files. + +Just put: + +> + + au BufRead,BufNewFile *.template.yaml set filetype=yaml.cloudformation + +< + +on `ftdetect/cloudformation.vim` + +This will get both cloudformation and yaml linters to work on any file with `.template.yaml` ext. +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cmake.txt b/sources_non_forked/ale/doc/ale-cmake.txt new file mode 100644 index 00000000..e44c328e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cmake.txt @@ -0,0 +1,62 @@ +=============================================================================== +ALE CMake Integration *ale-cmake-options* + + +=============================================================================== +cmakelint *ale-cmake-cmakelint* + +g:ale_cmake_cmakelint_executable *g:ale_cmake_cmakelint_executable* + *b:ale_cmake_cmakelint_executable* + Type: |String| + Default: `'cmakelint'` + + This variable can be set to change the path the cmakelint. + + +g:ale_cmake_cmakelint_options *g:ale_cmake_cmakelint_options* + *b:ale_cmake_cmakelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to cmakelint. + + +=============================================================================== +cmake-lint *ale-cmake-cmake-lint* + +g:ale_cmake_cmake_lint_executable *g:ale_cmake_cmake_lint_executable* + *b:ale_cmake_cmake_lint_executable* + Type: |String| + Default: `'cmake-lint'` + + This variable can be set to change the path the cmake-lint. + + +g:ale_cmake_cmake_lint_options *g:ale_cmake_cmake_lint_options* + *b:ale_cmake_cmake_lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to cmake-lint. + + +=============================================================================== +cmake-format *ale-cmake-cmakeformat* + +g:ale_cmake_cmakeformat_executable *g:ale_cmake_cmakeformat_executable* + *b:ale_cmake_cmakeformat_executable* + Type: |String| + Default: `'cmakeformat'` + + This variable can be set to change the path the cmake-format. + + +g:ale_cmake_cmakeformat_options *g:ale_cmake_cmakeformat_options* + *b:ale_cmake_cmakeformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to cmake-format. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cpp.txt b/sources_non_forked/ale/doc/ale-cpp.txt new file mode 100644 index 00000000..1ed6d371 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cpp.txt @@ -0,0 +1,401 @@ +=============================================================================== +ALE C++ Integration *ale-cpp-options* + +For basic checking of problems with C++ files, ALE offers the `cc` linter, +which runs either `clang++`, or `gcc`. See |ale-cpp-cc|. + + +=============================================================================== +Global Options + +The following C options also apply to some C++ linters too. + +* |g:ale_c_always_make| +* |g:ale_c_build_dir_names| +* |g:ale_c_build_dir| +* |g:ale_c_parse_makefile| +* |g:ale_c_parse_compile_commands| + + +=============================================================================== +astyle *ale-cpp-astyle* + +g:ale_cpp_astyle_executable *g:ale_cpp_astyle_executable* + *b:ale_cpp_astyle_executable* + Type: |String| + Default: `'astyle'` + + This variable can be changed to use a different executable for astyle. + + +g:ale_cpp_astyle_project_options *g:ale_cpp_astyle_project_options* + *b:ale_cpp_astyle_project_options* + Type: |String| + Default: `''` + + This variable can be changed to use an option file for project level + configurations. Provide only the filename of the option file that should be + present at the project's root directory. + + For example, if .astylrc is specified, the file is searched in the parent + directories of the source file's directory. + + +=============================================================================== +cc *ale-cpp-cc* + *ale-cpp-gcc* + *ale-cpp-clang* + +g:ale_cpp_cc_executable *g:ale_cpp_cc_executable* + *b:ale_cpp_cc_executable* + Type: |String| + Default: `''` + + This variable can be changed to use a different executable for a C++ compiler. + + ALE will try to use `clang++` if Clang is available, otherwise ALE will + default to checking C++ code with `gcc`. + + +g:ale_cpp_cc_options *g:ale_cpp_cc_options* + *b:ale_cpp_cc_options* + Type: |String| + Default: `'-std=c++14 -Wall'` + + This variable can be changed to modify flags given to the C++ compiler. + + +g:ale_cpp_cc_use_header_lang_flag *g:ale_cpp_cc_use_header_lang_flag* + *b:ale_cpp_cc_use_header_lang_flag* + Type: |Number| + Default: `-1` + + By default, ALE will use `'-x c++-header'` instead of `'-x c++'` for header + files when using Clang. + + This variable can be changed to manually activate or deactivate this flag + for header files. + + - When set to `-1`, the default beviour is used, `'-x c++-header'` is used with + Clang and `'-x c++'` is used with other compilers. + - When set to `0`, the flag is deactivated, `'-x c++'` is always used + independently of the compiler. + - When set to `1`, the flag is activated, `'-x c++-header'` is always used + independently of the compiler. + + Gcc does not support `'-x c++-header'` when using `'-'` as input filename, + which is what ALE does. This why, by default, ALE only uses `'-x c++-header'` + with Clang. + + +g:ale_cpp_cc_header_exts *g:ale_cpp_cc_header_exts* + *b:ale_cpp_cc_header_exts* + Type: |List| + Default: `['h', 'hpp']` + + This variable can be changed to modify the list of extensions of the files + considered as header files. + + This variable is only used when `'-x c++-header'` is used instead of `'-x c++'`, + see |ale_cpp_cc_use_header_lang_flag|. + + +=============================================================================== +ccls *ale-cpp-ccls* + +g:ale_cpp_ccls_executable *g:ale_cpp_ccls_executable* + *b:ale_cpp_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_cpp_ccls_init_options *g:ale_cpp_ccls_init_options* + *b:ale_cpp_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + +=============================================================================== +clangcheck *ale-cpp-clangcheck* + +`clang-check` will be run only when files are saved to disk, so that +`compile_commands.json` files can be used. It is recommended to use this +linter in combination with `compile_commands.json` files. +Therefore, `clang-check` linter reads the options |g:ale_c_build_dir| and +|g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually +overrides |g:ale_c_build_dir_names|. + + +g:ale_cpp_clangcheck_executable *g:ale_cpp_clangcheck_executable* + *b:ale_cpp_clangcheck_executable* + Type: |String| + Default: `'clang-check'` + + This variable can be changed to use a different executable for clangcheck. + + +g:ale_cpp_clangcheck_options *g:ale_cpp_clangcheck_options* + *b:ale_cpp_clangcheck_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clang-check. + + This variable should not be set to point to build subdirectory with + `-p path/to/build` option, as it is handled by the |g:ale_c_build_dir| + option. + + +=============================================================================== +clangd *ale-cpp-clangd* + +g:ale_cpp_clangd_executable *g:ale_cpp_clangd_executable* + *b:ale_cpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cpp_clangd_options *g:ale_cpp_clangd_options* + *b:ale_cpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + +=============================================================================== +clang-format *ale-cpp-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for C++. + + +=============================================================================== +clangtidy *ale-cpp-clangtidy* + +`clang-tidy` will be run only when files are saved to disk, so that +`compile_commands.json` files can be used. It is recommended to use this +linter in combination with `compile_commands.json` files. +Therefore, `clang-tidy` linter reads the options |g:ale_c_build_dir| and +|g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually +overrides |g:ale_c_build_dir_names|. + + +g:ale_cpp_clangtidy_checks *g:ale_cpp_clangtidy_checks* + *b:ale_cpp_clangtidy_checks* + Type: |List| + Default: `[]` + + The checks to enable for clang-tidy with the `-checks` argument. + + All options will be joined with commas, and escaped appropriately for + the shell. The `-checks` flag can be removed entirely by setting this + option to an empty List. + + +g:ale_cpp_clangtidy_executable *g:ale_cpp_clangtidy_executable* + *b:ale_cpp_clangtidy_executable* + Type: |String| + Default: `'clang-tidy'` + + This variable can be changed to use a different executable for clangtidy. + + +g:ale_cpp_clangtidy_options *g:ale_cpp_clangtidy_options* + *b:ale_cpp_clangtidy_options* + Type: |String| + Default: `''` + + This variable can be changed to modify compiler flags given to clang-tidy. + + - Setting this variable to a non-empty string, + - and working in a buffer where no compilation database is found using + |g:ale_c_build_dir_names| or |g:ale_c_build_dir|, + will cause the `--` argument to be passed to `clang-tidy`, which will mean + that detection of `compile_commands.json` files for compile command + databases will be disabled. + Only set this option if you want to control compiler flags + entirely manually, and no `compile_commands.json` file is in one + of the |g:ale_c_build_dir_names| directories of the project tree. + + +g:ale_cpp_clangtidy_extra_options *g:ale_cpp_clangtidy_extra_options* + *b:ale_cpp_clangtidy_extra_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clang-tidy. + + +g:ale_cpp_clangtidy_fix_errors *g:ale_cpp_clangtidy_fix_errors* + *b:ale_cpp_clangtidy_fix_errors* + Type: |Number| + Default: `1` + + This variable can be changed to disable the `-fix-errors` option for the + |clangtidy| fixer. + + +=============================================================================== +clazy *ale-cpp-clazy* + +g:ale_cpp_clazy_executable *g:ale_cpp_clazy_executable* + *b:ale_cpp_clazy_executable* + Type: |String| + Default: `'clazy-standalone'` + + This variable can be changed to use a different executable for clazy. + + +g:ale_cpp_clazy_checks *g:ale_cpp_clazy_checks* + *b:ale_cpp_clazy_checks* + Type: |List| + Default: `['level1']` + + The checks to enable for clazy with the `-checks` argument. + + All options will be joined with commas, and escaped appropriately for + the shell. The `-checks` flag can be removed entirely by setting this + option to an empty List. + + +g:ale_cpp_clazy_options *g:ale_cpp_clazy_options* + *b:ale_cpp_clazy_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clazy. + + +=============================================================================== +cppcheck *ale-cpp-cppcheck* + +g:ale_cpp_cppcheck_executable *g:ale_cpp_cppcheck_executable* + *b:ale_cpp_cppcheck_executable* + Type: |String| + Default: `'cppcheck'` + + This variable can be changed to use a different executable for cppcheck. + + +g:ale_cpp_cppcheck_options *g:ale_cpp_cppcheck_options* + *b:ale_cpp_cppcheck_options* + Type: |String| + Default: `'--enable=style'` + + This variable can be changed to modify flags given to cppcheck. + + +=============================================================================== +cpplint *ale-cpp-cpplint* + +g:ale_cpp_cpplint_executable *g:ale_cpp_cpplint_executable* + *b:ale_cpp_cpplint_executable* + Type: |String| + Default: `'cpplint'` + + This variable can be changed to use a different executable for cpplint. + + +g:ale_cpp_cpplint_options *g:ale_cpp_cpplint_options* + *b:ale_cpp_cpplint_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to cpplint. + +g:ale_c_cpplint_executable *g:ale_c_cpplint_executable* + *b:ale_c_cpplint_executable* + Type: |String| + Default: `'cpplint'` + + This variable can be changed to use a different executable for cpplint. + + +g:ale_c_cpplint_options *g:ale_c_cpplint_options* + *b:ale_c_cpplint_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to cpplint. + + +=============================================================================== +cquery *ale-cpp-cquery* + +g:ale_cpp_cquery_executable *g:ale_cpp_cquery_executable* + *b:ale_cpp_cquery_executable* + Type: |String| + Default: `'cquery'` + + This variable can be changed to use a different executable for cquery. + + +g:ale_cpp_cquery_cache_directory *g:ale_cpp_cquery_cache_directory* + *b:ale_cpp_cquery_cache_directory* + Type: |String| + Default: `'~/.cache/cquery'` + + This variable can be changed to decide which directory cquery uses for its + cache. + + +=============================================================================== +cspell *ale-cpp-cspell* + +See |ale-cspell-options| + + +=============================================================================== +flawfinder *ale-cpp-flawfinder* + +g:ale_cpp_flawfinder_executable *g:ale_cpp_flawfinder_executable* + *b:ale_cpp_flawfinder_executable* + Type: |String| + Default: `'flawfinder'` + + This variable can be changed to use a different executable for flawfinder. + + +g:ale_cpp_flawfinder_minlevel *g:ale_cpp_flawfinder_minlevel* + *b:ale_cpp_flawfinder_minlevel* + Type: |Number| + Default: `1` + + This variable can be changed to ignore risks under the given risk threshold. + + +g:ale_cpp_flawfinder_options *g:ale-cpp-flawfinder* + *b:ale-cpp-flawfinder* + Type: |String| + Default: `''` + + This variable can be used to pass extra options into the flawfinder command. + + +=============================================================================== +uncrustify *ale-cpp-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cs.txt b/sources_non_forked/ale/doc/ale-cs.txt new file mode 100644 index 00000000..26e2b023 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cs.txt @@ -0,0 +1,236 @@ +=============================================================================== +ALE C# Integration *ale-cs-options* + + +In addition to the linters that are provided with ALE, C# code can be checked +with the OmniSharp plugin. See here: https://github.com/OmniSharp/omnisharp-vim + + +=============================================================================== +csc *ale-cs-csc* + + The |ale-cs-csc| linter checks for semantic errors when files are opened or + saved. + + See |ale-lint-file-linters| for more information on linters which do not + check for problems while you type. + + The csc linter uses the mono csc compiler, providing full C# 7 and newer + support, to generate a temporary module target file (/t:module). The module + includes all '*.cs' files contained in the directory tree rooted at the path + defined by the |g:ale_cs_csc_source| or |b:ale_cs_csc_source| variable and + all sub directories. + + It will in future replace the |ale-cs-mcs| and |ale-cs-mcsc| linters as both + utilize the mcsc compiler which, according to the mono project, is no longer + actively developed, and only receives maintenance updates. However, because + the csc compiler does not support the -syntax option, this linter does not + offer any as-you-type syntax checking, similar to the |ale-cs-mcsc| linter. + + The paths to search for additional assembly files can be specified using the + |g:ale_cs_csc_assembly_path| or |b:ale_cs_csc_assembly_path| variables. + + NOTE: ALE will not find any errors in files apart from syntax errors if any + one of the source files contains a syntax error. Syntax errors must be fixed + first before other errors will be shown. + + +g:ale_cs_csc_options *g:ale_cs_csc_options* + *b:ale_cs_csc_options* + Type: |String| + Default: `''` + + This option can be set to pass additional arguments to the `csc` compiler. + + For example, to add the dotnet package which is not added per default: > + + let g:ale_cs_mcs_options = ' /warn:4 /langversion:7.2' +< + NOTE: the `/unsafe` option is always passed to `csc`. + + +g:ale_cs_csc_source *g:ale_cs_csc_source* + *b:ale_cs_csc_source* + Type: |String| + Default: `''` + + This variable defines the root path of the directory tree searched for the + '*.cs' files to be linted. If this option is empty, the source file's + directory will be used. + + NOTE: Currently it is not possible to specify sub directories and + directory sub trees which shall not be searched for *.cs files. + + +g:ale_cs_csc_assembly_path *g:ale_cs_csc_assembly_path* + *b:ale_cs_csc_assembly_path* + Type: |List| + Default: `[]` + + This variable defines a list of path strings to be searched for external + assembly files. The list is passed to the csc compiler using the `/lib:` + flag. + + +g:ale_cs_csc_assemblies *g:ale_cs_csc_assemblies* + *b:ale_cs_csc_assemblies* + Type: |List| + Default: `[]` + + This variable defines a list of external assembly (*.dll) files required + by the mono mcs compiler to generate a valid module target. The list is + passed the csc compiler using the `/r:` flag. + + For example: > + + " Compile C# programs with the Unity engine DLL file on Mac. + let g:ale_cs_mcsc_assemblies = [ + \ '/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll', + \ 'path-to-unityproject/obj/Debug', + \] +< + +=============================================================================== +cspell *ale-cs-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dotnet-format *ale-cs-dotnet-format* + +Installation +------------------------------------------------------------------------------- + +Installing .NET SDK should probably ensure that `dotnet` is in your `$PATH`. +For .NET 6 the `dotnet format` tool is already included in the .NET SDK. For +.NET 5 or below you will have to manually install it using the instructions +from listed in this repository: https://github.com/dotnet/format + + +Options +------------------------------------------------------------------------------- + +g:ale_cs_dotnet_format_executable *g:ale_cs_dotnet_format_executable* + *b:ale_cs_dotnet_format_executable* + Type: |String| + Default: `'dotnet'` + + This variable can be set to specify an absolute path to the + `dotnet` executable (or to specify an alternate executable). + + +g:ale_cs_dotnet_format_options *g:ale_cs_dotnet_format_options* + *b:ale_cs_dotnet_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the `dotnet format` + fixer. + + +=============================================================================== +mcs *ale-cs-mcs* + + The `mcs` linter looks only for syntax errors while you type. See + |ale-cs-mcsc| for the separately configured linter for checking for semantic + errors. + + +g:ale_cs_mcs_options *g:ale_cs_mcs_options* + *b:ale_cs_mcs_options* + + Type: String + Default: `''` + + This variable can be changed to pass additional flags given to mcs. + + NOTE: The -unsafe flag is selected implicitly and thus does not need to be + explicitly included in the |g:ale_cs_mcs_options| or |b:ale_cs_mcs_options| + parameter. + + +=============================================================================== +mcsc *ale-cs-mcsc* + + The mcsc linter checks for semantic errors when files are opened or saved + See |ale-lint-file-linters| for more information on linters which do not + check for problems while you type. + + The mcsc linter uses the mono mcs compiler to generate a temporary module + target file (-t:module). The module includes including all '*.cs' files + contained in the directory tree rooted at the path defined by the + |g:ale_cs_mcsc_source| or |b:ale_cs_mcsc_source| variable. + variable and all sub directories. + + The paths to search for additional assembly files can be specified using the + |g:ale_cs_mcsc_assembly_path| or |b:ale_cs_mcsc_assembly_path| variables. + + NOTE: ALE will not find any errors in files apart from syntax errors if any + one of the source files contains a syntax error. Syntax errors must be fixed + first before other errors will be shown. + + +g:ale_cs_mcsc_options *g:ale_cs_mcsc_options* + *b:ale_cs_mcsc_options* + Type: |String| + Default: `''` + + This option can be set to pass additional arguments to the `mcs` compiler. + + For example, to add the dotnet package which is not added per default: > + + let g:ale_cs_mcs_options = '-pkg:dotnet' +< + NOTE: the `-unsafe` option is always passed to `mcs`. + + +g:ale_cs_mcsc_source *g:ale_cs_mcsc_source* + *b:ale_cs_mcsc_source* + Type: |String| + Default: `''` + + This variable defines the root path of the directory tree searched for the + '*.cs' files to be linted. If this option is empty, the source file's + directory will be used. + + NOTE: Currently it is not possible to specify sub directories and + directory sub trees which shall not be searched for *.cs files. + + +g:ale_cs_mcsc_assembly_path *g:ale_cs_mcsc_assembly_path* + *b:ale_cs_mcsc_assembly_path* + Type: |List| + Default: `[]` + + This variable defines a list of path strings to be searched for external + assembly files. The list is passed to the mcs compiler using the `-lib:` + flag. + + +g:ale_cs_mcsc_assemblies *g:ale_cs_mcsc_assemblies* + *b:ale_cs_mcsc_assemblies* + Type: |List| + Default: `[]` + + This variable defines a list of external assembly (*.dll) files required + by the mono mcs compiler to generate a valid module target. The list is + passed the mcs compiler using the `-r:` flag. + + For example: > + + " Compile C# programs with the Unity engine DLL file on Mac. + let g:ale_cs_mcsc_assemblies = [ + \ '/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll', + \ 'path-to-unityproject/obj/Debug', + \] +< + +=============================================================================== +uncrustify *ale-cs-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-css.txt b/sources_non_forked/ale/doc/ale-css.txt new file mode 100644 index 00000000..74ca16dd --- /dev/null +++ b/sources_non_forked/ale/doc/ale-css.txt @@ -0,0 +1,93 @@ +=============================================================================== +ALE CSS Integration *ale-css-options* + + +=============================================================================== +cspell *ale-css-cspell* + +See |ale-cspell-options| + + +=============================================================================== +css-beautify *ale-css-css-beautify* + +g:ale_css_css_beautify_executable *g:ale_css_css_beautify_executable* + *b:ale_css_css_beautify_executable* + Type: |String| + Default: `'css-beautify'` + + See |ale-integrations-local-executables| + + +g:ale_css_css_beautify_options *g:ale_css_css_beautify_options* + *b:ale_css_css_beautify_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to css-beautify. + + +g:ale_css_css_beautify_use_global *g:ale_css_css_beautify_use_global* + *b:ale_css_css_beautify_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +fecs *ale-css-fecs* + +`fecs` options for CSS is the same as the options for JavaScript, and both of +them reads `./.fecsrc` as the default configuration file. See: +|ale-javascript-fecs|. + + +=============================================================================== +prettier *ale-css-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +stylelint *ale-css-stylelint* + +g:ale_css_stylelint_executable *g:ale_css_stylelint_executable* + *b:ale_css_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_css_stylelint_options *g:ale_css_stylelint_options* + *b:ale_css_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_css_stylelint_use_global *g:ale_css_stylelint_use_global* + *b:ale_css_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +vscodecss *ale-css-vscode* + +Website: https://github.com/hrsh7th/vscode-langservers-extracted + +Installation +------------------------------------------------------------------------------- + +Install VSCode css language server either globally or locally: > + + npm install -g vscode-langservers-extracted +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-cuda.txt b/sources_non_forked/ale/doc/ale-cuda.txt new file mode 100644 index 00000000..06aa48ce --- /dev/null +++ b/sources_non_forked/ale/doc/ale-cuda.txt @@ -0,0 +1,50 @@ +=============================================================================== +ALE CUDA Integration *ale-cuda-options* + + +=============================================================================== +nvcc *ale-cuda-nvcc* + +g:ale_cuda_nvcc_executable *g:ale_cuda_nvcc_executable* + *b:ale_cuda_nvcc_executable* + Type: |String| + Default: `'nvcc'` + + This variable can be changed to use a different executable for nvcc. + Currently only nvcc 8.0 is supported. + + +g:ale_cuda_nvcc_options *g:ale_cuda_nvcc_options* + *b:ale_cuda_nvcc_options* + Type: |String| + Default: `'-std=c++11'` + + This variable can be changed to modify flags given to nvcc. + +=============================================================================== +clangd *ale-cuda-clangd* + +g:ale_cuda_clangd_executable *g:ale_cuda_clangd_executable* + *b:ale_cuda_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_cuda_clangd_options *g:ale_cuda_clangd_options* + *b:ale_cuda_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + +=============================================================================== +clang-format *ale-cuda-clangformat* + +See |ale-c-clangformat| for information about the available options. +Note that the C options are also used for cuda. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-d.txt b/sources_non_forked/ale/doc/ale-d.txt new file mode 100644 index 00000000..72349a20 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-d.txt @@ -0,0 +1,32 @@ +=============================================================================== +ALE D Integration *ale-d-options* + +=============================================================================== +dfmt *ale-d-dfmt* + +g:ale_d_dfmt_options *g:ale_d_dfmt_options* + *b:ale_d_dfmt_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the dfmt fixer. + +=============================================================================== +dls *ale-d-dls* + +g:ale_d_dls_executable *g:ale_d_dls_executable* + *b:ale_d_dls_executable* + Type: |String| + Default: `dls` + +See |ale-integrations-local-executables| + + +=============================================================================== +uncrustify *ale-d-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dafny.txt b/sources_non_forked/ale/doc/ale-dafny.txt new file mode 100644 index 00000000..005170ad --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dafny.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Dafny Integration *ale-dafny-options* + + +=============================================================================== +dafny *ale-dafny-dafny* + +g:ale_dafny_dafny_timelimit *g:ale_dafny_dafny_timelimit* + *b:ale_dafny_dafny_timelimit* + Type: |Number| + Default: `10` + + This variable sets the `/timeLimit` used for dafny. + + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dart.txt b/sources_non_forked/ale/doc/ale-dart.txt new file mode 100644 index 00000000..4824e82e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dart.txt @@ -0,0 +1,124 @@ +=============================================================================== +ALE Dart Integration *ale-dart-options* + + +=============================================================================== +analysis_server *ale-dart-analysis_server* + +Installation +------------------------------------------------------------------------------- + +Install Dart via whatever means. `analysis_server` will be included in the SDK. + +In case that `dart` is not in your path, try to set the executable option to +its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_analysis_server_executable = '/usr/local/bin/dart' +< + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analysis_server_executable *g:ale_dart_analysis_server_executable* + *b:ale_dart_analysis_server_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to change the path of dart. + + +=============================================================================== +dart-analyze *ale-dart-analyze* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Install Dart via whatever means. `dart analyze` will be included in the SDK. + +Options +------------------------------------------------------------------------------- + +g:ale_dart_analyze_executable *g:ale_dart_analyze_executable* + *b:ale_dart_analyze_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +=============================================================================== +dart-format *ale-dart-format* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dart` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dart to the absolute path to it. + let g:ale_dart_format_executable = '/usr/lib/dart/bin/dart' + > + +Options +------------------------------------------------------------------------------- + +g:ale_dart_format_executable *g:ale_dart_format_executable* + *b:ale_dart_format_executable* + Type: |String| + Default: `'dart'` + + This variable can be set to specify an absolute path to the + format executable (or to specify an alternate executable). + + +g:ale_dart_format_options *g:ale_dart_format_options* + *b:ale_dart_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dart format fixer. + + +=============================================================================== +dartfmt *ale-dart-dartfmt* + +Installation +------------------------------------------------------------------------------- + +Installing Dart should probably ensure that `dartfmt` is in your `$PATH`. + +In case it is not, try to set the executable option to its absolute path. : > + " Set the executable path for dartfmt to the absolute path to it. + let g:ale_dart_dartfmt_executable = '/usr/lib/dart/bin/dartfmt' + > + +Options +------------------------------------------------------------------------------- + +g:ale_dart_dartfmt_executable *g:ale_dart_dartfmt_executable* + *b:ale_dart_dartfmt_executable* + Type: |String| + Default: `''` + + This variable can be set to specify an absolute path to the + dartfmt executable (or to specify an alternate executable). + + +g:ale_dart_dartfmt_options *g:ale_dart_dartfmt_options* + *b:ale_dart_dartfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dartfmt fixer. + +=============================================================================== + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-desktop.txt b/sources_non_forked/ale/doc/ale-desktop.txt new file mode 100644 index 00000000..62269e9c --- /dev/null +++ b/sources_non_forked/ale/doc/ale-desktop.txt @@ -0,0 +1,21 @@ +=============================================================================== +ALE desktop Integration *ale-desktop-options* + + +=============================================================================== +desktop-file-validate *ale-desktop-desktop-file-validate* + +ALE supports checking .desktop files with `desktop-file-validate.` + + +g:ale_desktop_desktop_file_validate_options + *g:ale_desktop_desktop_file_validate_options* + *b:ale_desktop_desktop_file_validate_options* + Type: |String| + Default: `''` + + This variable can be changed to set options for `desktop-file-validate`, + such as `'--warn-kde'`. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-development.txt b/sources_non_forked/ale/doc/ale-development.txt new file mode 100644 index 00000000..a0bba468 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-development.txt @@ -0,0 +1,466 @@ +*ale-development.txt* For Vim version 8.0. +*ale-dev* +*ale-development* + +ALE Development Documentation + +=============================================================================== +CONTENTS *ale-development-contents* + + 1. Introduction.........................|ale-development-introduction| + 2. Design Goals.........................|ale-design-goals| + 3. Coding Standards.....................|ale-coding-standards| + 4. Testing ALE..........................|ale-development-tests| + 4.1. Writing Linter Tests.............|ale-development-linter-tests| + 4.2. Writing Fixer Tests..............|ale-development-fixer-tests| + 4.3. Running Tests in a Windows VM....|ale-development-windows-tests| + 5. Contributing.........................|ale-development-contributing| + +=============================================================================== +1. Introduction *ale-development-introduction* + +This document contains helpful information for ALE developers, including +design goals, information on how to run the tests, coding standards, and so +on. You should read this document if you want to get involved with ALE +development. + +=============================================================================== +2. Design Goals *ale-design-goals* + +This section lists design goals for ALE, in no particular order. They are as +follows. + +ALE code should be almost 100% VimL. This makes the plugin as portable as +possible. + +ALE should run without needing any other plugins to be installed, to make +installation simple. ALE can integrate with other plugins for more advanced +functionality, non-essential functionality, or improving on basic first party +functionality. + +ALE should check files with as many tools as possible by default, except where +they cause security issues or make excessive use of resources on modern +machines. + +ALE should be free of breaking changes to the public API, which is comprised of +documented functions and options, until a major version is planned. Breaking +changes should be preceded by a deprecation phase complete with warnings. +Changes required for security may be an exception. + +ALE supports Vim 8 and above, and NeoVim 0.2.0 or newer. These are the +earliest versions of Vim and NeoVim which support |job|, |timer|, |closure|, +and |lambda| features. All ALE code should be written so it is compatible with +these versions of Vim, or with version checks so particular features can +degrade or fail gracefully. + +Just about everything should be documented and covered with tests. + +By and large, people shouldn't pay for the functionality they don't use. Care +should be taken when adding new features, so supporting new features doesn't +degrade the general performance of anything ALE does. + +LSP support will become more important as time goes on. ALE should provide +better support for LSP features as time goes on. + +When merging pull requests, you should respond with `Cheers! :beers:`, purely +for comedy value. + +=============================================================================== +3. Coding Standards *ale-coding-standards* + +The following general coding standards should be adhered to for Vim code. + +* Check your Vim code with `Vint` and do everything it says. ALE will check + your Vim code with Vint automatically. See: https://github.com/Kuniwak/vint + Read ALE's `Dockerfile` to see which version of `Vint` it uses. +* Try to write descriptive and concise names for variables and functions. + Names shouldn't be too short or too long. Think about others reading your + code later on. +* Use `snake_case` names for variables and arguments, and `PascalCase` names + for functions. Prefix every variable name with its scope. (`l:`, `g:`, etc.) +* Try to keep lines no longer than 80 characters, but this isn't an absolute + requirement. +* Use 4 spaces for every level of indentation in Vim code. +* Add a blank line before every `function`, `if`, `for`, `while`, or `return`, + which doesn't start a new level of indentation. This makes the logic in + your code easier to follow. +* End every file with a trailing newline character, but not with extra blank + lines. Remove trailing whitespace from the ends of lines. +* Write the full names of commands instead of abbreviations. For example, write + `function` instead of `func`, and `endif` instead of `end`. +* Write functions with `!`, so files can be reloaded. Use the |abort| keyword + for all functions, so functions exit on the first error. +* Make sure to credit yourself in files you have authored with `Author:` + and `Description:` comments. + +In addition to the above general guidelines for the style of your code, you +should also follow some additional rules designed to prevent mistakes. Some of +these are reported with ALE's `custom-linting-rules` script. See +|ale-development-tests|. + +* Don't leave stray `:echo` lines in code. Write `" no-custom-checks` above + the line if you must echo something. +* For strings use |is#| instead of |==#|, `is?` instead of `==?`, `isnot#` + instead of `!=#`, and `isnot?` instead of `!=?`. This is because `'x' ==# 0` + returns 1, while `'x' is# 0` returns 0, so you will experience fewer issues + when numbers are compared with strings. `is` and `isnot` also do not throw + errors when other objects like List or Dictionaries are compared with + strings. +* Don't use the `getcwd()` function in the ALE codebase. Most of ALE's code + runs from asynchronous callback functions, and these functions can execute + from essentially random buffers. Therefore, the `getcwd()` output is + useless. Use `expand('#' . a:buffer . ':p:h')` instead. Don't use + `expand('%...')` for the same reason. +* Don't use the `simplify()` function. It doesn't simplify paths enough. Use + `ale#path#Simplify()` instead. +* Don't use the `shellescape()` function. It doesn't escape arguments properly + on Windows. Use `ale#Escape()` instead, which will avoid escaping where it + isn't needed, and generally escape arguments better on Windows. +* Don't use the `tempname()` function. It doesn't work when `$TMPDIR` isn't + set. Use `ale#util#Tempname()` instead, which temporarily sets `$TMPDIR` + appropriately where needed. +* Use `snake_case` names for linter names, so they can be used as part of + variable names. You can define `aliases` for linters, for other names people + might try to configure linters with. +* Use |v:t_TYPE| variables instead of `type()`, which are more readable. + +Apply the following guidelines when writing Vader test files. + +* Use 2 spaces for Vader test files, instead of the 4 spaces for Vim files. +* If you write `Before` and `After` blocks, you should typically write them at + the top of the file, so they run for all tests. There may be some tests + where it make sense to modify the `Before` and `After` code part of the way + through the file. +* If you modify any settings or global variables, reset them in `After` + blocks. The Vader `Save` and `Restore` commands can be useful for this + purpose. +* If you load or define linters in tests, write `call ale#linter#Reset()` in + an `After` block. +* Just write `Execute` blocks for Vader tests, and don't bother writing `Then` + blocks. `Then` blocks execute after `After` blocks in older versions, and + that can be confusing. + +Apply the following rules when writing Bash scripts. + +* Run `shellcheck`, and do everything it says. + See: https://github.com/koalaman/shellcheck +* Try to write scripts so they will run on Linux, BSD, or Mac OSX. + +=============================================================================== +4. Testing ALE *ale-development-tests* *ale-dev-tests* *ale-tests* + +ALE is tested with a suite of tests executed via GitHub Actions and AppVeyor. +ALE runs tests with the following versions of Vim in the following +environments. + +1. Vim 8.0.0027 on Linux via GitHub Actions. +2. Vim 8.2.4693 on Linux via GitHub Actions. +3. NeoVim 0.2.0 on Linux via GitHub Actions. +4. NeoVim 0.7.0 on Linux via GitHub Actions. +6. Vim 8 (stable builds) on Windows via AppVeyor. + +If you are developing ALE code on Linux, Mac OSX, or BSD, you can run ALEs +tests by installing Docker and running the `run-tests` script. Follow the +instructions on the Docker site for installing Docker. +See: https://docs.docker.com/install/ + +NOTE: Don't forget to add your user to the `docker` group on Linux, or Docker +just won't work. See: https://docs.docker.com/install/linux/linux-postinstall/ + +If you run simply `./run-tests` from the ALE repository root directory, the +latest Docker image for tests will be downloaded if needed, and the script +will run all of the tests in Vader, Vint checks, and several Bash scripts for +finding extra issues. Run `./run-tests --help` to see all of the options the +script supports. Note that the script supports selecting particular test files. + +Once you get used to dealing with Vim and NeoVim compatibility issues, you +probably want to use `./run-tests --fast -q` for running tests with only the +fastest available Vim version, and with success messages from tests +suppressed. + +Generally write tests for any changes you make. The following types of tests +are recommended for the following types of code. + +* New/edited error handler callbacks -> Write tests in `test/handler` +* New/edited linter definition -> Write tests in `test/linter` +* New/edited fixer functions -> Write tests in `test/fixers` + +Look at existing tests in the codebase for examples of how to write tests. +Refer to the Vader documentation for general information on how to write Vader +tests: https://github.com/junegunn/vader.vim + +If you need to add any supporting files for tests, such as empty files present +to test searching upwards through paths for configuration files, they can be +added to the `test/test-files` directory. + +See |ale-development-linter-tests| for more information on how to write linter +tests. + +When you add new linters or fixers, make sure to add them into the tables in +supported-tools.md and |ale-supported-languages-and-tools.txt|. If you forget to +keep them both in sync, you should see an error like the following in the +builds run for GitHub Actions. +> + ======================================== + diff supported-tools.md and doc/ale-supported-languages-and-tools.txt tables + ======================================== + Differences follow: + + --- /tmp/readme.qLjNhJdB 2018-07-01 16:29:55.590331972 +0100 + +++ /tmp/doc.dAi8zfVE 2018-07-01 16:29:55.582331877 +0100 + @@ -1 +1 @@ + - ASM: gcc, foobar + + ASM: gcc +< +Make sure to list documentation entries for linters and fixers in individual +help files in the table of contents, and to align help tags to the right +margin. For example, if you add a heading for an `aardvark` tool to +`ale-python.txt` with a badly aligned doc tag, you will see errors like so. > + + ======================================== + Look for badly aligned doc tags + ======================================== + Badly aligned tags follow: + + doc/ale-python.txt:aardvark ... + ======================================== + Look for table of contents issues + ======================================== + + Check for bad ToC sorting: + + Check for mismatched ToC and headings: + + --- /tmp/table-of-contents.mwCFOgSI 2018-07-01 16:33:25.068811878 +0100 + +++ /tmp/headings.L4WU0hsO 2018-07-01 16:33:25.076811973 +0100 + @@ -168,6 +168,7 @@ + pyrex (cython), ale-pyrex-options + cython, ale-pyrex-cython + python, ale-python-options + + aardvark, ale-python-aardvark + autopep8, ale-python-autopep8 + black, ale-python-black + flake8, ale-python-flake8 +< +Make sure to make the table of contents match the headings, and to keep the +doc tags on the right margin. + +=============================================================================== +4.1 Writing Linter Tests *ale-development-linter-tests* + +Tests for ALE linters take two forms. + +1. Tests for handling the output of commands. +2. Tests for checking which commands are run, or connections are made. + +Tests of the first form should go in the `test/handler` directory, and should +be written like so. > + + Before: + " Load the file which defines the linter. + runtime ale_linters/filetype/linter_name_here.vim + + After: + " Unload all linters again. + call ale#linter#Reset() + + Execute(The output should be correct): + + " Test that the right loclist items are parsed from the handler. + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': 'Something went wrong', + \ }, + \ ], + \ ale_linters#filetype#linter_name#Handle(bufnr(''), [ + \ '1:Something went wrong', + \ ] +< +Tests for what ALE runs should go in the `test/linter` directory, and should +be written like so. > + + Before: + " Load the linter and set up a series of commands, reset linter variables, + " clear caches, etc. + " + " Vader's 'Save' command will be called here for linter variables. + call ale#assert#SetUpLinterTest('filetype', 'linter_name') + + After: + " Reset linters, variables, etc. + " + " Vader's 'Restore' command will be called here. + call ale#assert#TearDownLinterTest() + + Execute(The default command should be correct): + " AssertLinter checks the executable and command. + " Pass expected_executable, expected_command + AssertLinter 'some-command', ale#Escape('some-command') . ' --foo' + + Execute(Check chained commands): + " GivenCommandOutput can be called with 1 or more list for passing output + " to chained commands. The output for each callback defaults to an empty + " list. + GivenCommandOutput ['v2.1.2'] + " Given a List of commands, check all of them. + " Given a String, only the last command in the chain will be checked. + AssertLinter 'some-command', [ + \ ale#Escape('some-command') . ' --version', + \ ale#Escape('some-command') . ' --foo', + \] +< +The full list of commands that will be temporarily defined for linter tests +given the above setup are as follows. + +`GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertLinterCwd cwd` - Check the `cwd` for the linter. +`AssertLinter executable, command` - Check the executable and command. +`AssertLinterNotExecuted` - Check that linters will not be executed. +`AssertLSPLanguage language` - Check the language given to an LSP server. +`AssertLSPOptions options_dict` - Check the options given to an LSP server. +`AssertLSPConfig config_dict` - Check the config given to an LSP server. +`AssertLSPProject project_root` - Check the root given to an LSP server. +`AssertLSPAddress address` - Check the address to an LSP server. + + +=============================================================================== +4.2 Writing Fixer Tests *ale-development-fixer-tests* + +Tests for ALE fixers should go in the `test/fixers` directory, and should +be written like so. > + + Before: + " Load the fixer and set up a series of commands, reset fixer variables, + " clear caches, etc. + " + " Vader's 'Save' command will be called here for fixer variables. + call ale#assert#SetUpFixerTest('filetype', 'fixer_name') + + After: + " Reset fixers, variables, etc. + " + " Vader's 'Restore' command will be called here. + call ale#assert#TearDownFixerTest() + + Execute(The default command should be correct): + " AssertFixer checks the result of the loaded fixer function. + AssertFixer {'command': ale#Escape('some-command') . ' --foo'} + + Execute(Check chained commands): + " Same as above for linter tests. + GivenCommandOutput ['v2.1.2'] + " Given a List of commands, check all of them. + " Given anything else, only the last result will be checked. + AssertFixer [ + \ ale#Escape('some-command') . ' --version', + \ {'command': ale#Escape('some-command') . ' --foo'} + \] +< +The full list of commands that will be temporarily defined for fixer tests +given the above setup are as follows. + +`GivenCommandOutput [...]` - Define output for ale#command#Run. +`AssertFixerCwd cwd` - Check the `cwd` for the fixer. +`AssertFixer results` - Check the fixer results +`AssertFixerNotExecuted` - Check that fixers will not be executed. + + +=============================================================================== +4.3 Running Tests in a Windows VM *ale-development-windows-tests* + +Tests are run for ALE in a build of Vim 8 for Windows via AppVeyor. These +tests can frequently break due to minor differences in paths and how escaping +is done for commands on Windows. If you are a Linux or Mac user, running these +tests locally can be difficult. Here is a process that will make that easier. + +First, you want to install a Windows image with VirtualBox. Install VirtualBox +and grab a VirtualBox image for Windows such as from here: +https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ + +NOTE: If you need to enter a password for the virtual machine at any point, +the password is "Passw0rd!" without the double quotes. + +NOTE: If your trial period for Windows runs out, run the commands like the +wallpaper tells you to. + +Your virtual machine will need to have PowerShell installed. Before you go any +further, confirm that PowerShell is installed in your Windows virtual machine. + +Consult the VirtualBox documentation on how to install "Guest Additions." +You probably want to install "Guest Additions" for most things to work +properly. + +After you've loaded your virtual machine image, go into "Settings" for your +virtual machine, and "Shared Folders." Add a shared folder with the name +"ale", and set the "Folder Path" to the path to your ALE repository, for +example: "/home/w0rp/ale" + +Find out which drive letter "ale" has been mounted as in Windows. We'll use +"E:" as the drive letter, for example. Open the command prompt as an +administrator by typing in `cmd` in the start menu, right clicking on the +command prompt application, and clicking "Run as administrator." Click "Yes" +when prompted to ask if you're sure you want to run the command prompt. You +should type in the following command to mount the "ale" directory for testing, +where "E:" is replaced with your drive letter. > + + mklink /D C:\testplugin E: +< +Close the administrator Command Prompt, and try running the command +`type C:\testplugin\LICENSE` in a new Command Prompt which you are NOT running +as administrator. You should see the license for ALE in your terminal. After +you have confirmed that you have mounted ALE on your machine, search in the +Start Menu for "power shell," run PowerShell as an administrator, and issue +the following commands to install the correct Vim and Vader versions for +running tests. > + + Add-Type -A System.IO.Compression.FileSystem + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586w32.zip -OutFile C:\vim.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vim.zip', 'C:\vim') + rm C:\vim.zip + + Invoke-WebRequest ftp://ftp.vim.org/pub/vim/pc/vim80-586rt.zip -OutFile C:\rt.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\rt.zip', 'C:\vim') + rm C:\rt.zip + + Invoke-WebRequest https://github.com/junegunn/vader.vim/archive/c6243dd81c98350df4dec608fa972df98fa2a3af.zip -OutFile C:\vader.zip + [IO.Compression.ZipFile]::ExtractToDirectory('C:\vader.zip', 'C:\') + mv C:\vader.vim-c6243dd81c98350df4dec608fa972df98fa2a3af C:\vader + rm C:\vader.zip +< +After you have finished installing everything, you can run all of the tests +in Windows by opening a Command Prompt NOT as an administrator by navigating +to the directory where you've mounted the ALE code, which must be named +`C:\testplugin`, and by running the `run-tests.bat` batch file. > + + cd C:\testplugin + run-tests +< +It will probably take several minutes for all of the tests to run. Be patient. +You can run a specific test by passing the filename as an argument to the +batch file, for example: `run-tests test/test_c_flag_parsing.vader` . This will +give you results much more quickly. + +=============================================================================== +5. Contributing *ale-development-contributing* + +All integration of new code into ALE is done through GitHub pull requests. +Using that tool streamlines the process and minimizes the time and effort +required to e.g. ensure test suites are run for every change. + +As for any project hosted by GitHub, the choice of platform demands every +contributor to take care to setup an account and configure it accordingly. + +Due to details of our process, a difference to many other GitHub hosted +projects is that contributors who wish to keep the author fields for their +commits unaltered need to configure a public email address in their account +and profile settings. See: https://docs.github.com/en/account-and-profile/ + +Unless configuring GitHub to expose contact details, commits will be rewritten +to appear by `USERNAME ` . + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dhall.txt b/sources_non_forked/ale/doc/ale-dhall.txt new file mode 100644 index 00000000..9b997b9e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dhall.txt @@ -0,0 +1,52 @@ +=============================================================================== +ALE Dhall Integration *ale-dhall-options* + +g:ale_dhall_executable *g:ale_dhall_executable* + *b:ale_dhall_executable* + Type: |String| + Default: `'dhall'` + +g:ale_dhall_options *g:ale_dhall_options* + *b:ale_dhall_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall` executable. + This is shared with `dhall-freeze` and `dhall-lint`. +> + let g:ale_dhall_options = '--ascii' +< + +=============================================================================== +dhall-format *ale-dhall-format* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== +dhall-freeze *ale-dhall-freeze* + +Dhall + (https://dhall-lang.org/) + +g:ale_dhall_freeze_options *g:ale_dhall_freeze_options* + *b:ale_dhall_freeze_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the 'dhall freeze` + executable. +> + let g:ale_dhall_freeze_options = '--all' +< + +=============================================================================== +dhall-lint *ale-dhall-lint* + +Dhall + (https://dhall-lang.org/) + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-dockerfile.txt b/sources_non_forked/ale/doc/ale-dockerfile.txt new file mode 100644 index 00000000..51b9acc1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-dockerfile.txt @@ -0,0 +1,76 @@ +=============================================================================== +ALE Dockerfile Integration *ale-dockerfile-options* + + +=============================================================================== +dockerfile_lint *ale-dockerfile-dockerfile_lint* + +g:ale_dockerfile_dockerfile_lint_executable + *g:ale_dockerfile_dockerfile_lint_executable* + *b:ale_dockerfile_dockerfile_lint_executable* + Type: |String| + Default: `'dockerfile_lint'` + + This variable can be changed to specify the executable used to run + dockerfile_lint. + + +g:ale_dockerfile_dockerfile_lint_options + *g:ale_dockerfile_dockerfile_lint_options* + *b:ale_dockerfile_dockerfile_lint_options* + Type: |String| + Default: `''` + + This variable can be changed to add additional command-line arguments to + the dockerfile lint invocation - like custom rule file definitions. + + +=============================================================================== +dprint *ale-dockerfile-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/dockerfile + + +=============================================================================== +hadolint *ale-dockerfile-hadolint* + + hadolint can be found at: https://github.com/hadolint/hadolint + + +g:ale_dockerfile_hadolint_options *g:ale_dockerfile_hadolint_options* + *b:ale_dockerfile_hadolint_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the hadolint + invocation. These arguments will be used whether docker is being used or not + (see below). + + +g:ale_dockerfile_hadolint_use_docker *g:ale_dockerfile_hadolint_use_docker* + *b:ale_dockerfile_hadolint_use_docker* + Type: |String| + Default: `'never'` + + This variable controls if docker and the hadolint image are used to run this + linter: if 'never', docker will never be used; 'always' means docker will + always be used; 'yes' and docker will be used if the hadolint executable + cannot be found. + + For now, the default is 'never'. This may change as ale's support for using + docker to lint evolves. + + +g:ale_dockerfile_hadolint_image *g:ale_dockerfile_hadolint_image* + *b:ale_dockerfile_hadolint_image* + Type: |String| + Default: `'hadolint/hadolint'` + + This variable controls the docker image used to run hadolint. The default + is hadolint's author's build, and can be found at: + + https://hub.docker.com/r/hadolint/hadolint/ + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-elixir.txt b/sources_non_forked/ale/doc/ale-elixir.txt new file mode 100644 index 00000000..693db5aa --- /dev/null +++ b/sources_non_forked/ale/doc/ale-elixir.txt @@ -0,0 +1,108 @@ +=============================================================================== +ALE Elixir Integration *ale-elixir-options* + + +=============================================================================== +mix *ale-elixir-mix* + +The `mix` linter is disabled by default, as it can be too expensive to run. +See `:help g:ale_linters` + + +g:ale_elixir_mix_options *g:ale_elixir_mix_options* + *b:ale_elixir_mix_options* + Type: |String| + Default: `'mix'` + + + This variable can be changed to specify the mix executable. + + +=============================================================================== +mix_format *ale-elixir-mix-format* + +g:ale_elixir_mix_format_options *g:ale_elixir_mix_format_options* + *b:ale_elixir_mix_format_options* + Type: |String| + Default: `''` + + + This variable can be changed to specify the mix options passed to the + mix_format fixer + + +=============================================================================== +dialyxir *ale-elixir-dialyxir* + +Dialyzer, a DIscrepancy AnaLYZer for ERlang programs. +http://erlang.org/doc/man/dialyzer.html + +It can be used with elixir through dialyxir +https://github.com/jeremyjh/dialyxir + +Options for dialyzer are not configurable by ale, but they are instead +configured on your project's `mix.exs`. + +See https://github.com/jeremyjh/dialyxir#with-explaining-stuff for more +information. + + +=============================================================================== +elixir-ls *ale-elixir-elixir-ls* + +Elixir Language Server (https://github.com/JakeBecker/elixir-ls) + +g:ale_elixir_elixir_ls_release *g:ale_elixir_elixir_ls_release* + *b:ale_elixir_elixir_ls_release* + Type: |String| + Default: `'elixir-ls'` + + Location of the elixir-ls release directory. This directory must contain + the language server scripts (language_server.sh and language_server.bat). + +g:ale_elixir_elixir_ls_config *g:ale_elixir_elixir_ls_config* + *b:ale_elixir_elixir_ls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example, to disable Dialyzer: > + { + \ 'elixirLS': { + \ 'dialyzerEnabled': v:false, + \ }, + \ } +< + Consult the ElixirLS documentation for more information about settings. + + +=============================================================================== +credo *ale-elixir-credo* + +Credo (https://github.com/rrrene/credo) + +g:ale_elixir_credo_strict *g:ale_elixir_credo_strict* + + Type: |Integer| + Default: `0` + + Tells credo to run in strict mode or suggest mode. Set variable to 1 to + enable --strict mode. + + +g:ale_elixir_credo_config_file *g:ale_elixir_credo_config_file* + + Type: |String| + Default: `''` + + Tells credo to use a custom configuration file. + + +=============================================================================== +cspell *ale-elixir-cspell* + +See |ale-cspell-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-elm.txt b/sources_non_forked/ale/doc/ale-elm.txt new file mode 100644 index 00000000..b1510241 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-elm.txt @@ -0,0 +1,100 @@ +=============================================================================== +ALE Elm Integration *ale-elm-options* + + +=============================================================================== +elm-format *ale-elm-elm-format* + +g:ale_elm_format_executable *g:ale_elm_format_executable* + *b:ale_elm_format_executable* + Type: |String| + Default: `'elm-format'` + + See |ale-integrations-local-executables| + + +g:ale_elm_format_use_global *g:ale_elm_format_use_global* + *b:ale_elm_format_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_elm_format_options *g:ale_elm_format_options* + *b:ale_elm_format_options* + Type: |String| + Default: `'--yes'` + + This variable can be set to pass additional options to elm-format. + +=============================================================================== +elm-ls *ale-elm-elm-ls* + +g:ale_elm_ls_executable *g:ale_elm_ls_executable* + *b:ale_elm_ls_executable* + Type: |String| + Default: `'elm-language-server'` + + See |ale-integrations-local-executables| + + +g:ale_elm_ls_use_global *g:ale_elm_ls_use_global* + *b:ale_elm_ls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 1)` + + See |ale-integrations-local-executables| + + +g:ale_elm_ls_elm_path *g:ale_elm_ls_elm_path* + *b:ale_elm_ls_elm_path* + Type: |String| + Default: `''` + + See |ale-integrations-local-executables| + + +g:ale_elm_ls_elm_format_path *g:ale_elm_ls_elm_format_path* + *b:ale_elm_ls_elm_format_path* + Type: |String| + Default: `''` + + See |ale-integrations-local-executables| + + +g:ale_elm_ls_elm_test_path *g:ale_elm_ls_elm_test_path* + *b:ale_elm_ls_elm_test_path* + Type: |String| + Default: `''` + + See |ale-integrations-local-executables| + + +g:ale_elm_ls_elm_analyse_trigger *g:ale_elm_ls_elm_analyse_trigger* + *b:ale_elm_ls_elm_analyse_trigger* + Type: |String| + Default: `'change'` + + One of 'change', 'save' or 'never' + +=============================================================================== +elm-make *ale-elm-elm-make* + +g:ale_elm_make_executable *g:ale_elm_make_executable* + *b:ale_elm_make_executable* + Type: |String| + Default: `'elm'` + + See |ale-integrations-local-executables| + + +g:ale_elm_make_use_global *g:ale_elm_make_use_global* + *b:ale_elm_make_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-erlang.txt b/sources_non_forked/ale/doc/ale-erlang.txt new file mode 100644 index 00000000..2c6ff22a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-erlang.txt @@ -0,0 +1,131 @@ +=============================================================================== +ALE Erlang Integration *ale-erlang-options* + + +=============================================================================== +dialyzer *ale-erlang-dialyzer* + +g:ale_erlang_dialyzer_executable *g:ale_erlang_dialyzer_executable* + *b:ale_erlang_dialyzer_executable* + Type: |String| + Default: `'dialyzer'` + + This variable can be changed to specify the dialyzer executable. + + +g:ale_erlang_dialyzer_options *g:ale_erlang_dialyzer_options* + *b:ale_erlang_dialyzer_options* + Type: |String| + Default: `'-Wunmatched_returns -Werror_handling -Wrace_conditions -Wunderspec'` + + This variable can be changed to specify the options to pass to the dialyzer + executable. + +g:ale_erlang_dialyzer_plt_file *g:ale_erlang_dialyzer_plt_file* + *b:ale_erlang_dialyzer_plt_file* + Type: |String| + + This variable can be changed to specify the path to the PLT file. By + default, it will search for the PLT file inside the `_build` directory. If + there isn't one, it will fallback to the path `$REBAR_PLT_DIR/dialyzer/plt`. + Otherwise, it will default to `$HOME/.dialyzer_plt`. + + +g:ale_erlang_dialyzer_rebar3_profile *g:ale_erlang_dialyzer_rebar3_profile* + *b:ale_erlang_dialyzer_rebar3_profile* + Type: |String| + Default: `'default'` + + This variable can be changed to specify the profile that is used to + run dialyzer with rebar3. + + +------------------------------------------------------------------------------- +elvis *ale-erlang-elvis* + +g:ale_erlang_elvis_executable *g:ale_erlang_elvis_executable* + *b:ale_erlang_elvis_executable* + Type: |String| + Default: `'elvis'` + + This variable can be changed to specify the elvis executable. + + +------------------------------------------------------------------------------- +erlang_ls *ale-erlang-erlang_ls* + +g:ale_erlang_erlang_ls_executable *g:ale_erlang_erlang_ls_executable* + *b:ale_erlang_erlang_ls_executable* + Type: |String| + Default: `'erlang_ls'` + + This variable can be changed to specify the erlang_ls executable. + +g:ale_erlang_erlang_ls_log_dir *g:ale_erlang_erlang_ls_log_dir* + *b:ale_erlang_erlang_ls_log_dir* + Type: |String| + Default: `''` + + If set this variable overrides default directory where logs will be written. + +g:ale_erlang_erlang_ls_log_level *g:ale_erlang_erlang_ls_log_level* + *b:ale_erlang_erlang_ls_log_level* + Type: |String| + Default: `'info'` + + This variable can be changed to specify log level. + + +------------------------------------------------------------------------------- +erlc *ale-erlang-erlc* + +g:ale_erlang_erlc_executable *g:ale_erlang_erlc_executable* + *b:ale_erlang_erlc_executable* + Type: |String| + Default: `'erlc'` + + This variable can be changed to specify the erlc executable. + + +g:ale_erlang_erlc_options *g:ale_erlang_erlc_options* + *b:ale_erlang_erlc_options* + Type: |String| + Default: `''` + + This variable controls additional parameters passed to `erlc`, such as `-I` + or `-pa`. + + +------------------------------------------------------------------------------- +erlfmt *ale-erlang-erlfmt* + +g:ale_erlang_erlfmt_executable *g:ale_erlang_erlfmt_executable* + *b:ale_erlang_erlfmt_executable* + Type: |String| + Default: `'erlfmt'` + + This variable can be changed to specify the erlfmt executable. + + +g:ale_erlang_erlfmt_options *g:ale_erlang_erlfmt_options* + *b:ale_erlang_erlfmt_options* + Type: |String| + Default: `''` + + This variable controls additional parameters passed to `erlfmt`, such as + `--insert-pragma` or `--print-width`. + + +------------------------------------------------------------------------------- +syntaxerl *ale-erlang-syntaxerl* + +g:ale_erlang_syntaxerl_executable *g:ale_erlang_syntaxerl_executable* + *b:ale_erlang_syntaxerl_executable* + Type: |String| + Default: `'syntaxerl'` + + This variable can be changed to specify the syntaxerl executable. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-eruby.txt b/sources_non_forked/ale/doc/ale-eruby.txt new file mode 100644 index 00000000..4cf08d07 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-eruby.txt @@ -0,0 +1,58 @@ +=============================================================================== +ALE Eruby Integration *ale-eruby-options* + +There are four linters for `eruby` files: + +- `erb` +- `erblint` +- `erubis` +- `erubi` +- `ruumba` + +`erb` is in the Ruby standard library and is mostly universal. `erubis` is the +default parser in Rails between 3.0 and 5.1. `erubi` is the default in Rails +5.1 and later. `ruumba` can extract Ruby from eruby files and run rubocop on +the result. To selectively enable a subset, see |g:ale_linters|. + +=============================================================================== +erblint *ale-eruby-erblint* + +g:ale_eruby_erblint_executable *g:ale_eruby_erblint_executable* + *b:ale_eruby_erblint_executable* + Type: |String| + Default: `'erblint'` + + Override the invoked erblint binary. This is useful for running erblint + from binstubs or a bundle. + + +g:ale_eruby_erblint_options *g:ale_ruby_erblint_options* + *b:ale_ruby_erblint_options* + Type: |String| + Default: `''` + + This variable can be change to modify flags given to erblint. + + +=============================================================================== +ruumba *ale-eruby-ruumba* + +g:ale_eruby_ruumba_executable *g:ale_eruby_ruumba_executable* + *b:ale_eruby_ruumba_executable* + Type: |String| + Default: `'ruumba` + + Override the invoked ruumba binary. This is useful for running ruumba + from binstubs or a bundle. + + +g:ale_eruby_ruumba_options *g:ale_ruby_ruumba_options* + *b:ale_ruby_ruumba_options* + Type: |String| + Default: `''` + + This variable can be change to modify flags given to ruumba. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-fish.txt b/sources_non_forked/ale/doc/ale-fish.txt new file mode 100644 index 00000000..7dbbc10c --- /dev/null +++ b/sources_non_forked/ale/doc/ale-fish.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE Fish Integration *ale-fish-options* + +Lints fish files using `fish -n`. + +Note that `fish -n` is not foolproof: it sometimes gives false positives or +errors that are difficult to parse without more context. This integration skips +displaying errors if an error message is not found. + +If ALE is not showing any errors but your file does not run as expected, run +`fish -n ` from the command line. + +=============================================================================== +fish_indent *ale-fish-fish_indent* + +g:ale_fish_fish_indent_executable *g:ale_fish_fish_indent_executable* + *b:ale_fish_fish_indent_executable* + Type: |String| + Default: `'fish_indent'` + + This variable can be changed to use a different executable for fish_indent. + +g:ale_fish_fish_indent_options *g:ale_fish_fish_indent_options* + *b:ale_fish_fish_indent_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to fish_indent. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-fortran.txt b/sources_non_forked/ale/doc/ale-fortran.txt new file mode 100644 index 00000000..c9b7e8e2 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-fortran.txt @@ -0,0 +1,55 @@ +=============================================================================== +ALE Fortran Integration *ale-fortran-options* + + +=============================================================================== +gcc *ale-fortran-gcc* + +g:ale_fortran_gcc_executable *g:ale_fortran_gcc_executable* + *b:ale_fortran_gcc_executable* + Type: |String| + Default: `'gcc'` + + This variable can be changed to modify the executable used for checking + Fortran code with GCC. + + +g:ale_fortran_gcc_options *g:ale_fortran_gcc_options* + *b:ale_fortran_gcc_options* + Type: |String| + Default: `'-Wall'` + + This variable can be changed to modify flags given to gcc. + + +g:ale_fortran_gcc_use_free_form *g:ale_fortran_gcc_use_free_form* + *b:ale_fortran_gcc_use_free_form* + Type: |Number| + Default: `1` + + When set to `1`, the `-ffree-form` flag will be used for GCC, to check files + with the free form layout. When set to `0`, `-ffixed-form` will be used + instead, for checking files with fixed form layouts. + + +=============================================================================== +language_server *ale-fortran-language-server* + +g:ale_fortran_language_server_executable *g:ale_fortran_language_server_executable* + *b:ale_fortran_language_server_executable* + Type: |String| + Default: `'fortls'` + + This variable can be changed to modify the executable used for the Fortran + Language Server. + +g:ale_fortran_language_server_use_global *g:ale_fortran_language_server_use_global* + *b:ale_fortran_language_server_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-fountain.txt b/sources_non_forked/ale/doc/ale-fountain.txt new file mode 100644 index 00000000..ac0870cf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-fountain.txt @@ -0,0 +1,6 @@ +=============================================================================== +ALE Fountain Integration *ale-fountain-options* + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-fuse.txt b/sources_non_forked/ale/doc/ale-fuse.txt new file mode 100644 index 00000000..0849c371 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-fuse.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE FusionScript Integration *ale-fuse-options* + + +=============================================================================== +fusion-lint *ale-fuse-fusionlint* + +g:ale_fusion_fusionlint_executable *g:ale_fuse_fusionlint_executable* + *b:ale_fuse_fusionlint_executable* + Type: |String| + Default: `'fusion-lint'` + + This variable can be changed to change the path to fusion-lint. + + +g:ale_fuse_fusionlint_options *g:ale_fuse_fusionlint_options* + *b:ale_fuse_fusionlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to fusion-lint. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-gitcommit.txt b/sources_non_forked/ale/doc/ale-gitcommit.txt new file mode 100644 index 00000000..38f3fd90 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-gitcommit.txt @@ -0,0 +1,44 @@ +=============================================================================== +ALE Git Commit Integration *ale-gitcommit-options* + + +=============================================================================== +gitlint *ale-gitcommit-gitlint* + +g:ale_gitcommit_gitlint_executable *g:ale_gitcommit_gitlint_executable* + *b:ale_gitcommit_gitlint_executable* + Type: |String| + Default: `'gitlint'` + + This variable can be changed to modify the executable used for gitlint. + + +g:ale_gitcommit_gitlint_options *g:ale_gitcommit_gitlint_options* + *b:ale_gitcommit_gitlint_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the gitlint + invocation. For example, you can specify the path to a configuration file. > + + let g:ale_gitcommit_gitlint_options = '-C /home/user/.config/gitlint.ini' +< + You can also disable particular error codes using this option. For example, + you can ignore errors for git commits with a missing body. > + + let g:ale_gitcommit_gitlint_options = '--ignore B6' +< + +g:ale_gitcommit_gitlint_use_global *g:ale_gitcommit_gitlint_use_global* + *b:ale_gitcommit_gitlint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for gitlint in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_gitcommit_gitlint_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-glsl.txt b/sources_non_forked/ale/doc/ale-glsl.txt new file mode 100644 index 00000000..257de751 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-glsl.txt @@ -0,0 +1,56 @@ +=============================================================================== +ALE GLSL Integration *ale-glsl-options* + *ale-integration-glsl* + +=============================================================================== +Integration Information + + Since Vim does not detect the glsl file types out-of-the-box, you need the + runtime files for glsl from here: https://github.com/tikhomirov/vim-glsl + + Note that the current glslang-based linter expects glslangValidator in + standard paths. If it's not installed system-wide you can set + |g:ale_glsl_glslang_executable| to a specific path. + + +=============================================================================== +glslang *ale-glsl-glslang* + +g:ale_glsl_glslang_executable *g:ale_glsl_glslang_executable* + *b:ale_glsl_glslang_executable* + Type: |String| + Default: `'glslangValidator'` + + This variable can be changed to change the path to glslangValidator. + + +g:ale_glsl_glslang_options *g:ale_glsl_glslang_options* + *b:ale_glsl_glslang_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to glslangValidator. + + +=============================================================================== +glslls *ale-glsl-glslls* + +g:ale_glsl_glslls_executable *g:ale_glsl_glslls_executable* + *b:ale_glsl_glslls_executable* + Type: |String| + Default: `'glslls'` + + This variable can be changed to change the path to glslls. + See |ale-integrations-local-executables| + +g:ale_glsl_glslls_logfile *g:ale_glsl_glslls_logfile* + *b:ale_glsl_glslls_logfile* + Type: |String| + Default: `''` + + Setting this variable to a writeable file path will enable logging to that + file. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-go.txt b/sources_non_forked/ale/doc/ale-go.txt new file mode 100644 index 00000000..367618ea --- /dev/null +++ b/sources_non_forked/ale/doc/ale-go.txt @@ -0,0 +1,372 @@ +=============================================================================== +ALE Go Integration *ale-go-options* + + +=============================================================================== +Integration Information + +The `gometalinter` linter is disabled by default. ALE enables `gofmt`, +`golint` and `go vet` by default. It also supports `staticcheck`, `go +build`, `gosimple`, `golangserver`. + +To enable `gometalinter`, update |g:ale_linters| as appropriate: +> + " Enable all of the linters you want for Go. + let g:ale_linters = {'go': ['gometalinter', 'gofmt']} +< +A possible configuration is to enable `gometalinter` and `gofmt` but paired +with the `--fast` option, set by |g:ale_go_gometalinter_options|. This gets you +the benefit of running a number of linters, more than ALE would by default, +while ensuring it doesn't run any linters known to be slow or resource +intensive. + +g:ale_go_go_executable *g:ale_go_go_executable* + *b:ale_go_go_executable* + + Type: |String| + Default: `'go'` + + The executable that will be run for the `gobuild` and `govet` linters, and + the `gomod` fixer. + + +g:ale_go_go111module *g:ale_go_go111module* + *b:ale_go_go111module* + Type: |String| + Default: `''` + + Override the value of the `$GO111MODULE` environment variable for + golang tools. + + +=============================================================================== +bingo *ale-go-bingo* + +g:ale_go_bingo_executable *g:ale_go_bingo_executable* + *b:ale_go_bingo_executable* + Type: |String| + Default: `'bingo'` + + Location of the bingo binary file. + + +g:ale_go_bingo_options *g:ale_go_bingo_options* + *b:ale_go_bingo_options* + Type: |String| + Default: `''` + + +=============================================================================== +cspell *ale-go-cspell* + +See |ale-cspell-options| + +=============================================================================== +gobuild *ale-go-gobuild* + +g:ale_go_gobuild_options *g:ale_go_gobuild_options* + *b:ale_go_gobuild_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the gobuild linter. + They are injected directly after "go test". + + +=============================================================================== +gofmt *ale-go-gofmt* + +g:ale_go_gofmt_options *g:ale_go_gofmt_options* + *b:ale_go_gofmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the gofmt fixer. + + +=============================================================================== +gofumpt *ale-go-gofumpt* + +g:ale_go_gofumpt_executable *g:ale_go_gofumpt_executable* + *b:ale_go_gofumpt_executable* + Type: |String| + Default: `'gofumpt'` + + Executable to run to use as the gofumpt fixer. + +g:ale_go_gofumpt_options *g:ale_go_gofumpt_options* + *b:ale_go_gofumpt_options* + Type: |String| + Default: `''` + + Options to pass to the gofumpt fixer. + + +=============================================================================== +golangci-lint *ale-go-golangci-lint* + +`golangci-lint` is a `lint_file` linter, which only lints files that are +written to disk. This differs from the default behavior of linting the buffer. +See: |ale-lint-file| + +g:ale_go_golangci_lint_executable *g:ale_go_golangci_lint_executable* + *b:ale_go_golangci_lint_executable* + Type: |String| + Default: `'golangci-lint'` + + The executable that will be run for golangci-lint. + + +g:ale_go_golangci_lint_options *g:ale_go_golangci_lint_options* + *b:ale_go_golangci_lint_options* + Type: |String| + Default: `'--enable-all'` + + This variable can be changed to alter the command-line arguments to the + golangci-lint invocation. + + +g:ale_go_golangci_lint_package *g:ale_go_golangci_lint_package* + *b:ale_go_golangci_lint_package* + Type: |Number| + Default: `0` + + When set to `1`, the whole Go package will be checked instead of only the + current file. + + +=============================================================================== +golangserver *ale-go-golangserver* + +g:ale_go_langserver_executable *g:ale_go_langserver_executable* + *b:ale_go_langserver_executable* + Type: |String| + Default: `'go-langserver'` + + Location of the go-langserver binary file. + + +g:ale_go_langserver_options *g:ale_go_langserver_options* + *b:ale_go_langserver_options* + Type: |String| + Default: `''` + + Additional options passed to the go-langserver command. Note that the + `-gocodecompletion` option is ignored because it is handled automatically + by the |g:ale_completion_enabled| variable. + + +=============================================================================== +golines *ale-go-golines* + +g:ale_go_golines_executable *g:ale_go_lines_executable* + *b:ale_go_lines_executable* + Type: |String| + Default: `'golines'` + + Location of the golines binary file + +g:ale_go_golines_options *g:ale_go_golines_options* + *b:ale_go_golines_options* + Type: |String| + Default: `''` + + Additional options passed to the golines command. By default golines has + --max-length=100 (lines above 100 characters will be wrapped) + + +=============================================================================== +golint *ale-go-golint* + +g:ale_go_golint_executable *g:ale_go_golint_executable* + *b:ale_go_golint_executable* + Type: |String| + Default: `'golint'` + + This variable can be set to change the golint executable path. + + +g:ale_go_golint_options *g:ale_go_golint_options* + *b:ale_go_golint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the golint linter. + + +=============================================================================== +gometalinter *ale-go-gometalinter* + +`gometalinter` is a `lint_file` linter, which only lints files that are +written to disk. This differs from the default behavior of linting the buffer. +See: |ale-lint-file| + +g:ale_go_gometalinter_executable *g:ale_go_gometalinter_executable* + *b:ale_go_gometalinter_executable* + Type: |String| + Default: `'gometalinter'` + + The executable that will be run for gometalinter. + + +g:ale_go_gometalinter_options *g:ale_go_gometalinter_options* + *b:ale_go_gometalinter_options* + Type: |String| + Default: `''` + + This variable can be changed to alter the command-line arguments to the + gometalinter invocation. + + Since `gometalinter` runs a number of linters that can consume a lot of + resources it's recommended to set this option to a value of `--fast` if you + use `gometalinter` as one of the linters in |g:ale_linters|. This disables a + number of linters known to be slow or consume a lot of resources. + + +g:ale_go_gometalinter_lint_package *g:ale_go_gometalinter_lint_package* + *b:ale_go_gometalinter_lint_package* + Type: |Number| + Default: `0` + + When set to `1`, the whole Go package will be checked instead of only the + current file. + + +=============================================================================== +gopls *ale-go-gopls* + +gopls is the official Go language server, and is enabled for use with ALE by +default. + +To install the latest stable version of `gopls` to your `$GOPATH`, try the +following command: > + + GO111MODULE=on go get golang.org/x/tools/gopls@latest +< +If `$GOPATH` is readable by ALE, it should probably work without you having to +do anything else. See the `gopls` README file for more information: + +https://github.com/golang/tools/blob/master/gopls/README.md + + +g:ale_go_gopls_executable *g:ale_go_gopls_executable* + *b:ale_go_gopls_executable* + Type: |String| + Default: `'gopls'` + + See |ale-integrations-local-executables| + + ALE will search for `gopls` in locally installed directories first by + default, and fall back on a globally installed `gopls` if it can't be found + otherwise. + + +g:ale_go_gopls_options *g:ale_go_gopls_options* + *b:ale_go_gopls_options* + Type: |String| + Default: `''` + + Command-line options passed to the gopls executable. See `gopls -h`. + + +g:ale_go_gopls_init_options *g:ale_go_gopls_init_options* + *b:ale_go_gopls_init_options* + Type: |Dictionary| + Default: `{}` + + LSP initialization options passed to gopls. This can be used to configure + the behaviour of gopls. + + Example: > + let g:ale_go_gopls_init_options = {'ui.diagnostic.analyses': { + \ 'composites': v:false, + \ 'unusedparams': v:true, + \ 'unusedresult': v:true, + \ }} +< + + For a full list of supported analyzers, see: + https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md + + +g:ale_go_gopls_use_global *g:ale_go_gopls_use_global* + *b:ale_go_gopls_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +govet *ale-go-govet* + +g:ale_go_govet_options *g:ale_go_govet_options* + *b:ale_go_govet_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the go vet linter. + + +=============================================================================== +revive *ale-go-revive* + +g:ale_go_revive_executable *g:ale_go_revive_executable* + *b:ale_go_revive_executable* + Type: |String| + Default: `'revive'` + + This variable can be set to change the revive executable path. + + +g:ale_go_revive_options *g:ale_go_revive_options* + *b:ale_go_revive_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the revive + + +=============================================================================== +staticcheck *ale-go-staticcheck* + +g:ale_go_staticcheck_executable *g:ale_go_staticcheck_executable* + *b:ale_go_staticcheck_executable* + Type: |String| + Default: `'staticcheck'` + + See |ale-integrations-local-executables| + + ALE will search for `staticcheck` in locally installed directories first by + default, and fall back on a globally installed `staticcheck` if it can't be + found otherwise. + + +g:ale_go_staticcheck_options *g:ale_go_staticcheck_options* + *b:ale_go_staticcheck_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the staticcheck + linter. + + +g:ale_go_staticcheck_lint_package *g:ale_go_staticcheck_lint_package* + *b:ale_go_staticcheck_lint_package* + Type: |Number| + Default: `1` + + When set to `1`, the whole Go package will be checked instead of only the + current file. + + +g:ale_go_staticcheck_use_global *g:ale_go_staticcheck_use_global* + *b:ale_go_staticcheck_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-graphql.txt b/sources_non_forked/ale/doc/ale-graphql.txt new file mode 100644 index 00000000..603694bb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-graphql.txt @@ -0,0 +1,22 @@ +=============================================================================== +ALE GraphQL Integration *ale-graphql-options* + + +=============================================================================== +eslint *ale-graphql-eslint* + +The `eslint` linter for GraphQL uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need the GraphQL ESLint plugin installed for this to work. + +=============================================================================== +gqlint *ale-graphql-gqlint* + +=============================================================================== +prettier *ale-graphql-prettier* + +See |ale-javascript-prettier| for information about the available options. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-hack.txt b/sources_non_forked/ale/doc/ale-hack.txt new file mode 100644 index 00000000..4776b8cf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-hack.txt @@ -0,0 +1,51 @@ +=============================================================================== +ALE Hack Integration *ale-hack-options* + *ale-integration-hack* + + HHAST is disabled by default, as it executes code in the project root. + + Currently linters must be enabled globally. HHAST can be enabled with: + +> + let g:ale_linters = {'hack': ['hack', 'hhast']} +< + +=============================================================================== +hack *ale-hack-hack* + +g:ale_hack_hack_executable *g:ale_hack_hack_executable* + *b:ale_hack_hack_executable* + + Type: |String| + Default: `'hh_client'` + + This variable can be set to use a specific executable to interact with the + Hack typechecker. + + +=============================================================================== +hackfmt *ale-hack-hackfmt* + +g:ale_hack_hackfmt_options *g:ale_hack_hackfmt_options* + *b:ale_hack_hackfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the hackfmt fixer. + + +=============================================================================== +hhast *ale-hack-hhast* + +g:ale_hack_hhast_executable *g:ale_hack_hhast_executable* + *b:ale_hack_hhast_executable* + + Type: |String| + Default: `'vendor/bin/hhast-lint'` + + This variable can be set to use a specific executable to interact with the + Hack typechecker. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-handlebars.txt b/sources_non_forked/ale/doc/ale-handlebars.txt new file mode 100644 index 00000000..4a5a3870 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-handlebars.txt @@ -0,0 +1,34 @@ +=============================================================================== +ALE Handlebars Integration *ale-handlebars-options* + + +=============================================================================== +prettier *ale-handlebars-prettier* + +See |ale-javascript-prettier| for information about the available options. +Uses glimmer parser by default. + + +=============================================================================== +ember-template-lint *ale-handlebars-embertemplatelint* + +g:ale_handlebars_embertemplatelint_executable + *g:ale_handlebars_embertemplatelint_executable* + *b:ale_handlebars_embertemplatelint_executable* + Type: |String| + Default: `'ember-template-lint'` + + See |ale-integrations-local-executables| + + +g:ale_handlebars_embertemplatelint_use_global + *g:ale_handlebars_embertemplatelint_use_global* + *b:ale_handlebars_embertemplatelint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-haskell.txt b/sources_non_forked/ale/doc/ale-haskell.txt new file mode 100644 index 00000000..bd5a5edf --- /dev/null +++ b/sources_non_forked/ale/doc/ale-haskell.txt @@ -0,0 +1,228 @@ +=============================================================================== +ALE Haskell Integration *ale-haskell-options* + + +=============================================================================== +brittany *ale-haskell-brittany* + +g:ale_haskell_brittany_executable *g:ale_haskell_brittany_executable* + *b:ale_haskell_brittany_executable* + Type: |String| + Default: `'brittany'` + + This variable can be changed to use a different executable for brittany. + + +=============================================================================== +cspell *ale-haskell-cspell* + +See |ale-cspell-options| + + +=============================================================================== +floskell *ale-haskell-floskell* + +g:ale_haskell_floskell_executable *g:ale_haskell_floskell_executable* + *b:ale_haskell_floskell_executable* + Type: |String| + Default: `'floskell'` + + This variable can be changed to use a different executable for floskell. + + +=============================================================================== +ghc *ale-haskell-ghc* + +g:ale_haskell_ghc_options *g:ale_haskell_ghc_options* + *b:ale_haskell_ghc_options* + Type: |String| + Default: `'-fno-code -v0'` + + This variable can be changed to modify flags given to ghc. + + +=============================================================================== +ghc-mod *ale-haskell-ghc-mod* + +g:ale_haskell_ghc_mod_executable *g:ale_haskell_ghc_mod_executable* + *b:ale_haskell_ghc_mod_executable* + Type: |String| + Default: `'ghc-mod'` + + This variable can be changed to use a different executable for ghc-mod. + + +=============================================================================== +cabal-ghc *ale-haskell-cabal-ghc* + +g:ale_haskell_cabal_ghc_options *g:ale_haskell_cabal_ghc_options* + *b:ale_haskell_cabal_ghc_options* + Type: |String| + Default: `'-fno-code -v0'` + + This variable can be changed to modify flags given to ghc through cabal + exec. + + +=============================================================================== +hdevtools *ale-haskell-hdevtools* + +g:ale_haskell_hdevtools_executable *g:ale_haskell_hdevtools_executable* + *b:ale_haskell_hdevtools_executable* + Type: |String| + Default: `'hdevtools'` + + This variable can be changed to use a different executable for hdevtools. + + +g:ale_haskell_hdevtools_options *g:ale_haskell_hdevtools_options* + *b:ale_haskell_hdevtools_options* + Type: |String| + Default: `get(g:, 'hdevtools_options', '-g -Wall')` + + This variable can be changed to modify flags given to hdevtools. + + The hdevtools documentation recommends setting GHC options for `hdevtools` + with `g:hdevtools_options`. ALE will use the value of `g:hdevtools_options` + for the value of `g:ale_haskell_hdevtools_options` by default, so this + option can be respected and overridden specifically for ALE. + + +=============================================================================== +hfmt *ale-haskell-hfmt* + +g:ale_haskell_hfmt_executable *g:ale_haskell_hfmt_executable* + *b:ale_haskell_hfmt_executable* + Type: |String| + Default: `'hfmt'` + + This variable can be changed to use a different executable for hfmt. + + +=============================================================================== +hindent *ale-haskell-hindent* + +g:ale_haskell_hindent_executable *g:ale_haskell_hindent_executable* + *b:ale_haskell_hindent_executable* + Type: |String| + Default: `'hindent'` + + This variable can be changed to use a different executable for hindent. + + +=============================================================================== +hlint *ale-haskell-hlint* + +g:ale_haskell_hlint_executable *g:ale_haskell_hlint_executable* + *b:ale_haskell_hlint_executable* + Type: |String| + Default: `'hlint'` + + This variable can be changed to use a different executable for hlint. + + +g:ale_haskell_hlint_options g:ale_haskell_hlint_options + b:ale_haskell_hlint_options + Type: |String| + Default: `''` + + This variable can be used to pass extra options to the underlying hlint + executable. + + +=============================================================================== +hls *ale-haskell-hls* + +g:ale_haskell_hls_executable *g:ale_haskell_hls_executable* + *b:ale_haskell_hls_executable* + Type: |String| + Default: `'haskell-language-server-wrapper'` + + This variable can be changed to use a different executable for the haskell + language server. + + +g:ale_haskell_hls_config *g:ale_haskell_hls_config* + *b:ale_haskell_hls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for HLS. For example, to see more + completions: +> + let g:ale_haskell_hls_config = {'haskell': {'maxCompletions': 250}} +< + Refer to HLS documentation for possible settings: + https://haskell-language-server.readthedocs.io/en/latest/configuration.html#language-specific-server-options + + +=============================================================================== +stack-build *ale-haskell-stack-build* + +g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options* + *b:ale_haskell_stack_build_options* + Type: |String| + Default: `'--fast'` + + We default to using `'--fast'`. Since Stack generates binaries, your + programs will be slower unless you separately rebuild them outside of ALE. + + +=============================================================================== +stack-ghc *ale-haskell-stack-ghc* + +g:ale_haskell_stack_ghc_options *g:ale_haskell_stack_ghc_options* + *b:ale_haskell_stack_ghc_options* + Type: |String| + Default: `'-fno-code -v0'` + + This variable can be changed to modify flags given to ghc through `stack + ghc` + + +=============================================================================== +stylish-haskell *ale-haskell-stylish-haskell* + +g:ale_haskell_stylish_haskell_executable + *g:ale_haskell_stylish_haskell_executable* + *b:ale_haskell_stylish_haskell_executable* + Type: |String| + Default: `'stylish-haskell'` + + This variable can be changed to use a different executable for stylish-haskell. + + +=============================================================================== +hie *ale-haskell-hie* + +g:ale_haskell_hie_executable *g:ale_haskell_hie_executable* + *b:ale_haskell_hie_executable* + Type: |String| + Default: `'hie'` + + This variable can be changed to use a different executable for the haskell + ide engine. i.e. `'hie-wrapper'` + + +=============================================================================== +ormolu *ale-haskell-ormolu* + +g:ale_haskell_ormolu_executable *g:ale_haskell_ormolu_executable* + *b:ale_haskell_ormolu_executable* + Type: |String| + Default: `'ormolu'` + + This variable can be changed to use a different executable for ormolu. + + +g:ale_haskell_ormolu_options *g:ale_haskell_ormolu_options* + *b:ale_haskell_ormolu_options* + Type: |String| + Default: `''` + + This variable can be used to pass extra options to the underlying ormolu + executable. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-hcl.txt b/sources_non_forked/ale/doc/ale-hcl.txt new file mode 100644 index 00000000..71e1114e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-hcl.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE HCL Integration *ale-hcl-options* + + +=============================================================================== +packer-fmt *ale-hcl-packer-fmt* + +See |ale-packer-fmt-fixer| for information about the available options. + +=============================================================================== +terraform-fmt *ale-hcl-terraform-fmt* + +See |ale-terraform-fmt-fixer| for information about the available options. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-help.txt b/sources_non_forked/ale/doc/ale-help.txt new file mode 100644 index 00000000..89872545 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-help.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Help Integration *ale-help-options* + + +=============================================================================== +cspell *ale-help-cspell* + +See |ale-cspell-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-html.txt b/sources_non_forked/ale/doc/ale-html.txt new file mode 100644 index 00000000..6d18afd1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-html.txt @@ -0,0 +1,202 @@ +=============================================================================== +ALE HTML Integration *ale-html-options* + + +=============================================================================== +angular *ale-html-angular* + +ALE supports language server features for Angular. You can install it via `npm`: > + + $ npm install --save-dev @angular/language-server +< +Angular 11 and up are supported. + + +g:ale_html_angular_executable *g:ale_html_angular_executable* + *b:ale_html_angular_executable* + Type: |String| + Default: `'ngserver'` + + See |ale-integrations-local-executables| + + +g:ale_html_angular_use_global *g:ale_html_angular_use_global* + *b:ale_html_angular_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +cspell *ale-html-cspell* + +See |ale-cspell-options| + +=============================================================================== +fecs *ale-html-fecs* + +`fecs` options for HTML are the same as the options for JavaScript, and both +of them read `./.fecsrc` as the default configuration file. + +See: |ale-javascript-fecs|. + + +=============================================================================== +html-beautify *ale-html-beautify* + +g:ale_html_beautify_executable *g:ale_html_beautify_executable* + *b:ale_html_beautify_executable* + Type: |String| + Default: `'html-beautify'` + + See |ale-integrations-local-executables| + + +g:ale_html_beautify_options *g:ale_html_beautify_options* + *b:ale_html_beautify_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to html-beautify. + + +g:ale_html_beautify_use_global *g:ale_html_beautify_use_global* + *b:ale_html_beautify_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +htmlhint *ale-html-htmlhint* + +g:ale_html_htmlhint_executable *g:ale_html_htmlhint_executable* + *b:ale_html_htmlhint_executable* + Type: |String| + Default: `'htmlhint'` + + See |ale-integrations-local-executables| + + +g:ale_html_htmlhint_options *g:ale_html_htmlhint_options* + *b:ale_html_htmlhint_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to HTMLHint. + + +g:ale_html_htmlhint_use_global *g:ale_html_htmlhint_use_global* + *b:ale_html_htmlhint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prettier *ale-html-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +stylelint *ale-html-stylelint* + +g:ale_html_stylelint_executable *g:ale_html_stylelint_executable* + *b:ale_html_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_html_stylelint_options *g:ale_html_stylelint_options* + *b:ale_html_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_html_stylelint_use_global *g:ale_html_stylelint_use_global* + *b:ale_html_stylelint_use_global* + Type: |String| + Default: `0` + + See |ale-integrations-local-executables| + + +=============================================================================== +tidy *ale-html-tidy* + +`tidy` is a console application which corrects and cleans up HTML and XML +documents by fixing markup errors and upgrading legacy code to modern +standards. + +Note: +`/usr/bin/tidy` on macOS (installed by default) is too old. It was released +on 31 Oct 2006. It does not consider modern HTML specs (HTML5) and shows +outdated warnings. So |ale| ignores `/usr/bin/tidy` on macOS. + +To use `tidy` on macOS, please install the latest version with Homebrew: +> + $ brew install tidy-html5 +< +`/usr/local/bin/tidy` is installed. + +g:ale_html_tidy_executable *g:ale_html_tidy_executable* + *b:ale_html_tidy_executable* + Type: |String| + Default: `'tidy'` + + This variable can be changed to change the path to tidy. + + +g:ale_html_tidy_options *g:ale_html_tidy_options* + *b:ale_html_tidy_options* + Type: |String| + Default: `'-q -e -language en'` + + This variable can be changed to change the arguments provided to the + executable. + + ALE will attempt to automatically detect the appropriate file encoding to + provide to html-tidy, and fall back to UTF-8 when encoding detection fails. + + The recognized file encodings are as follows: ascii, big5, cp1252 (win1252), + cp850 (ibm858), cp932 (shiftjis), iso-2022-jp (iso-2022), latin1, macroman + (mac), sjis (shiftjis), utf-16le, utf-16, utf-8 + + +g:ale_html_tidy_use_global *g:html_tidy_use_global* + + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +vscodehtml *ale-html-vscode* + +Website: https://github.com/hrsh7th/vscode-langservers-extracted + +Installation +------------------------------------------------------------------------------- + +Install VSCode html language server either globally or locally: > + + npm install -g vscode-langservers-extracted +< + +=============================================================================== +write-good *ale-html-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-idris.txt b/sources_non_forked/ale/doc/ale-idris.txt new file mode 100644 index 00000000..c7500b0d --- /dev/null +++ b/sources_non_forked/ale/doc/ale-idris.txt @@ -0,0 +1,23 @@ +=============================================================================== +ALE Idris Integration *ale-idris-options* + +=============================================================================== +idris *ale-idris-idris* + +g:ale_idris_idris_executable *g:ale_idris_idris_executable* + *b:ale_idris_idris_executable* + Type: |String| + Default: `'idris'` + + This variable can be changed to change the path to idris. + + +g:ale_idris_idris_options *g:ale_idris_idris_options* + *b:ale_idris_idris_options* + Type: |String| + Default: `'--total --warnpartial --warnreach --warnipkg'` + + This variable can be changed to modify flags given to idris. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ink.txt b/sources_non_forked/ale/doc/ale-ink.txt new file mode 100644 index 00000000..9412a09f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ink.txt @@ -0,0 +1,40 @@ +=============================================================================== +ALE Ink Integration *ale-ink-options* + + +=============================================================================== +ink-language-server *ale-ink-language-server* + +Ink Language Server + (https://github.com/ephraim/ink-language-server) + +g:ale_ink_ls_executable g:ale_ink_ls_executable + b:ale_ink_ls_executable + Type: |String| + Default: `'ink-language-server'` + + Ink language server executable. + +g:ale_ink_ls_initialization_options + g:ale_ink_ls_initialization_options + b:ale_ink_ls_initialization_options + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server at startup. For certain platforms and certain story + structures, the defaults will suffice. However, many projects will need to + change these settings - see the ink-language-server website for more + information. + + An example of setting non-default options: + { + \ 'ink': { + \ 'mainStoryPath': 'init.ink', + \ 'inklecateExecutablePath': '/usr/local/bin/inklecate', + \ 'runThroughMono': v:false + \ } + \} + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-inko.txt b/sources_non_forked/ale/doc/ale-inko.txt new file mode 100644 index 00000000..5ca14af6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-inko.txt @@ -0,0 +1,22 @@ +=============================================================================== +ALE Inko Integration *ale-inko-options* + *ale-integration-inko* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Inko is the Inko compiler itself. + +=============================================================================== +inko *ale-inko-inko* + +g:ale_inko_inko_executable *g:ale_inko_inko_executable* + *b:ale_inko_inko_executable* + Type: |String| + Default: `'inko'` + + This variable can be modified to change the executable path for `inko`. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ispc.txt b/sources_non_forked/ale/doc/ale-ispc.txt new file mode 100644 index 00000000..bf30e8e3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ispc.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE ISPC Integration *ale-ispc-options* + + +=============================================================================== +ispc *ale-ispc-ispc* + +g:ale_ispc_ispc_executable *g:ale_ispc_ispc_executable* + *b:ale_ispc_ispc_executable* + Type: |String| + Default: `'ispc'` + + This variable can be changed to use a different executable for ispc. + + +g:ale_ispc_ispc_options *g:ale_ispc_ispc_options* + *b:ale_ispc_ispc_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to ispc. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-java.txt b/sources_non_forked/ale/doc/ale-java.txt new file mode 100644 index 00000000..8767c791 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-java.txt @@ -0,0 +1,284 @@ +=============================================================================== +ALE Java Integration *ale-java-options* + + +=============================================================================== +checkstyle *ale-java-checkstyle* + +g:ale_java_checkstyle_config *g:ale_java_checkstyle_config* + *b:ale_java_checkstyle_config* + + Type: |String| + Default: `'/google_checks.xml'` + + A path to a checkstyle configuration file. + + If a configuration file is specified with |g:ale_java_checkstyle_options|, + it will be preferred over this setting. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + + +g:ale_java_checkstyle_executable *g:ale_java_checkstyle_executable* + *b:ale_java_checkstyle_executable* + + Type: |String| + Default: `'checkstyle'` + + This variable can be changed to modify the executable used for checkstyle. + + +g:ale_java_checkstyle_options *g:ale_java_checkstyle_options* + *b:ale_java_checkstyle_options* + + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to checkstyle. + + If a configuration file is specified with `-c`, it will be used instead of + configuration files set with |g:ale_java_checkstyle_config|. + + +=============================================================================== +cspell *ale-java-cspell* + +See |ale-cspell-options| + + +=============================================================================== +javac *ale-java-javac* + +g:ale_java_javac_classpath *g:ale_java_javac_classpath* + *b:ale_java_javac_classpath* + Type: |String| or |List| + Default: `''` + + This variable can be set to change the global classpath for Java. + + +g:ale_java_javac_executable *g:ale_java_javac_executable* + *b:ale_java_javac_executable* + Type: |String| + Default: `'javac'` + + This variable can be set to change the executable path used for javac. + + +g:ale_java_javac_options *g:ale_java_javac_options* + *b:ale_java_javac_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to javac. + +g:ale_java_javac_sourcepath *g:ale_java_javac_sourcepath* + *b:ale_java_javac_sourcepath* + Type: |String| or |List| + Default: `''` + +This variable can set multiple source code paths, the source code path is a +relative path (relative to the project root directory). + +Example: + +String type: +Note that the unix system separator is a colon(`:`) window system +is a semicolon(`;`). +> + let g:ale_java_javac_sourcepath = 'build/gen/source/xx/main:build/gen/source' +< +List type: +> + let g:ale_java_javac_sourcepath = [ + \ 'build/generated/source/querydsl/main', + \ 'target/generated-sources/source/querydsl/main' + \ ] +< + +=============================================================================== +google-java-format *ale-java-google-java-format* + + +g:ale_java_google_java_format_executable + *g:ale_java_google_java_format_executable* + *b:ale_java_google_java_format_executable* + Type: |String| + Default: `'google-java-format'` + + See |ale-integrations-local-executables| + + +g:ale_java_google_java_format_options *g:ale_java_google_java_format_options* + *b:ale_java_google_java_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options + + +=============================================================================== +pmd *ale-java-pmd* + +g:ale_java_pmd_options *g:ale_java_pmd_options* + *b:ale_java_pmd_options* + + Type: |String| + Default: `'-R category/java/bestpractices'` + + This variable can be changed to modify flags given to PMD. Do not specify -f + and -d. They are added automatically. + + +=============================================================================== +javalsp *ale-java-javalsp* + +To enable Java LSP linter you need to download and build the vscode-javac +language server from https://github.com/georgewfraser/java-language-server. + +Before building the language server you need to install pre-requisites: npm, +maven, and protobuf. You also need to have Java 13 and JAVA_HOME properly +set. + +After downloading the source code and installing all pre-requisites you can +build the language server with the included build.sh script: + + scripts/build.sh + +This will create launch scripts for Linux, Mac, and Windows in the dist folder +within the repo: + + - lang_server_linux.sh + - lang_server_mac.sh + - lang_server_windows.sh + +To let ALE use this language server you need to set the +g:ale_java_javalsp_executable variable to the absolute path of the launcher +executable for your platform. + +g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* + *b:ale_java_javalsp_executable* + Type: |String| + Default: `''` + +This variable must be set to the absolute path of the language server launcher +executable. For example: +> + let g:ale_java_javalsp_executable=/java-language-server/dist/lang_server_linux.sh +< + +g:ale_java_javalsp_config *g:ale_java_javalsp_config* + *b:ale_java_javalsp_config* + Type: |Dictionary| + Default: `{}` + +The javalsp linter automatically detects external dependencies for Maven and +Gradle projects. In case the javalsp fails to detect some of them, you can +specify them setting a dictionary to |g:ale_java_javalsp_config| variable. +> + let g:ale_java_javalsp_config = + \ { + \ 'java': { + \ 'externalDependencies': [ + \ 'junit:junit:jar:4.12:test', " Maven format + \ 'junit:junit:4.1' " Gradle format + \ ], + \ 'classPath': [ + \ 'lib/some-dependency.jar', + \ '/android-sdk/platforms/android-28.jar' + \ ] + \ } + \ } + +The Java language server will look for the dependencies you specify in +`externalDependencies` array in your Maven and Gradle caches ~/.m2 and +~/.gradle. + + +=============================================================================== +eclipselsp *ale-java-eclipselsp* + +To enable Eclipse JDT LSP linter you need to clone and build the eclipse.jdt.ls +language server from https://github.com/eclipse/eclipse.jdt.ls. Simply +clone the source code repo and then build the plugin: + + ./mvnw clean verify + +Note: currently, the build can only run when launched with JDK 11. More +recent versions can be used to run the server though. + +After build completes the files required to run the language server will be +located inside the repository folder `eclipse.jdt.ls`. Please ensure to set +|g:ale_java_eclipselsp_path| to the absolute path of that folder. + +You could customize compiler options and code assists of the server. +Under your project folder, modify the file `.settings/org.eclipse.jdt.core.prefs` +with options presented at +https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/JavaCore.html. + +g:ale_java_eclipselsp_path *g:ale_java_eclipselsp_path* + *b:ale_java_eclipselsp_path* + + Type: |String| + Default: `'$HOME/eclipse.jdt.ls'` + + Absolute path to the location of the eclipse.jdt.ls repository folder. Or if + you have VSCode extension installed the absolute path to the VSCode + extensions folder (e.g. $HOME/.vscode/extensions/redhat.java-0.4x.0 in + Linux). + + +g:ale_java_eclipselsp_executable *g:ale_java_eclipse_executable* + *b:ale_java_eclipse_executable* + Type: |String| + Default: `'java'` + + This variable can be set to change the executable path used for java. + + +g:ale_java_eclipselsp_config_path *g:ale_java_eclipse_config_path* + *b:ale_java_eclipse_config_path* + Type: |String| + Default: `''` + + Set this variable to change the configuration directory path used by + eclipselsp (e.g. `$HOME/.jdtls` in Linux). + By default ALE will attempt to use the configuration within the installation + directory. + This setting is particularly useful when eclipselsp is installed in a + non-writable directory like `/usr/share/java/jdtls`, as is the case when + installed via system package. + + +g:ale_java_eclipselsp_workspace_path *g:ale_java_eclipselsp_workspace_path* + *b:ale_java_eclipselsp_workspace_path* + + Type: |String| + Default: `''` + + If you have Eclipse installed is good idea to set this variable to the + absolute path of the Eclipse workspace. If not set this value will be set to + the parent folder of the project root. + +g:ale_java_eclipselsp_javaagent *g:ale_java_eclipselsp_javaagent* + *b:ale_java_eclipselsp_javaagent* + + Type: |String| + Default: `''` + + A variable to add java agent for annotation processing such as Lombok. + If you have multiple java agent files, use space to separate them. + For example: +> + let g:ale_java_eclipselsp_javaagent='/eclipse/lombok.jar /eclipse/jacoco.jar' +< + +=============================================================================== +uncrustify *ale-java-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-javascript.txt b/sources_non_forked/ale/doc/ale-javascript.txt new file mode 100644 index 00000000..7d626efe --- /dev/null +++ b/sources_non_forked/ale/doc/ale-javascript.txt @@ -0,0 +1,354 @@ +=============================================================================== +ALE JavaScript Integration *ale-javascript-options* + + *ale-eslint-nested-configuration-files* + +For fixing files with ESLint, nested configuration files with `root: false` +are not supported. This is because ALE fixes files by writing the contents of +buffers to temporary files, and then explicitly sets the configuration file. +Configuration files which are set explicitly must be root configuration files. +If you are using nested configuration files, you should restructure your +project so your configuration files use `extends` instead. + +See the ESLint documentation here: +http://eslint.org/docs/user-guide/configuring#extending-configuration-files + +You should change the structure of your project from this: > + /path/foo/.eslintrc.js # root: true + /path/foo/bar/.eslintrc.js # root: false +< +To this: > + /path/foo/.base-eslintrc.js # Base configuration here + /path/foo/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"] + /path/foo/bar/.eslintrc.js # extends: ["/path/foo/.base-eslintrc.js"] +< + +=============================================================================== +cspell *ale-javascript-cspell* + +See |ale-cspell-options| + + +=============================================================================== +deno *ale-javascript-deno* + +Check the docs over at |ale-typescript-deno|. + + +=============================================================================== +dprint *ale-javascript-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/typescript + + +=============================================================================== +eslint *ale-javascript-eslint* + +g:ale_javascript_eslint_executable *g:ale_javascript_eslint_executable* + *b:ale_javascript_eslint_executable* + Type: |String| + Default: `'eslint'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_eslint_options *g:ale_javascript_eslint_options* + *b:ale_javascript_eslint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to eslint. + + +g:ale_javascript_eslint_use_global *g:ale_javascript_eslint_use_global* + *b:ale_javascript_eslint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_javascript_eslint_suppress_eslintignore + *g:ale_javascript_eslint_suppress_eslintignore* + *b:ale_javascript_eslint_suppress_eslintignore* + Type: |Number| + Default: `0` + + This variable can be set to `1` to disable warnings for files being ignored + by eslint. + + +g:ale_javascript_eslint_suppress_missing_config + *g:ale_javascript_eslint_suppress_missing_config* + *b:ale_javascript_eslint_suppress_missing_config* + Type: |Number| + Default: `0` + + This variable can be set to `1` to disable errors for missing eslint + configuration files. + + When turning this option on, eslint will not report any problems when no + configuration files are found. + + +=============================================================================== +fecs *ale-javascript-fecs* + +`fecs` is a lint tool for HTML/CSS/JavaScript, can be installed via: + + `$ npm install --save-dev fecs` + +And the configuration file is located at `./fecsrc`, see http://fecs.baidu.com +for more options. + + +g:ale_javascript_fecs_executable *g:ale_javascript_fecs_executable* + *b:ale_javascript_fecs_executable* + Type: |String| + Default: `'fecs'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_fecs_use_global *g:ale_javascript_fecs_use_global* + *b:ale_javascript_fecs_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +flow *ale-javascript-flow* + +g:ale_javascript_flow_executable *g:ale_javascript_flow_executable* + *b:ale_javascript_flow_executable* + Type: |String| + Default: `'flow'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_flow_use_home_config *g:ale_javascript_flow_use_home_config* + *b:ale_javascript_flow_use_home_config* + Type: |Number| + Default: `0` + + When set to `1`, ALE will allow Flow to be executed with configuration files + from your home directory. ALE will not run Flow with home directory + configuration files by default, as doing so can lead to Vim consuming all of + your RAM and CPU power. + + +g:ale_javascript_flow_use_global *g:ale_javascript_flow_use_global* + *b:ale_javascript_flow_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_javascript_flow_use_respect_pragma + *g:ale_javascript_flow_use_respect_pragma* + *b:ale_javascript_flow_use_respect_pragma* + Type: |Number| + Default: `1` + + By default, ALE will use the `--respect-pragma` option for `flow`, so only + files with the `@flow` pragma are checked by ALE. This option can be set to + `0` to disable that behavior, so all files can be checked by `flow`. + + +=============================================================================== +importjs *ale-javascript-importjs* + +g:ale_javascript_importjs_executable *g:ale_javascript_importjs_executable* + *b:ale_javascript_importjs_executable* + Type: |String| + Default: `'importjs'` + + +=============================================================================== +jscs *ale-javascript-jscs* + +g:ale_javascript_jscs_executable *g:ale_javascript_jscs_executable* + *b:ale_javascript_jscs_executable* + Type: |String| + Default: `'jscs'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_jscs_use_global *g:ale_javascript_jscs_use_global* + *b:ale_javascript_jscs_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +jshint *ale-javascript-jshint* + +g:ale_javascript_jshint_executable *g:ale_javascript_jshint_executable* + *b:ale_javascript_jshint_executable* + Type: |String| + Default: `'jshint'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_jshint_use_global *g:ale_javascript_jshint_use_global* + *b:ale_javascript_jshint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prettier *ale-javascript-prettier* + +g:ale_javascript_prettier_executable *g:ale_javascript_prettier_executable* + *b:ale_javascript_prettier_executable* + Type: |String| + Default: `'prettier'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_prettier_options *g:ale_javascript_prettier_options* + *b:ale_javascript_prettier_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to prettier. + + +g:ale_javascript_prettier_use_global *g:ale_javascript_prettier_use_global* + *b:ale_javascript_prettier_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prettier-eslint *ale-javascript-prettier-eslint* + +g:ale_javascript_prettier_eslint_executable + *g:ale_javascript_prettier_eslint_executable* + *b:ale_javascript_prettier_eslint_executable* + Type: |String| + Default: `'prettier-eslint'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_prettier_eslint_options + *g:ale_javascript_prettier_eslint_options* + *b:ale_javascript_prettier_eslint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to prettier-eslint. + + +g:ale_javascript_prettier_eslint_use_global + *g:ale_javascript_prettier_eslint_use_global* + *b:ale_javascript_prettier_eslint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prettier-standard *ale-javascript-prettier-standard* + + +g:ale_javascript_prettier_standard_executable + *g:ale_javascript_prettier_standard_executable* + *b:ale_javascript_prettier_standard_executable* + Type: |String| + Default: `'prettier-standard'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_prettier_standard_options + *g:ale_javascript_prettier_standard_options* + *b:ale_javascript_prettier_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to prettier-standard. + + +g:ale_javascript_prettier_standard_use_global + *g:ale_javascript_prettier_standard_use_global* + *b:ale_javascript_prettier_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + + + +=============================================================================== +standard *ale-javascript-standard* + +g:ale_javascript_standard_executable *g:ale_javascript_standard_executable* + *b:ale_javascript_standard_executable* + Type: |String| + Default: `'standard'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_standard_options *g:ale_javascript_standard_options* + *b:ale_javascript_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to standard. + + +g:ale_javascript_standard_use_global *g:ale_javascript_standard_use_global* + *b:ale_javascript_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +xo *ale-javascript-xo* + +g:ale_javascript_xo_executable *g:ale_javascript_xo_executable* + *b:ale_javascript_xo_executable* + Type: |String| + Default: `'xo'` + + See |ale-integrations-local-executables| + + +g:ale_javascript_xo_options *g:ale_javascript_xo_options* + *b:ale_javascript_xo_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xo. + + +g:ale_javascript_xo_use_global *g:ale_javascript_xo_use_global* + *b:ale_javascript_xo_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-json.txt b/sources_non_forked/ale/doc/ale-json.txt new file mode 100644 index 00000000..154aee62 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-json.txt @@ -0,0 +1,170 @@ +=============================================================================== +ALE JSON Integration *ale-json-options* + + +=============================================================================== +cspell *ale-json-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dprint *ale-json-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/json + + +=============================================================================== +eslint *ale-json-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSON ESLint plugin installed for this to work. + + +=============================================================================== +fixjson *ale-json-fixjson* + +fixjson is a JSON file fixer/formatter for humans using (relaxed) JSON5. +It provides: + +- Pretty-prints JSON input +- Fixes various failures while humans writing JSON + - Fixes trailing commas objects or arrays + - Fixes missing commas for elements of objects or arrays + - Adds quotes to keys in objects + - Newlines in strings + - Hex numbers + - Fixes single quotes to double quotes + +You can install it using npm: +> + $ npm install -g fixjson +< +ALE provides fixjson integration as a fixer. See |ale-fix|. + +g:ale_json_fixjson_executable *g:ale_json_fixjson_executable* + *b:ale_json_fixjson_executable* + + Type: |String| + Default: `'fixjson'` + + The executable that will be run for fixjson. + +g:ale_json_fixjson_options *g:ale_json_fixjson_options* + *b:ale_json_fixjson_options* + + Type: |String| + Default: `''` + + This variable can add extra options to the command executed for running + fixjson. + +g:ale_json_fixjson_use_global *g:ale_json_fixjson_use_global* + *b:ale_json_fixjson_use_global* + + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +jsonlint *ale-json-jsonlint* + +g:ale_json_jsonlint_executable *g:ale_json_jsonlint_executable* + *b:ale_json_jsonlint_executable* + + Type: |String| + Default: `'jsonlint'` + + The executable that will be run for jsonlint. + +g:ale_json_jsonlint_use_global *g:ale_json_jsonlint_use_global* + *b:ale_json_jsonlint_use_global* + + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +jq *ale-json-jq* + +g:ale_json_jq_executable *g:ale_json_jq_executable* + *b:ale_json_jq_executable* + Type: |String| + Default: `'jq'` + + This option can be changed to change the path for `jq`. + + +g:ale_json_jq_options *g:ale_json_jq_options* + *b:ale_json_jq_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jq`. + +g:ale_json_jq_filters *g:ale_json_jq_filters* + *b:ale_json_jq_filters* + Type: |String| + Default: `'.'` + + This option can be changed to pass custom filters to `jq`. + + +=============================================================================== +prettier *ale-json-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +spectral *ale-json-spectral* + +Website: https://github.com/stoplightio/spectral + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_json_spectral_executable *g:ale_json_spectral_executable* + *b:ale_json_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_json_spectral_use_global *g:ale_json_spectral_use_global* + *b:ale_json_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + +=============================================================================== +vscodejson *ale-json-vscode* + +Website: https://github.com/hrsh7th/vscode-langservers-extracted + +Installation +------------------------------------------------------------------------------- + +Install VSCode json language server either globally or locally: > + + npm install -g vscode-langservers-extracted +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-json5.txt b/sources_non_forked/ale/doc/ale-json5.txt new file mode 100644 index 00000000..bafa60d1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-json5.txt @@ -0,0 +1,15 @@ +=============================================================================== +ALE JSON5 Integration *ale-json5-options* + + +=============================================================================== +eslint *ale-json5-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSON5 ESLint plugin installed for this to work. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-jsonc.txt b/sources_non_forked/ale/doc/ale-jsonc.txt new file mode 100644 index 00000000..92247cd4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-jsonc.txt @@ -0,0 +1,15 @@ +=============================================================================== +ALE JSONC Integration *ale-jsonc-options* + + +=============================================================================== +eslint *ale-jsonc-eslint* + +The `eslint` linter for JSON uses the JavaScript options for `eslint`; see: +|ale-javascript-eslint|. + +You will need a JSONC ESLint plugin installed for this to work. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-jsonnet.txt b/sources_non_forked/ale/doc/ale-jsonnet.txt new file mode 100644 index 00000000..f99d415f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-jsonnet.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Jsonnet Integration *ale-jsonnet-options* + + +=============================================================================== +jsonnetfmt *ale-jsonnet-jsonnetfmt* + +g:ale_jsonnet_jsonnetfmt_executable *g:ale_jsonnet_jsonnetfmt_executable* + *b:ale_jsonnet_jsonnetfmt_executable* + Type: |String| + Default: `'jsonnetfmt'` + + This option can be changed to change the path for `jsonnetfmt`. + + +g:ale_jsonnet_jsonnetfmt_options *g:ale_jsonnet_jsonnetfmt_options* + *b:ale_jsonnet_jsonnetfmt_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jsonnetfmt`. + + +=============================================================================== +jsonnet-lint *ale-jsonnet-jsonnet-lint* + +g:ale_jsonnet_jsonnet_lint_executable *g:ale_jsonnet_jsonnet_lint_executable* + *b:ale_jsonnet_jsonnet_lint_executable* + Type: |String| + Default: `'jsonnet-lint'` + + This option can be changed to change the path for `jsonnet-lint`. + + +g:ale_jsonnet_jsonnet_lint_options *g:ale_jsonnet_jsonnet_lint_options* + *b:ale_jsonnet_jsonnet_lint_options* + Type: |String| + Default: `''` + + This option can be changed to pass extra options to `jsonnet-lint`. + + + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-julia.txt b/sources_non_forked/ale/doc/ale-julia.txt new file mode 100644 index 00000000..ab74ee12 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-julia.txt @@ -0,0 +1,20 @@ +=============================================================================== +ALE Julia Integration *ale-julia-options* + +=============================================================================== +languageserver *ale-julia-languageserver* + +To enable Julia LSP linter you need to install the LanguageServer.jl package +within julia. + +g:ale_julia_executable *g:ale_julia_executable* + *b:ale_julia_executable* + + Type: |String| + Default: `'julia'` + + Path to the julia exetuable. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-kotlin.txt b/sources_non_forked/ale/doc/ale-kotlin.txt new file mode 100644 index 00000000..87cf56c5 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-kotlin.txt @@ -0,0 +1,113 @@ +=============================================================================== +ALE Kotlin Integration *ale-kotlin-options* + *ale-integration-kotlin* + +=============================================================================== +Integration Information + + Make sure your setup has support for the kotlin file type. A filetype plugin + can be found here: https://github.com/udalov/kotlin-vim + + + Note: Make sure you have a working kotlin compiler + + +=============================================================================== +kotlinc *ale-kotlin-kotlinc* + +g:ale_kotlin_kotlinc_options *g:ale_kotlin_kotlinc_options* + Type: |String| + Default: `''` + + Additional options to pass to the kotlin compiler + +g:ale_kotlin_kotlinc_enable_config *g:ale_kotlin_kotlinc_enable_config* + Type: |Number| + Default: `0` + + Setting this variable to `1` tells the linter to load a configuration file. + This should be set in your vimrc + +g:ale_kotlin_kotlinc_config_file *g:ale_kotlin_kotlinc_config_file* + Type: |String| + Default: `'.ale_kotlin_kotlinc_config'` + + Filename of the configuration file. This should be set in your vimrc + +g:ale_kotlin_kotlinc_classpath *g:ale_kotlin_kotlinc_classpath* + Type: |String| + Default: `''` + + A string containing the paths (separated by the appropriate path separator) + of the source directories. + +g:ale_kotlin_kotlinc_sourcepath *g:ale_kotlin_kotlinc_sourcepath* + Type: |String| + Default: `''` + + A string containing the paths (separated by space) of the source + directories. + +g:ale_kotlin_kotlinc_use_module_file *g:ale_kotlin_kotlinc_use_module_file* + Type: |Number| + Default: `0` + + This option indicates whether the linter should use a module file. It is off + by default. + +g:ale_kotlin_kotlinc_module_filename *g:ale_kotlin_kotlinc_module_filename* + Type: |String| + Default: `'module.xml'` + + The filename of the module file that the linter should pass to the kotlin + compiler. + + +=============================================================================== +ktlint *ale-kotlin-ktlint* + +g:ale_kotlin_ktlint_executable *g:ale_kotlin_ktlint_executable* + Type: |String| + Default: `''` + + The Ktlint executable. + + Posix-compliant shell scripts are the only executables that can be found on + Ktlint's github release page. If you are not on such a system, your best + bet will be to download the ktlint jar and set this option to something + similar to `'java -jar /path/to/ktlint.jar'` + +g:ale_kotlin_ktlint_rulesets *g:ale_kotlin_ktlint_rulesets* + Type: |List| of |String|s + Default: `[]` + + This list should contain paths to ruleset jars and/or strings of maven + artifact triples. Example: + > + let g:ale_kotlin_ktlint_rulesets = ['/path/to/custom-ruleset.jar', + 'com.ktlint.rulesets:mycustomrule:1.0.0'] + +g:ale_kotlin_ktlint_options *g:ale_kotlin_ktlint_options* + Type: |String| + Default: `''` + + Additional options to pass to ktlint for both linting and fixing. Example: + > + let g:ale_kotlin_ktlint_options = '--android' + + +=============================================================================== +languageserver *ale-kotlin-languageserver* + +g:ale_kotlin_languageserver_executable *g:ale_kotlin_languageserver_executable* + Type: |String| + Default: `''` + + The kotlin-language-server executable. + + Executables are located inside the bin/ folder of the language server + release. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-latex.txt b/sources_non_forked/ale/doc/ale-latex.txt new file mode 100644 index 00000000..b3029a5b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-latex.txt @@ -0,0 +1,21 @@ +=============================================================================== +ALE LaTeX Integration *ale-latex-options* + + +=============================================================================== +cspell *ale-latex-cspell* + +=============================================================================== +write-good *ale-latex-write-good* + +See |ale-write-good-options| + + +=============================================================================== +textlint *ale-latex-textlint* + +See |ale-text-textlint| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-less.txt b/sources_non_forked/ale/doc/ale-less.txt new file mode 100644 index 00000000..040e511e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-less.txt @@ -0,0 +1,66 @@ +=============================================================================== +ALE Less Integration *ale-less-options* + + +=============================================================================== +lessc *ale-less-lessc* + +g:ale_less_lessc_executable *g:ale_less_lessc_executable* + *b:ale_less_lessc_executable* + Type: |String| + Default: `'lessc'` + + See |ale-integrations-local-executables| + + +g:ale_less_lessc_options *g:ale_less_lessc_options* + *b:ale_less_lessc_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lessc. + + +g:ale_less_lessc_use_global *g:ale_less_lessc_use_global* + *b:ale_less_lessc_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prettier *ale-less-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +stylelint *ale-less-stylelint* + +g:ale_less_stylelint_executable *g:ale_less_stylelint_executable* + *b:ale_less_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_less_stylelint_options *g:ale_less_stylelint_options* + *b:ale_less_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_less_stylelint_use_global *g:ale_less_stylelint_use_global* + *b:ale_less_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-llvm.txt b/sources_non_forked/ale/doc/ale-llvm.txt new file mode 100644 index 00000000..fff1c305 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-llvm.txt @@ -0,0 +1,19 @@ +=============================================================================== +ALE LLVM Integration *ale-llvm-options* + + +=============================================================================== +llc *ale-llvm-llc* + +g:ale_llvm_llc_executable *g:ale_llvm_llc_executable* + *b:ale_llvm_llc_executable* + + Type: |String| + Default: `"llc"` + + The command to use for checking. This variable is useful when llc command + has suffix like "llc-5.0". + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-lua.txt b/sources_non_forked/ale/doc/ale-lua.txt new file mode 100644 index 00000000..7ee60d0e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-lua.txt @@ -0,0 +1,118 @@ +=============================================================================== +ALE Lua Integration *ale-lua-options* + + +=============================================================================== +cspell *ale-lua-cspell* + +See |ale-cspell-options| + + +=============================================================================== +lua-format *ale-lua-lua-format* + +g:ale_lua_lua_format_executable *g:ale_lua_lua_format_executable* + *b:ale_lua_lua_format_executable* + Type: |String| + Default: `'lua-format'` + + This variable can be changed to change the path to lua-format. + + +g:ale_lua_lua_format_options *g:ale_lua_lua_format_options* + *b:ale_lua_lua_format_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lua-format. + + +=============================================================================== +luac *ale-lua-luac* + +g:ale_lua_luac_executable *g:ale_lua_luac_executable* + *b:ale_lua_luac_executable* + Type: |String| + Default: `'luac'` + + This variable can be changed to change the path to luac. + + +=============================================================================== +luacheck *ale-lua-luacheck* + +g:ale_lua_luacheck_executable *g:ale_lua_luacheck_executable* + *b:ale_lua_luacheck_executable* + Type: |String| + Default: `'luacheck'` + + This variable can be changed to change the path to luacheck. + + +g:ale_lua_luacheck_options *g:ale_lua_luacheck_options* + *b:ale_lua_luacheck_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to luacheck. + + +=============================================================================== +luafmt *ale-lua-luafmt* + +g:ale_lua_luafmt_executable *g:ale_lua_luafmt_executable* + *b:ale_lua_luafmt_executable* + Type: |String| + Default: `'luafmt'` + + This variable can be set to use a different executable for luafmt. + + +g:ale_lua_luafmt_options *g:ale_lua_luafmt_options* + *b:ale_lua_luafmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the luafmt fixer. + + +=============================================================================== +selene *ale-lua-selene* + +g:ale_lua_selene_executable *g:ale_lua_selene_executable* + *b:ale_lua_selene_executable* + Type: |String| + Default: `'selene'` + + This variable can be set to use a different executable for selene. + + +g:ale_lua_selene_options *g:ale_lua_selene_options* + *b:ale_lua_selene_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to selene. + + +=============================================================================== +stylua *ale-lua-stylua* + +g:ale_lua_stylua_executable *g:ale_lua_stylua_executable* + *b:ale_lua_stylua_executable* + Type: |String| + Default: `'stylua'` + + This variable can be set to use a different executable for stylua. + + +g:ale_lua_stylua_options *g:ale_lua_stylua_options* + *b:ale_lua_stylua_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the stylua fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-make.txt b/sources_non_forked/ale/doc/ale-make.txt new file mode 100644 index 00000000..74de798f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-make.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE Make Integration *ale-make-options* + + +=============================================================================== +checkmake *ale-make-checkmake* + +g:ale_make_checkmake_config *g:ale_make_checkmake_config* + *b:ale_make_checkmake_config* + Type: |String| + Default: `''` + + This variable can be used to set the `--config` option of checkmake command. + if the value is empty, the checkmake command will not be invoked with the + option. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-markdown.txt b/sources_non_forked/ale/doc/ale-markdown.txt new file mode 100644 index 00000000..6ba78ff0 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-markdown.txt @@ -0,0 +1,113 @@ +=============================================================================== +ALE Markdown Integration *ale-markdown-options* + + +=============================================================================== +cspell *ale-markdown-cspell* + +See |ale-cspell-options| + + +=============================================================================== +dprint *ale-markdown-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/markdown + + +=============================================================================== +markdownlint *ale-markdown-markdownlint* + +g:ale_markdown_markdownlint_options *g:ale_markdown_markdownlint_options* + *b:ale_markdown_markdownlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to markdownlint. + + +=============================================================================== +mdl *ale-markdown-mdl* + +g:ale_markdown_mdl_executable *g:ale_markdown_mdl_executable* + *b:ale_markdown_mdl_executable* + Type: |String| + Default: `'mdl'` + + Override the invoked mdl binary. This is useful for running mdl from + binstubs or a bundle. + + +g:ale_markdown_mdl_options *g:ale_markdown_mdl_options* + *b:ale_markdown_mdl_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to mdl. + + +=============================================================================== +pandoc *ale-markdown-pandoc* + +g:ale_markdown_pandoc_executable *g:ale_markdown_pandoc_executable* + *b:ale_markdown_pandoc_executable* + Type: |String| + Default: `'pandoc'` + + This variable can be set to specify where to find the pandoc executable + + +g:ale_markdown_pandoc_options *g:ale_markdown_pandoc_options* + *b:ale_markdown_pandoc_options* + Type: |String| + Default: `'-f gfm -t gfm -s -'` + + This variable can be set to change the default options passed to pandoc + + +=============================================================================== +prettier *ale-markdown-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +remark-lint *ale-markdown-remark-lint* + +g:ale_markdown_remark_lint_executable *g:ale_markdown_remark_lint_executable* + *b:ale_markdown_remark_lint_executable* + Type: |String| + Default: `'remark'` + + See |ale-integrations-local-executables| + + +g:ale_markdown_remark_lint_options *g:ale_markdown_remark_lint_options* + *b:ale_markdown_remark_lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to remark-lint. + + +g:ale_markdown_remark_lint_use_global *g:ale_markdown_remark_lint_use_global* + *b:ale_markdown_remark_lint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +textlint *ale-markdown-textlint* + +See |ale-text-textlint| + + +=============================================================================== +write-good *ale-markdown-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-mercury.txt b/sources_non_forked/ale/doc/ale-mercury.txt new file mode 100644 index 00000000..ca06a0a7 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-mercury.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE Mercury Integration *ale-mercury-options* + + +=============================================================================== +mmc *ale-mercury-mmc* + + +g:ale_mercury_mmc_executable *g:ale_mercury_mmc_executable* + *b:ale_mercury_mmc_executable* + Type: |String| + Default: `'mmc'` + + This variable can be changed to use a different executable for mmc. + + +g:ale_mercury_mmc_options *g:ale_mercury_mmc_options* + *b:ale_mercury_mmc_options* + Type: |String| + Default: `'--make --output-compile-error-lines 100'` + + This variable can be set to pass additional options to mmc. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nasm.txt b/sources_non_forked/ale/doc/ale-nasm.txt new file mode 100644 index 00000000..16c024a1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nasm.txt @@ -0,0 +1,26 @@ +=============================================================================== +ALE NASM Integration *ale-nasm-options* + + +=============================================================================== +nasm *ale-nasm-nasm* + +g:ale_nasm_nasm_executable *g:ale_nasm_nasm_executable* + *b:ale_nasm_nasm_executable* + + Type: |String| + Default `'nasm'` + + This variable can be changed to use different executable for NASM. + + +g:ale_nasm_nasm_options *g:ale_nasm_nasm_options* + *b:ale_nasm_nasm_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to NASM. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nim.txt b/sources_non_forked/ale/doc/ale-nim.txt new file mode 100644 index 00000000..8985aeb8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nim.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE Nim Integration *ale-nim-options* + + +=============================================================================== +nimcheck *ale-nim-nimcheck* + + ALE does not provide additional configuration options for `nimcheck` at this + point. + + +=============================================================================== +nimlsp *ale-nim-nimlsp* + +g:nim_nimlsp_nim_sources *g:nim_nimlsp_nim_sources* + + Type: |String| + Default: `''` + + Sets the path to Nim source repository as the first argument to `nimlsp` + command. + + +=============================================================================== +nimpretty *ale-nim-nimpretty* + + +g:ale_nim_nimpretty_executable *g:ale_nim_nimpretty_executable* + *b:ale_nim_nimpretty_executable* + Type: |String| + Default: `'nimpretty'` + + This variable can be changed to use a different executable for nimpretty. + + +g:ale_nim_nimpretty_options *g:ale_nim_nimpretty_options* + *b:ale_nim_nimpretty_options* + Type: |String| + Default: `'--maxLineLen:80'` + + This variable can be changed to modify flags given to nimpretty. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nix.txt b/sources_non_forked/ale/doc/ale-nix.txt new file mode 100644 index 00000000..1df7caff --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nix.txt @@ -0,0 +1,79 @@ +=============================================================================== +ALE Nix Integration *ale-nix-options* + + +=============================================================================== +nixfmt *ale-nix-nixfmt* + +g:ale_nix_nixfmt_executable *g:ale_nix_nixfmt_executable* + *b:ale_nix_nixfmt_executable* + Type: |String| + Default: `'nixfmt'` + + This variable sets the executable used for nixfmt. + +g:ale_nix_nixfmt_options *g:ale_nix_nixfmt_options* + *b:ale_nix_nixfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixfmt fixer. + + +=============================================================================== +nixpkgs-fmt *ale-nix-nixpkgs-fmt* + +g:ale_nix_nixpkgsfmt_executable *g:ale_nix_nixpkgsfmt_executable* + *b:ale_nix_nixpkgsfmt_executable* + Type: |String| + Default: `'nixpkgs-fmt'` + + This variable sets executable used for nixpkgs-fmt. + +g:ale_nix_nixpkgsfmt_options *g:ale_nix_nixpkgsfmt_options* + *b:ale_nix_nixpkgsfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the nixpkgs-fmt + fixer. + + +=============================================================================== +statix *ale-nix-statix* + +g:ale_nix_statix_check_executable *g:ale_nix_statix_check_executable* + *b:ale_nix_statix_check_executable* + Type: |String| + Default: `'statix'` + + This variable sets the executable used for statix when running it as a + linter. + +g:ale_nix_statix_check_options *g:ale_nix_statix_check_options* + *b:ale_nix_statix_check_options* + Type: |String| + Default: `''` + + This variable can be used to pass additional options to statix when running + it as a linter. + +g:ale_nix_statix_fix_executable *g:ale_nix_fix_check_executable* + *b:ale_nix_fix_check_executable* + Type: |String| + Default: `'statix'` + + This variable sets the executable used for statix when running it as a + fixer. + +g:ale_nix_statix_fix_options *g:ale_nix_statix_fix_options* + *b:ale_nix_statix_fix_options* + Type: |String| + Default: `''` + + This variable can be used to pass additional options to statix when running + it as a fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-nroff.txt b/sources_non_forked/ale/doc/ale-nroff.txt new file mode 100644 index 00000000..62ec7896 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-nroff.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE nroff Integration *ale-nroff-options* + + +=============================================================================== +write-good *ale-nroff-write-good* + +See |ale-write-good-options| + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-objc.txt b/sources_non_forked/ale/doc/ale-objc.txt new file mode 100644 index 00000000..0163175a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-objc.txt @@ -0,0 +1,73 @@ +=============================================================================== +ALE Objective-C Integration *ale-objc-options* + + +=============================================================================== +clang *ale-objc-clang* + +g:ale_objc_clang_options *g:ale_objc_clang_options* + *b:ale_objc_clang_options* + Type: |String| + Default: `'-std=c11 -Wall'` + + This variable can be changed to modify flags given to clang. + + +=============================================================================== +clangd *ale-objc-clangd* + +g:ale_objc_clangd_executable *g:ale_objc_clangd_executable* + *b:ale_objc_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_objc_clangd_options *g:ale_objc_clangd_options* + *b:ale_objc_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + +=============================================================================== +uncrustify *ale-objc-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== +ccls *ale-objc-ccls* + +g:ale_objc_ccls_executable *g:ale_objc_ccls_executable* + *b:ale_objc_ccls_executable* + Type: |String| + Default: `'ccls'` + + This variable can be changed to use a different executable for ccls. + + +g:ale_objc_ccls_init_options *g:ale_objc_ccls_init_options* + *b:ale_objc_ccls_init_options* + Type: |Dictionary| + Default: `{}` + + This variable can be changed to customize ccls initialization options. + Example: > + { + \ 'cacheDirectory': '/tmp/ccls', + \ 'cacheFormat': 'binary', + \ 'diagnostics': { + \ 'onOpen': 0, + \ 'opChange': 1000, + \ }, + \ } +< + Visit https://github.com/MaskRay/ccls/wiki/Initialization-options for all + available options and explanations. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-objcpp.txt b/sources_non_forked/ale/doc/ale-objcpp.txt new file mode 100644 index 00000000..cd65ab73 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-objcpp.txt @@ -0,0 +1,42 @@ +=============================================================================== +ALE Objective-C++ Integration *ale-objcpp-options* + + +=============================================================================== +clang *ale-objcpp-clang* + +g:ale_objcpp_clang_options *g:ale_objcpp_clang_options* + *b:ale_objcpp_clang_options* + Type: |String| + Default: `'-std=c++14 -Wall'` + + This variable can be changed to modify flags given to clang. + + +=============================================================================== +clangd *ale-objcpp-clangd* + +g:ale_objcpp_clangd_executable *g:ale_objcpp_clangd_executable* + *b:ale_objcpp_clangd_executable* + Type: |String| + Default: `'clangd'` + + This variable can be changed to use a different executable for clangd. + + +g:ale_objcpp_clangd_options *g:ale_objcpp_clangd_options* + *b:ale_objcpp_clangd_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to clangd. + + +=============================================================================== +uncrustify *ale-objcpp-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-ocaml.txt b/sources_non_forked/ale/doc/ale-ocaml.txt new file mode 100644 index 00000000..a361a7b4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ocaml.txt @@ -0,0 +1,117 @@ +=============================================================================== +ALE OCaml Integration *ale-ocaml-options* + + +=============================================================================== +dune *ale-ocaml-dune* + + Dune is a build system for OCaml projects. The `dune format` command is + supported for automatically formatting `dune` and `dune-project` files. + +g:ale_ocaml_dune_executable *g:ale_ocaml_dune_executable* + *b:ale_ocaml_dune_executable* + Type: |String| + Default: `'dune'` + + This variable can be set to pass the path to dune. + +g:ale_ocaml_dune_options *g:ale_ocaml_dune_options* + *b:ale_ocaml_dune_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the dune fixer. + +=============================================================================== +merlin *ale-ocaml-merlin* + + To use merlin linter for OCaml source code you need to make sure Merlin for + Vim is correctly configured. See the corresponding Merlin wiki page for + detailed instructions + (https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch). + +=============================================================================== +ocamllsp *ale-ocaml-ocamllsp* + + The `ocaml-lsp-server` is the official OCaml implementation of the Language + Server Protocol. See the installation instructions: + https://github.com/ocaml/ocaml-lsp#installation + +g:ale_ocaml_ocamllsp_use_opam *g:ale_ocaml_ocamllsp_use_opam* + *b:ale_ocaml_ocamllsp_use_opam* + Type: |Number| + Default: `get(g:, 'ale_ocaml_ocamllsp_use_opam', 1)` + + This variable can be set to change whether or not opam is used to execute + the language server. + +=============================================================================== +ols *ale-ocaml-ols* + + The `ocaml-language-server` is the engine that powers OCaml and ReasonML + editor support using the Language Server Protocol. See the installation + instructions: + https://github.com/freebroccolo/ocaml-language-server#installation + +g:ale_ocaml_ols_executable *g:ale_ocaml_ols_executable* + *b:ale_ocaml_ols_executable* + Type: |String| + Default: `'ocaml-language-server'` + + This variable can be set to change the executable path for `ols`. + +g:ale_ocaml_ols_use_global *g:ale_ocaml_ols_use_global* + *b:ale_ocaml_ols_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to always use the globally installed + executable. See also |ale-integrations-local-executables|. + +=============================================================================== +ocamlformat *ale-ocaml-ocamlformat* + +g:ale_ocaml_ocamlformat_executable *g:ale_ocaml_ocamlformat_executable* + *b:ale_ocaml_ocamlformat_executable* + Type: |String| + Default: `'ocamlformat'` + + This variable can be set to pass the path of the ocamlformat fixer. + +g:ale_ocaml_ocamlformat_options *g:ale_ocaml_ocamlformat_options* + *b:ale_ocaml_ocamlformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the ocamlformat fixer. + +=============================================================================== +ocp-indent *ale-ocaml-ocp-indent* + +g:ale_ocaml_ocp_indent_executable *g:ale_ocaml_ocp_indent_executable* + *b:ale_ocaml_ocp_indent_executable* + Type: |String| + Default: `ocp-indent` + + This variable can be set to pass the path of the ocp-indent. + +g:ale_ocaml_ocp_indent_options *g:ale_ocaml_ocp_indent_options* + *b:ale_ocaml_ocp_indent_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the ocp-indent. + +g:ale_ocaml_ocp_indent_config *g:ale_ocaml_ocp_indent_config* + *b:ale_ocaml_ocp_indent_config* + Type: |String| + Default: `''` + + This variable can be set to pass additional config to the ocp-indent. + Expand after "--config=". + + "ocp-indent" can also be enabled from ocamlformat config. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-openapi.txt b/sources_non_forked/ale/doc/ale-openapi.txt new file mode 100644 index 00000000..1fc41add --- /dev/null +++ b/sources_non_forked/ale/doc/ale-openapi.txt @@ -0,0 +1,74 @@ +=============================================================================== +ALE OpenApi Integration *ale-openapi-options* + +=============================================================================== +ibm_validator *ale-openapi-ibm-validator* + +Website: https://github.com/IBM/openapi-validator + + +Installation +------------------------------------------------------------------------------- + +Install ibm-openapi-validator either globally or locally: > + + npm install ibm-openapi-validator -g # global + npm install ibm-openapi-validator # local +< +Configuration +------------------------------------------------------------------------------- + +OpenAPI files can be written in YAML or JSON so in order for ALE plugins to +work with these files we must set the buffer |filetype| to either |openapi.yaml| +or |openapi.json| respectively. This causes ALE to lint the file with linters +configured for openapi and yaml files or openapi and json files respectively. + +For example setting filetype to |openapi.yaml| on a buffer and the following +|g:ale_linters| configuration will enable linting of openapi files using both +|ibm_validator| and |yamlint|: + +> + let g:ale_linters = { + \ 'yaml': ['yamllint'], + \ 'openapi': ['ibm_validator'] + \} +< + +The following plugin will detect openapi files automatically and set the +filetype to |openapi.yaml| or |openapi.json|: + + https://github.com/hsanson/vim-openapi + +Options +------------------------------------------------------------------------------- + +g:ale_openapi_ibm_validator_executable *g:ale_openapi_ibm_validator_executable* + *b:ale_openapi_ibm_validator_executable* + Type: |String| + Default: `'lint-openapi'` + + This variable can be set to change the path to lint-openapi. + + +g:ale_openapi_ibm_validator_options *g:ale_openapi_ibm_validator_options* + *b:ale_openapi_ibm_validator_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to lint-openapi. + + +=============================================================================== +prettier *ale-openapi-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +yamllint *ale-openapi-yamllint* + +See |ale-yaml-yamllint| for information about the available options. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-openscad.txt b/sources_non_forked/ale/doc/ale-openscad.txt new file mode 100644 index 00000000..ac416bc3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-openscad.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE OpenSCAD Integration *ale-openscad-options* + + +=============================================================================== +sca2d *ale-openscad-sca2d* + +g:ale_openscad_sca2d_executable *g:ale_openscad_sca2d_executable* + *b:ale_openscad_sca2d_executable* + Type: |String| + Default: `'sca2d'` + + See |ale-integrations-local-executables| + + +g:ale_openscad_sca2d_options *g:ale_openscad_sca2d_options* + *b:ale_openscad_sca2d_options* + Type: |String| + Default: `''` + + This variable can be set to pass options to sca2d. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-packer.txt b/sources_non_forked/ale/doc/ale-packer.txt new file mode 100644 index 00000000..11b7cc22 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-packer.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Packer Integration *ale-packer-options* + + +=============================================================================== +packer-fmt-fixer *ale-packer-fmt-fixer* + +g:ale_packer_fmt_executable *g:ale_packer_fmt_executable* + *b:ale_packer_fmt_executable* + + Type: |String| + Default: `'packer'` + + This variable can be changed to use a different executable for packer. + + +g:ale_packer_fmt_options *g:ale_packer_fmt_options* + *b:ale_packer_fmt_options* + Type: |String| + Default: `''` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pascal.txt b/sources_non_forked/ale/doc/ale-pascal.txt new file mode 100644 index 00000000..03d9a004 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pascal.txt @@ -0,0 +1,24 @@ +=============================================================================== +ALE Pascal Integration *ale-pascal-options* + +=============================================================================== +ptop *ale-pascal-ptop* + +g:ale_pascal_ptop_executable *g:ale_pascal_ptop_executable* + *b:ale_pascal_ptop_executable* + Type: |String| + Default: `'ptop'` + + This variable can be changed to specify the ptop executable. + + +g:ale_pascal_ptop_options *g:ale_pascal_ptop_options* + *b:ale_pascal_ptop_options* + Type: |String| + Default: `''` + +This variable can be set to pass additional options to the ptop fixer. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pawn.txt b/sources_non_forked/ale/doc/ale-pawn.txt new file mode 100644 index 00000000..f836df97 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pawn.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Pawn Integration *ale-pawn-options* + + +=============================================================================== +uncrustify *ale-pawn-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-perl.txt b/sources_non_forked/ale/doc/ale-perl.txt new file mode 100644 index 00000000..5eebc0e3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-perl.txt @@ -0,0 +1,91 @@ +=============================================================================== +ALE Perl Integration *ale-perl-options* + +ALE offers a few ways to check Perl code. Checking code with `perl` is +disabled by default, as `perl` code cannot be checked without executing it. +Specifically, we use the `-c` flag to see if `perl` code compiles. This does +not execute all of the code in a file, but it does run `BEGIN` and `CHECK` +blocks. See `perl --help` and https://stackoverflow.com/a/12908487/406224 + +See |g:ale_linters|. + + +=============================================================================== +perl *ale-perl-perl* + +g:ale_perl_perl_executable *g:ale_perl_perl_executable* + *b:ale_perl_perl_executable* + Type: |String| + Default: `'perl'` + + This variable can be changed to modify the executable used for linting perl. + + +g:ale_perl_perl_options *g:ale_perl_perl_options* + *b:ale_perl_perl_options* + Type: |String| + Default: `'-c -Mwarnings -Ilib'` + + This variable can be changed to alter the command-line arguments to the perl + invocation. + + +=============================================================================== +perlcritic *ale-perl-perlcritic* + +g:ale_perl_perlcritic_executable *g:ale_perl_perlcritic_executable* + *b:ale_perl_perlcritic_executable* + Type: |String| + Default: `'perlcritic'` + + This variable can be changed to modify the perlcritic executable used for + linting perl. + + +g:ale_perl_perlcritic_profile *g:ale_perl_perlcritic_profile* + *b:ale_perl_perlcritic_profile* + Type: |String| + Default: `'.perlcriticrc'` + + This variable can be changed to modify the perlcritic profile used for + linting perl. The current directory is checked for the file, then the + parent directory, etc, until it finds one. If no matching file is found, no + profile is passed to perlcritic. + + Set to an empty string to disable passing a specific profile to perlcritic + with the `'--profile'` option. + + To prevent perlcritic from using any profile, set this variable to an empty + string and pass `'--no-profile'`to perlcritic via the + |g:ale_perl_perlcritic_options| variable. + + +g:ale_perl_perlcritic_options *g:ale_perl_perlcritic_options* + *b:ale_perl_perlcritic_options* + Type: |String| + Default: `''` + + This variable can be changed to supply additional command-line arguments to + the perlcritic invocation. + + +g:ale_perl_perlcritic_showrules *g:ale_perl_perlcritic_showrules* + + Type: |Number| + Default: `0` + + Controls whether perlcritic rule names are shown after the error message. + Defaults to off to reduce length of message. +=============================================================================== +perltidy *ale-perl-perltidy* + +g:ale_perl_perltidy_options *g:ale_perl_perltidy_options* + *b:ale_perl_perltidy_options* + Type: |String| + Default: `''` + + This variable can be changed to alter the command-line arguments to + the perltidy invocation. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-perl6.txt b/sources_non_forked/ale/doc/ale-perl6.txt new file mode 100644 index 00000000..94953db5 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-perl6.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Perl6 Integration *ale-perl6-options* + +Checking code with `perl6` is disabled by default, as `perl6` code cannot be +checked without executing it. Specifically, we use the `-c` flag to see if +`perl6` code compiles. This does not execute all of the code in a file, but it +does run `BEGIN` and `CHECK` blocks. See `perl6 --help` + +Full support requires a perl6 implementation that supports the +PERL6_EXCEPTIONS_HANDLER environment variable and JSON error output, +which was specified in 6.d. Rakudo version 2018.08 is the first rakudo release +that supports this. See `perl6 --version` and +https://docs.perl6.org/programs/03-environment-variables. + +Without this variable, errors and warnings will appear at line 1, and can be +viewed with ALEDetail. This also serves as a fallback for errors and warnings +that do not trigger JSON output. + +See |g:ale_linters|. + + +=============================================================================== +perl6 *ale-perl6-perl6* + +g:ale_perl6_perl6_executable *g:ale_perl6_perl6_executable* + *b:ale_perl6_perl6_executable* + Type: |String| + Default: `'perl6'` + + This variable can be changed to modify the executable used for linting + perl6. + + +g:ale_perl6_perl6_options *g:ale_perl6_perl6_options* + *b:ale_perl6_perl6_options* + Type: |String| + Default: `'-c -Ilib'` + + This variable can be changed to alter the command-line arguments to the + perl6 invocation. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-php.txt b/sources_non_forked/ale/doc/ale-php.txt new file mode 100644 index 00000000..2750a319 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-php.txt @@ -0,0 +1,367 @@ +=============================================================================== +ALE PHP Integration *ale-php-options* + + +=============================================================================== +cspell *ale-php-cspell* + +See |ale-cspell-options| + + +=============================================================================== +langserver *ale-php-langserver* + +g:ale_php_langserver_executable *g:ale_php_langserver_executable* + *b:ale_php_langserver_executable* + Type: |String| + Default: `'php-language-server.php'` + + The variable can be set to configure the executable that will be used for + running the PHP language server. `vendor` directory executables will be + preferred instead of this setting if |g:ale_php_langserver_use_global| is `0`. + + See: |ale-integrations-local-executables| + + +g:ale_php_langserver_use_global *g:ale_php_langserver_use_global* + *b:ale_php_langserver_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to force the language server to be run with + the executable set for |g:ale_php_langserver_executable|. + + See: |ale-integrations-local-executables| + + +=============================================================================== +phan *ale-php-phan* + +WARNING: please use the phan_client linter if you have an configuration file +for your project because the phan will look into your entirely project and +ale will display in the current buffer warnings that may belong to other file. + +g:ale_php_phan_minimum_severity *g:ale_php_phan_minimum_severity* + *b:ale_php_phan_minimum_severity* + Type: |Number| + Default: `0` + + This variable defines the minimum severity level. + + +g:ale_php_phan_executable *g:ale_php_phan_executable* + *b:ale_php_phan_executable* + Type: |String| + Default: `'phan'` + + This variable sets executable used for phan or phan_client. + + +g:ale_php_phan_use_client *g:ale_php_phan_use_client* + *b:ale_php_phan_use_client* + Type: |Number| + Default: `get(g:, 'ale_php_phan_use_client', 0)` + + This variable can be set to 1 to use the phan_client with phan daemon mode + instead of the phan standalone. + + +=============================================================================== +phpcbf *ale-php-phpcbf* + +g:ale_php_phpcbf_executable *g:ale_php_phpcbf_executable* + *b:ale_php_phpcbf_executable* + Type: |String| + Default: `'phpcbf'` + + See |ale-integrations-local-executables| + + +g:ale_php_phpcbf_standard *g:ale_php_phpcbf_standard* + *b:ale_php_phpcbf_standard* + Type: |String| + Default: `''` + + This variable can be set to specify the coding standard used by phpcbf. If no + coding standard is specified, phpcbf will default to fixing against the + PEAR coding standard, or the standard you have set as the default. + + +g:ale_php_phpcbf_use_global *g:ale_php_phpcbf_use_global* + *b:ale_php_phpcbf_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_php_phpcbf_options *g:ale_php_phpcbf_options* + *b:ale_php_phpcbf_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cbf + + +=============================================================================== +phpcs *ale-php-phpcs* + +g:ale_php_phpcs_executable *g:ale_php_phpcs_executable* + *b:ale_php_phpcs_executable* + Type: |String| + Default: `'phpcs'` + + See |ale-integrations-local-executables| + + +g:ale_php_phpcs_standard *g:ale_php_phpcs_standard* + *b:ale_php_phpcs_standard* + Type: |String| + Default: `''` + + This variable can be set to specify the coding standard used by phpcs. If no + coding standard is specified, phpcs will default to checking against the + PEAR coding standard, or the standard you have set as the default. + + +g:ale_php_phpcs_use_global *g:ale_php_phpcs_use_global* + *b:ale_php_phpcs_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_php_phpcs_options *g:ale_php_phpcs_options* + *b:ale_php_phpcs_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cs + + +=============================================================================== +phpmd *ale-php-phpmd* + +g:ale_php_phpmd_executable *g:ale_php_phpmd_executable* + *b:ale_php_phpmd_executable* + Type: |String| + Default: `'phpmd'` + + This variable sets executable used for phpmd. + + +g:ale_php_phpmd_ruleset *g:ale_php_phpmd_ruleset* + *b:ale_php_phpmd_ruleset* + Type: |String| + Default: `'cleancode,codesize,controversial,design,naming,unusedcode'` + + This variable controls the ruleset used by phpmd. Default is to use all of + the available phpmd rulesets + + +=============================================================================== +phpstan *ale-php-phpstan* + +g:ale_php_phpstan_executable *g:ale_php_phpstan_executable* + *b:ale_php_phpstan_executable* + Type: |String| + Default: `'phpstan'` + + This variable sets executable used for phpstan. + + +g:ale_php_phpstan_level *g:ale_php_phpstan_level* + *b:ale_php_phpstan_level* + Type: |String| + Default: `''` + + This variable controls the rule levels. 0 is the loosest and 7 is the + strictest. If this option isn't set, the rule level will be controlled by + the configuration file. If no configuration file can be detected, `'7'` will + be used instead. + + +g:ale_php_phpstan_configuration *g:ale_php_phpstan_configuration* + *b:ale_php_phpstan_configuration* + Type: |String| + Default: `''` + + This variable sets path to phpstan configuration file. + + +g:ale_php_phpstan_autoload *g:ale_php_phpstan_autoload* + *b:ale_php_phpstan_autoload* + Type: |String| + Default: `''` + + This variable sets path to phpstan autoload file. + + +g:ale_php_phpstan_memory_limit *g:ale_php_phpstan_memory-limit* + *b:ale_php_phpstan_memory-limit* + Type: |String| + Default: `''` + + This variable sets the memory limit for phpstan analysis. This is a string + in the same format as `php.ini` accepts, e.g. `128M`, `1G`. + + +=============================================================================== +psalm *ale-php-psalm* + +g:ale_php_psalm_executable *g:ale_php_psalm_executable* + *b:ale_php_psalm_executable* + Type: |String| + Default: `'psalm'` + + This variable sets the executable used for psalm. + + +g:ale_php_psalm_options *g:ale_php_psalm_options* + *b:ale_php_psalm_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to psalm. + + +g:ale_php_psalm_use_global *g:ale_php_psalm_use_global* + *b:ale_php_psalm_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php-cs-fixer *ale-php-php-cs-fixer* + +g:ale_php_cs_fixer_executable *g:ale_php_cs_fixer_executable* + *b:ale_php_cs_fixer_executable* + Type: |String| + Default: `'php-cs-fixer'` + + This variable sets executable used for php-cs-fixer. + + +g:ale_php_cs_fixer_options *g:ale_php_cs_fixer_options* + *b:ale_php_cs_fixer_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to php-cs-fixer. + + +g:ale_php_cs_fixer_use_global *g:ale_php_cs_fixer_use_global* + *b:ale_php_cs_fixer_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +php *ale-php-php* + +g:ale_php_php_executable *g:ale_php_php_executable* + *b:ale_php_php_executable* + Type: |String| + Default: `'php'` + + This variable sets the executable used for php. + + +=============================================================================== +pint *ale-php-pint* + +g:ale_php_pint_executable *g:ale_php_pint_executable* + *b:ale_php_pint_executable* + Type: |String| + Default: `'pint'` + + This variable sets the executable used for pint. + + +g:ale_php_pint_options *g:ale_php_pint_options* + *b:ale_php_pint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to pint. + + +g:ale_php_pint_use_global *g:ale_php_pint_use_global* + *b:ale_php_pint_use_global* + Type: |Boolean| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +tlint *ale-php-tlint* + +g:ale_php_tlint_executable *g:ale_php_tlint_executable* + *b:ale_php_tlint_executable* + Type: |String| + Default: `'tlint'` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_use_global *g:ale_php_tlint_use_global* + *b:ale_php_tlint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_php_tlint_options *g:ale_php_tlint_options* + *b:ale_php_tlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to tlint + + +=============================================================================== +intelephense *ale-php-intelephense* + +g:ale_php_intelephense_executable *g:ale_php_intelephense_executable* + *b:ale_php_intelephense_executable* + Type: |String| + Default: `'intelephense'` + + The variable can be set to configure the executable that will be used for + running the intelephense language server. `node_modules` directory + executable will be preferred instead of this setting if + |g:ale_php_intelephense_use_global| is `0`. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_use_global *g:ale_php_intelephense_use_global* + *b:ale_php_intelephense_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to force the language server to be run with + the executable set for |g:ale_php_intelephense_executable|. + + See: |ale-integrations-local-executables| + + +g:ale_php_intelephense_config *g:ale_php_intelephense_config* + *b:ale_php_intelephense_config* + Type: |Dictionary| + Default: `{}` + + The initialization options config specified by Intelephense. Refer to the + installation docs provided by intelephense (github.com/bmewburn/intelephense + -docs). + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-po.txt b/sources_non_forked/ale/doc/ale-po.txt new file mode 100644 index 00000000..1e03b7bb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-po.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE PO Integration *ale-po-options* + + +=============================================================================== +write-good *ale-po-write-good* + +See |ale-write-good-options| + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pod.txt b/sources_non_forked/ale/doc/ale-pod.txt new file mode 100644 index 00000000..c7cc0bbc --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pod.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Pod Integration *ale-pod-options* + + +=============================================================================== +write-good *ale-pod-write-good* + +See |ale-write-good-options| + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pony.txt b/sources_non_forked/ale/doc/ale-pony.txt new file mode 100644 index 00000000..3b32168e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pony.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE Pony Integration *ale-pony-options* + + +=============================================================================== +ponyc *ale-pony-ponyc* + +g:ale_pony_ponyc_executable *g:ale_pony_ponyc_executable* + *b:ale_pony_ponyc_executable* + Type: |String| + Default: `'ponyc'` + + See |ale-integrations-local-executables| + + +g:ale_pony_ponyc_options *g:ale_pony_ponyc_options* + *b:ale_pony_ponyc_options* + Type: |String| + Default: `'--pass paint'` + + This variable can be set to pass options to ponyc. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-powershell.txt b/sources_non_forked/ale/doc/ale-powershell.txt new file mode 100644 index 00000000..44a3c618 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-powershell.txt @@ -0,0 +1,75 @@ +=============================================================================== +ALE PowerShell Integration *ale-powershell-options* + + +=============================================================================== +cspell *ale-powershell-cspell* + +See |ale-cspell-options| + + +=============================================================================== +powershell *ale-powershell-powershell* + +g:ale_powershell_powershell_executable *g:ale_powershell_powershell_executable* + *b:ale_powershell_powershell_executable* + Type: |String| + Default: `'pwsh'` + + This variable can be changed to use a different executable for powershell. + +> + " Use powershell.exe rather than the default pwsh + let g:ale_powershell_powershell_executable = 'powershell.exe' +> + +=============================================================================== +psscriptanalyzer *ale-powershell-psscriptanalyzer* + +Installation +------------------------------------------------------------------------------- + +Install PSScriptAnalyzer by any means, so long as it can be automatically +imported in PowerShell. + +g:ale_powershell_psscriptanalyzer_executable +*g:ale_powershell_psscriptanalyzer_executable* + *b:ale_powershell_psscriptanalyzer_executable* + Type: |String| + Default: `'pwsh'` + + This variable sets executable used for powershell. + + For example, on Windows you could set powershell to be Windows Powershell: +> + let g:ale_powershell_psscriptanalyzer_executable = 'powershell.exe' +< + +g:ale_powershell_psscriptanalyzer_module +*g:ale_powershell_psscriptanalyzer_module* + *b:ale_powershell_psscriptanalyzer_module* + Type: |String + Default: `'psscriptanalyzer'` + + This variable sets the name of the psscriptanalyzer module. + for psscriptanalyzer invocation. + + +g:ale_powershell_psscriptanalyzer_exclusions +*g:ale_powershell_psscriptanalyzer_exclusions* + *b:ale_powershell_psscriptanalyzer_exclusions* + Type: |String| + Default: `''` + + Set this variable to exclude test(s) for psscriptanalyzer + (-ExcludeRule option). To exclude more than one option, separate them with + commas. + +> + " Suppress Write-Host and Global vars warnings + let g:ale_powershell_psscriptanalyzer_exclusions = + \ 'PSAvoidUsingWriteHost,PSAvoidGlobalVars' +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-prolog.txt b/sources_non_forked/ale/doc/ale-prolog.txt new file mode 100644 index 00000000..14062a5a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-prolog.txt @@ -0,0 +1,56 @@ +=============================================================================== +ALE Prolog Integration *ale-prolog-options* + + +=============================================================================== +swipl *ale-prolog-swipl* + +g:ale_prolog_swipl_executable *g:ale_prolog_swipl_executable* + *b:ale_prolog_swipl_executable* + Type: |String| + Default: `'swipl'` + + The executable that will be run for the `swipl` linter. + +g:ale_prolog_swipl_load *g:ale_prolog_swipl_load* + *b:ale_prolog_swipl_load* + Type: |String| + Default: `'current_prolog_flag(argv, [File]), load_files(File, [sandboxed(true)]), halt.'` + + The prolog goals that will be passed to |g:ale_prolog_swipl_executable| with `-g` option. + + It does: + 1. Takes the first command argument (current file path) + 2. Checks (syntactic / semantic) problems and output to stderr + + NOTE: `sandboxed(true)` prohibits executing some directives such as 'initialization main'. + +g:ale_prolog_swipl_timeout *g:ale_prolog_swipl_timeout* + *b:ale_prolog_swipl_timeout* + Type: |Number| + Default: `3` + + Timeout seconds to detect long-running linter. + It is done by setting SIGALRM. + See |g:ale_prolog_swipl_alarm| and |g:ale_prolog_swipl_alarm_handler|. + +g:ale_prolog_swipl_alarm *g:ale_prolog_swipl_alarm* + *b:ale_prolog_swipl_alarm* + Type: |String| + Default: `'alarm(%t, (%h), _, [])'` + + The prolog goals to be expected to set SIGALRM. + `%t` is replaced by |g:ale_prolog_swipl_timeout|. + `%h` is replaced by |g:ale_prolog_swipl_alarm_handler|. + +g:ale_prolog_swipl_alarm_handler *g:ale_prolog_swipl_alarm_handler* + *b:ale_prolog_swipl_alarm_handler* + Type: |String| + Default: `'writeln(user_error, "ERROR: Exceeded %t seconds, Please change g:prolog_swipl_timeout to modify the limit."), halt(1)'` + + The prolog goals to be expected that will be run on SIGALRM. + `%t` is replaced by |g:ale_prolog_swipl_timeout|. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-proto.txt b/sources_non_forked/ale/doc/ale-proto.txt new file mode 100644 index 00000000..198ae3b6 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-proto.txt @@ -0,0 +1,98 @@ +=============================================================================== +ALE Proto Integration *ale-proto-options* + + +=============================================================================== +Integration Information + +To enable `.proto` file linting, update |g:ale_linters| as appropriate: +> + " Enable linter for .proto files + let g:ale_linters = {'proto': ['buf-lint', 'protoc-gen-lint', 'protolint']} + +To enable `.proto` file fixing, update |g:ale_fixers| as appropriate: +> + " Enable linter for .proto files + let b:ale_fixers = {'proto': ['buf-format', 'protolint']} +< +=============================================================================== +buf-format *ale-proto-buf-format* + + The formatter uses `buf`, a fully-featured Protobuf compiler that doesn't depend + on `protoc`. Make sure the `buf` binary is available in the system path, or + set ale_proto_buf_format_executable. + +g:ale_proto_buf_format_executable *g:ale_proto_buf_format_executable* + + Type: |String| + Default: `'buf'` + + This variable can be changed to modify the executable used for buf. + +=============================================================================== +buf-lint *ale-proto-buf-lint* + + The linter uses `buf`, a fully-featured Protobuf compiler that doesn't depend + on `protoc`. Make sure the `buf` binary is available in the system path, or + set ale_proto_buf_lint_executable. + +g:ale_proto_buf_lint_executable *g:ale_proto_buf_lint_executable* + + Type: |String| + Default: `'buf'` + + This variable can be changed to modify the executable used for buf. + +g:ale_proto_buf_lint_config *g:ale_proto_buf_lint_config* + + Type: |String| + Default: `''` + + A path to a buf configuration file. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + +=============================================================================== +protoc-gen-lint *ale-proto-protoc-gen-lint* + + The linter is a plugin for the `protoc` binary. As long as the binary resides + in the system path, `protoc` will find it. + +g:ale_proto_protoc_gen_lint_options *g:ale_proto_protoc_gen_lint_options* + + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to protoc. Note that the + directory of the linted file is always passed as an include path with '-I' + before any user-supplied options. + +=============================================================================== +protolint *ale-proto-protolint* + + The linter is a pluggable tool that doesn't depend on the `protoc` binary. + This supports both linting and fixing. + Make sure the binary is available in the system path, or set + ale_proto_protolint_executable. + Note that the binary with v0.22.0 or above is supported. + +g:ale_proto_protolint_executable *g:ale_proto_protolint_executable* + + Type: |String| + Default: `'protolint'` + + This variable can be changed to modify the executable used for protolint. + +g:ale_proto_protolint_config *g:ale_proto_protolint_config* + + Type: |String| + Default: `''` + + A path to a protolint configuration file. + + The path to the configuration file can be an absolute path or a relative + path. ALE will search for the relative path in parent directories. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pug.txt b/sources_non_forked/ale/doc/ale-pug.txt new file mode 100644 index 00000000..e2836f85 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pug.txt @@ -0,0 +1,44 @@ +=============================================================================== +ALE Pug Integration *ale-pug-options* + + +=============================================================================== +puglint *ale-pug-puglint* + +The puglint linter will detect configuration files based on the path to the +filename automatically. Configuration files will be loaded in this order: + +1. `.pug-lintrc` +2. `.pug-lintrc.js` +3. `.pug-lintrc.json` +4. `package.json` + +You might need to create a configuration file for your project to get +meaningful results. + +g:ale_pug_puglint_executable *g:ale_pug_puglint_executable* + *b:ale_pug_puglint_executable* + Type: |String| + Default: `'pug-lint'` + + See |ale-integrations-local-executables| + + +g:ale_pug_puglint_options *g:ale_pug_puglint_options* + *b:ale_pug_puglint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to pug-lint. + + +g:ale_pug_puglint_use_global *g:ale_pug_puglint_use_global* + *b:ale_pug_puglint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-puppet.txt b/sources_non_forked/ale/doc/ale-puppet.txt new file mode 100644 index 00000000..daa8c10f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-puppet.txt @@ -0,0 +1,57 @@ +=============================================================================== +ALE Puppet Integration *ale-puppet-options* + + +=============================================================================== +puppet *ale-puppet-puppet* + +g:ale_puppet_puppet_executable *g:ale_puppet_puppet_executable* + *b:ale_puppet_puppet_executable* + Type: |String| + Default: `'puppet'` + + This variable can be changed to specify the executable used for puppet. + + +g:ale_puppet_puppet_options *g:ale_puppet_puppet_options* + *b:ale_puppet_puppet_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + puppet parser validate invocation. + + +=============================================================================== +puppetlint *ale-puppet-puppetlint* + +g:ale_puppet_puppetlint_executable *g:ale_puppet_puppetlint_executable* + *b:ale_puppet_puppetlint_executable* + Type: |String| + Default: `'puppet-lint'` + + This variable can be changed to specify the executable used for puppet-lint. + + +g:ale_puppet_puppetlint_options *g:ale_puppet_puppetlint_options* + *b:ale_puppet_puppetlint_options* + Type: |String| + Default: `'--no-autoloader_layout-check'` + + This variable can be changed to add command-line arguments to the + puppet-lint invocation. + + +=============================================================================== +puppet-languageserver *ale-puppet-languageserver* + +g:ale_puppet_languageserver_executable *g:ale_puppet_languageserver_executable* + *b:ale_puppet_languageserver_executable* + type: |String| + Default: `'puppet-languageserver'` + + This variable can be used to specify the executable used for + puppet-languageserver. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-purescript.txt b/sources_non_forked/ale/doc/ale-purescript.txt new file mode 100644 index 00000000..25b3dd8d --- /dev/null +++ b/sources_non_forked/ale/doc/ale-purescript.txt @@ -0,0 +1,69 @@ +=============================================================================== +ALE PureScript Integration *ale-purescript-options* + + +=============================================================================== +purescript-language-server *ale-purescript-language-server* + +PureScript Language Server + (https://github.com/nwolverson/purescript-language-server) + +g:ale_purescript_ls_executable g:ale_purescript_ls_executable + b:ale_purescript_ls_executable + Type: |String| + Default: `'purescript-language-server'` + + PureScript language server executable. + +g:ale_purescript_ls_config g:ale_purescript_ls_config + b:ale_purescript_ls_config + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example, with a spago project: + { + \ 'purescript': { + \ 'addSpagoSources': v:true, + \ 'addNpmPath': v:true, + \ 'buildCommand': 'spago --quiet build --purs-args --json-errors' + \ } + \} +=============================================================================== +purs-tidy *ale-purescript-tidy* + +g:ale_purescript_tidy_executable *g:ale_purescript_tidy_executable* + *b:ale_purescript_tidy_executable* + Type: |String| + Default: `'purs-tidy'` + + This variable can be changed to use a different executable for purs-tidy. + +g:ale_purescript_tidy_use_global *g:ale_purescript_tidy_use_global* + *b:ale_purescript_tidy_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + +g:ale_purescript_tidy_options *g:ale_purescript_tidy_options* + *b:ale_purescript_tidy_options* + Type: |String| + Default: `''` + + This variable can be set to pass in additional option to the 'purs-tidy' + executable. +> + let g:ale_purescript_options = '--indent 3' +< +=============================================================================== +purty *ale-purescript-purty* + +g:ale_purescript_purty_executable *g:ale_purescript_purty_executable* + *b:ale_purescript_purty_executable* + Type: |String| + Default: `'purty'` + + This variable can be changed to use a different executable for purty. +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-pyrex.txt b/sources_non_forked/ale/doc/ale-pyrex.txt new file mode 100644 index 00000000..245e611f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-pyrex.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE Pyrex (Cython) Integration *ale-pyrex-options* + + +=============================================================================== +cython *ale-pyrex-cython* + +g:ale_pyrex_cython_executable *g:ale_pyrex_cython_executable* + *b:ale_pyrex_cython_executable* + Type: |String| + Default: `'cython'` + + This variable can be changed to use a different executable for cython. + + +g:ale_pyrex_cython_options *g:ale_pyrex_cython_options* + *b:ale_pyrex_cython_options* + Type: |String| + Default: `'--warning-extra --warning-errors'` + + This variable can be changed to modify flags given to cython. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-python.txt b/sources_non_forked/ale/doc/ale-python.txt new file mode 100644 index 00000000..6badcff3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-python.txt @@ -0,0 +1,1292 @@ +=============================================================================== +ALE Python Integration *ale-python-options* + + +g:ale_python_auto_pipenv *g:ale_python_auto_pipenv* + *b:ale_python_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_auto_poetry *g:ale_python_auto_poetry* + *b:ale_python_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +ALE Python Project Root Behavior *ale-python-root* + +For some linters, ALE will search for a Python project root by looking at the +files in directories on or above where a file being checked is. ALE applies +the following methods, in order: + +1. Find the first directory containing a common Python configuration file. +2. If no configuration file can be found, use the first directory which does + not contain a readable file named `__init__.py`. + +ALE will look for configuration files with the following filenames. > + + MANIFEST.in + setup.cfg + pytest.ini + tox.ini + .pyre_configuration.local + mypy.ini + .mypy.ini + pycodestyle.cfg + .flake8 + .flake8rc + pylama.ini + pylintrc + .pylintrc + pyrightconfig.json + pyrightconfig.toml + Pipfile + Pipfile.lock + poetry.lock + pyproject.toml + .tool-versions +< + +The first directory containing any of the files named above will be used. + + +=============================================================================== +autoflake *ale-python-autoflake* + +g:ale_python_autoflake_executable *g:ale_python_autoflake_executable* + *b:ale_python_autoflake_executable* + Type: |String| + Default: `'autoflake'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoflake_options *g:ale_python_autoflake_options* + *b:ale_python_autoflake_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoflake. + + +g:ale_python_autoflake_use_global *g:ale_python_autoflake_use_global* + *b:ale_python_autoflake_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +autoimport *ale-python-autoimport* + +g:ale_python_autoimport_executable *g:ale_python_autoimport_executable* + *b:ale_python_autoimport_executable* + Type: |String| + Default: `'autoimport'` + + See |ale-integrations-local-executables| + + +g:ale_python_autoimport_options *g:ale_python_autoimport_options* + *b:ale_python_autoimport_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autoimport. + + +g:ale_python_autoimport_use_global *g:ale_python_autoimport_use_global* + *b:ale_python_autoimport_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +autopep8 *ale-python-autopep8* + +g:ale_python_autopep8_executable *g:ale_python_autopep8_executable* + *b:ale_python_autopep8_executable* + Type: |String| + Default: `'autopep8'` + + See |ale-integrations-local-executables| + + +g:ale_python_autopep8_options *g:ale_python_autopep8_options* + *b:ale_python_autopep8_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to autopep8. + + +g:ale_python_autopep8_use_global *g:ale_python_autopep8_use_global* + *b:ale_python_autopep8_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +bandit *ale-python-bandit* + +g:ale_python_bandit_executable *g:ale_python_bandit_executable* + *b:ale_python_bandit_executable* + Type: |String| + Default: `'bandit'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `bandit'`. + Set this to `'poetry'` to invoke `'poetry` `run` `bandit'`. + + +g:ale_python_bandit_options *g:ale_python_bandit_options* + *b:ale_python_bandit_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + bandit invocation. + + +g:ale_python_bandit_use_config *g:ale_python_bandit_use_config* + *b:ale_python_bandit_use_config* + Type: |Number| + Default: `1` + + If this variable is true and a `.bandit` file exists in the directory of the + file being checked or a parent directory, an `--ini` option is added to the + `bandit` command for the nearest `.bandit` file. Set this variable false to + disable adding the `--ini` option automatically. + + +g:ale_python_bandit_use_global *g:ale_python_bandit_use_global* + *b:ale_python_bandit_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_bandit_auto_pipenv *g:ale_python_bandit_auto_pipenv* + *b:ale_python_bandit_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_bandit_auto_poetry *g:ale_python_bandit_auto_poetry* + *b:ale_python_bandit_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +black *ale-python-black* + +g:ale_python_black_executable *g:ale_python_black_executable* + *b:ale_python_black_executable* + Type: |String| + Default: `'black'` + + See |ale-integrations-local-executables| + + +g:ale_python_black_options *g:ale_python_black_options* + *b:ale_python_black_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to black. + + +g:ale_python_black_use_global *g:ale_python_black_use_global* + *b:ale_python_black_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv* + *b:ale_python_black_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_black_auto_poetry *g:ale_python_black_auto_poetry* + *b:ale_python_black_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_black_change_directory *g:ale_python_black_change_directory* + *b:ale_python_black_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, ALE will switch to the directory the Python file being + checked with `black` is in before checking it. This helps `black` find + configuration files more easily. This option can be turned off if you want + to control the directory Python is executed from yourself. + + +=============================================================================== +cspell *ale-python-cspell* + +See |ale-cspell-options| + + +=============================================================================== +flake8 *ale-python-flake8* + +g:ale_python_flake8_change_directory *g:ale_python_flake8_change_directory* + *b:ale_python_flake8_change_directory* + Type: |String| + Default: `'project'` + + If set to `project`, ALE will switch to the project root before checking file. + If set to `file`, ALE will first switch to the directory containing the + Python file being checked with `flake8` before checking it. + You can turn it off with `off` option if you want to control the directory + Python is executed from yourself. + + +g:ale_python_flake8_executable *g:ale_python_flake8_executable* + *b:ale_python_flake8_executable* + Type: |String| + Default: `'flake8'` + + This variable can be changed to modify the executable used for flake8. Set + this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. Set this to + `'poetry'` to invoke `'poetry` `run` `flake8'`. + + +g:ale_python_flake8_options *g:ale_python_flake8_options* + *b:ale_python_flake8_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the flake8 + invocation. + + For example, to dynamically switch between programs targeting Python 2 and + Python 3, you may want to set > + + let g:ale_python_flake8_executable = 'python3' " or 'python' for Python 2 + let g:ale_python_flake8_options = '-m flake8' +< + after making sure it's installed for the appropriate Python versions (e.g. + `python3 -m pip install --user flake8`). + + +g:ale_python_flake8_use_global *g:ale_python_flake8_use_global* + *b:ale_python_flake8_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for flake8 in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_python_flake8_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + + +g:ale_python_flake8_auto_pipenv *g:ale_python_flake8_auto_pipenv* + *b:ale_python_flake8_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_flake8_auto_poetry *g:ale_python_flake8_auto_poetry* + *b:ale_python_flake8_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +flakehell *ale-python-flakehell* + +g:ale_python_flakehell_change_directory*g:ale_python_flakehell_change_directory* + *b:ale_python_flakehell_change_directory* + Type: |String| + Default: `project` + + If set to `project`, ALE will switch to the project root before checking file. + If set to `file`, ALE will switch to directory the Python file being + checked with `flakehell` is in before checking it. + You can turn it off with `off` option if you want to control the directory + Python is executed from yourself. + + +g:ale_python_flakehell_executable *g:ale_python_flakehell_executable* + *b:ale_python_flakehell_executable* + Type: |String| + Default: `'flakehell'` + + This variable can be changed to modify the executable used for flakehell. Set + this to `'pipenv'` to invoke `'pipenv` `run` `flakehell'`. Set this to + `'poetry'` to invoke `'poetry` `run` `flakehell'`. Set this to `'python'` to + invoke `'python` `-m` `flakehell'`. + + +g:ale_python_flakehell_options *g:ale_python_flakehell_options* + *b:ale_python_flakehell_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the flakehell + lint invocation. + + +g:ale_python_flakehell_use_global *g:ale_python_flakehell_use_global* + *b:ale_python_flakehell_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for flakehell in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_python_flakehell_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + + +g:ale_python_flakehell_auto_pipenv *g:ale_python_flakehell_auto_pipenv* + *b:ale_python_flakehell_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_flakehell_auto_poetry *g:ale_python_flakehell_auto_poetry* + *b:ale_python_flakehell_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +isort *ale-python-isort* + +g:ale_python_isort_executable *g:ale_python_isort_executable* + *b:ale_python_isort_executable* + Type: |String| + Default: `'isort'` + + See |ale-integrations-local-executables| + + +g:ale_python_isort_options *g:ale_python_isort_options* + *b:ale_python_isort_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to isort. + + +g:ale_python_isort_use_global *g:ale_python_isort_use_global* + *b:ale_python_isort_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_isort_auto_pipenv *g:ale_python_isort_auto_pipenv* + *b:ale_python_isort_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_isort_auto_poetry *g:ale_python_isort_auto_poetry* + *b:ale_python_isort_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +mypy *ale-python-mypy* + +The minimum supported version of mypy that ALE supports is v0.4.4. This is +the first version containing the `--shadow-file` option ALE needs to be able +to check for errors while you type. + +`mypy` will be run from a detected project root, per |ale-python-root|. + + +g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv* + *b:ale_python_mypy_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_mypy_auto_poetry *g:ale_python_mypy_auto_poetry* + *b:ale_python_mypy_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_mypy_executable *g:ale_python_mypy_executable* + *b:ale_python_mypy_executable* + Type: |String| + Default: `'mypy'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`. + Set this to `'poetry'` to invoke `'poetry` `run` `mypy'`. + + +g:ale_python_mypy_ignore_invalid_syntax + *g:ale_python_mypy_ignore_invalid_syntax* + *b:ale_python_mypy_ignore_invalid_syntax* + Type: |Number| + Default: `0` + + When set to `1`, syntax error messages for mypy will be ignored. This option + can be used when running other Python linters which check for syntax errors, + as mypy can take a while to finish executing. + + +g:ale_python_mypy_options *g:ale_python_mypy_options* + *b:ale_python_mypy_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the mypy + invocation. + + +g:ale_python_mypy_show_notes *g:ale_python_mypy_show_notes* + *b:ale_python_mypy_show_notes* + Type: |Number| + Default: `1` + + If enabled, notes on lines will be displayed as 'I' (info) messages. + + +g:ale_python_mypy_use_global *g:ale_python_mypy_use_global* + *b:ale_python_mypy_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +prospector *ale-python-prospector* + +g:ale_python_prospector_executable *g:ale_python_prospector_executable* + *b:ale_python_prospector_executable* + Type: |String| + Default: `'prospector'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `prospector'`. + Set this to `'poetry'` to invoke `'poetry` `run` `prospector'`. + + +g:ale_python_prospector_options *g:ale_python_prospector_options* + *b:ale_python_prospector_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the prospector + invocation. + + For example, to dynamically switch between programs targeting Python 2 and + Python 3, you may want to set > + + let g:ale_python_prospector_executable = 'python3' + " or 'python' for Python 2 + let g:ale_python_prospector_options = '--rcfile /path/to/.prospector.yaml' + " The virtualenv detection needs to be disabled. + let g:ale_python_prospector_use_global = 0 + + after making sure it's installed for the appropriate Python versions (e.g. + `python3 -m pip install --user prospector`). + + +g:ale_python_prospector_use_global *g:ale_python_prospector_use_global* + *b:ale_python_prospector_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_prospector_auto_pipenv *g:ale_python_prospector_auto_pipenv* + *b:ale_python_prospector_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_prospector_auto_poetry *g:ale_python_prospector_auto_poetry* + *b:ale_python_prospector_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pycodestyle *ale-python-pycodestyle* + +g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable* + *b:ale_python_pycodestyle_executable* + Type: |String| + Default: `'pycodestyle'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pycodestyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pycodestyle'`. + + +g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options* + *b:ale_python_pycodestyle_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + pycodestyle invocation. + + +g:ale_python_pycodestyle_use_global *g:ale_python_pycodestyle_use_global* + *b:ale_python_pycodestyle_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pycodestyle_auto_pipenv *g:ale_python_pycodestyle_auto_pipenv* + *b:ale_python_pycodestyle_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pycodestyle_auto_poetry *g:ale_python_pycodestyle_auto_poetry* + *b:ale_python_pycodestyle_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pydocstyle *ale-python-pydocstyle* + +g:ale_python_pydocstyle_executable *g:ale_python_pydocstyle_executable* + *b:ale_python_pydocstyle_executable* + Type: |String| + Default: `'pydocstyle'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pydocstyle'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pydocstyle'`. + + +g:ale_python_pydocstyle_options *g:ale_python_pydocstyle_options* + *b:ale_python_pydocstyle_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the + pydocstyle invocation. + + +g:ale_python_pydocstyle_use_global *g:ale_python_pydocstyle_use_global* + *b:ale_python_pydocstyle_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pydocstyle_auto_pipenv *g:ale_python_pydocstyle_auto_pipenv* + *b:ale_python_pydocstyle_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pydocstyle_auto_poetry *g:ale_python_pydocstyle_auto_poetry* + *b:ale_python_pydocstyle_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pyflakes *ale-python-pyflakes* + +g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable* + *b:ale_python_pyflakes_executable* + Type: |String| + Default: `'pyflakes'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyflakes'`. + + +g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv* + *b:ale_python_pyflakes_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry* + *b:ale_python_pyflakes_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pyflyby *ale-python-pyflyby* + +g:ale_python_pyflyby_executable *g:ale_python_pyflyby_executable* + *b:ale_python_pyflyby_executable* + Type: |String| + Default: `'tidy-imports'` + + See |ale-integrations-local-executables| + + +g:ale_python_pyflyby_options *g:ale_python_pyflyby_options* + *b:ale_python_pyflyby_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pyflyby + tidy-imports invocation. + + +g:ale_python_pyflyby_use_global *g:ale_python_pyflyby_use_global* + *b:ale_python_pyflyby_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pyflyby_auto_pipenv *g:ale_python_pyflyby_auto_pipenv* + *b:ale_python_pyflyby_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pyflyby_auto_poetry *g:ale_python_pyflyby_auto_poetry* + *b:ale_python_pyflyby_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pylama *ale-python-pylama* + +g:ale_python_pylama_change_directory *g:ale_python_pylama_change_directory* + *b:ale_python_pylama_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `pylama` will be run from a detected project root, per + |ale-python-root|. This is useful because `pylama` only searches for + configuration files in its current directory and applies file masks using + paths relative to its current directory. This option can be turned off if + you want to control the directory in which `pylama` is executed. + + +g:ale_python_pylama_executable *g:ale_python_pylama_executable* + *b:ale_python_pylama_executable* + Type: |String| + Default: `'pylama'` + + This variable can be changed to modify the executable used for pylama. Set + this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. Set this to + `'poetry'` to invoke `'poetry` `run` `pylama'`. + + +g:ale_python_pylama_options *g:ale_python_pylama_options* + *b:ale_python_pylama_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylama + invocation. + + +g:ale_python_pylama_use_global *g:ale_python_pylama_use_global* + *b:ale_python_pylama_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for pylama in a + virtualenv directory first. If this variable is set to `1`, then ALE will + always use |g:ale_python_pylama_executable| for the executable path. + + Both variables can be set with `b:` buffer variables instead. + + +g:ale_python_pylama_auto_pipenv *g:ale_python_pylama_auto_pipenv* + *b:ale_python_pylama_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylama_auto_poetry *g:ale_python_pylama_auto_poetry* + *b:ale_python_pylama_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pylint *ale-python-pylint* + +g:ale_python_pylint_change_directory *g:ale_python_pylint_change_directory* + *b:ale_python_pylint_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `pylint` will be run from a detected project root, per + |ale-python-root|. Since `pylint` only checks for `pylintrc` in the packages + above its current directory before falling back to user and global `pylintrc` + files, this is necessary for `pylint` to use a project `pylintrc` file, if + present. This option can be turned off if you want to control the directory + Python is executed from yourself. + + +g:ale_python_pylint_executable *g:ale_python_pylint_executable* + *b:ale_python_pylint_executable* + Type: |String| + Default: `'pylint'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pylint'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pylint'`. + + +g:ale_python_pylint_options *g:ale_python_pylint_options* + *b:ale_python_pylint_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylint + invocation. + + For example, to dynamically switch between programs targeting Python 2 and + Python 3, you may want to set > + + let g:ale_python_pylint_executable = 'python3' " or 'python' for Python 2 + let g:ale_python_pylint_options = '--rcfile /path/to/pylint.rc' + " The virtualenv detection needs to be disabled. + let g:ale_python_pylint_use_global = 0 + + after making sure it's installed for the appropriate Python versions (e.g. + `python3 -m pip install --user pylint`). + + +g:ale_python_pylint_use_global *g:ale_python_pylint_use_global* + *b:ale_python_pylint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv* + *b:ale_python_pylint_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylint_auto_poetry *g:ale_python_pylint_auto_poetry* + *b:ale_python_pylint_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id* + *b:ale_python_pylint_use_msg_id* + Type: |Number| + Default: `0` + + Use message for output (e.g. I0011) instead of symbolic name of the message + (e.g. locally-disabled). + + +=============================================================================== +pylsp *ale-python-pylsp* + +`pylsp` will be run from a detected project root, per |ale-python-root|. + + +g:ale_python_pylsp_executable *g:ale_python_pylsp_executable* + *b:ale_python_pylsp_executable* + Type: |String| + Default: `'pylsp'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pylsp'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyls'`. + + +g:ale_python_pylsp_use_global *g:ale_python_pylsp_use_global* + *b:ale_python_pylsp_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pylsp_auto_pipenv *g:ale_python_pylsp_auto_pipenv* + *b:ale_python_pylsp_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylsp_auto_poetry *g:ale_python_pylsp_auto_poetry* + *b:ale_python_pylsp_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pylsp_config *g:ale_python_pylsp_config* + *b:ale_python_pylsp_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for pylsp. For example, to disable + the pycodestyle linter: > + { + \ 'pylsp': { + \ 'plugins': { + \ 'pycodestyle': { + \ 'enabled': v:false + \ } + \ } + \ }, + \ } +< + +g:ale_python_pylsp_options *g:ale_python_pylsp_options* + *b:ale_python_pylsp_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the pylsp + invocation. Note that this is not the same thing as ale_python_pylsp_config, + which allows configuration of how pylsp functions; this is intended to + provide flexibility in how the pylsp command is invoked. + + For example, if you had installed `pylsp` but your `pylsp` executable was not + on your `PATH` for some reason, an alternative way to run the pylsp server + would be: + let g:ale_python_pylsp_executable = 'python3' + let g:ale_python_pylsp_options = '-m pylsp' + + An example strategy for installing `pylsp`: + `python3 -m pip install --user pylsp` + + +=============================================================================== +pyre *ale-python-pyre* + +`pyre` will be run from a detected project root, per |ale-python-root|. + + +g:ale_python_pyre_executable *g:ale_python_pyre_executable* + *b:ale_python_pyre_executable* + Type: |String| + Default: `'pyre'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `pyre'`. + Set this to `'poetry'` to invoke `'poetry` `run` `pyre'`. + + +g:ale_python_pyre_use_global *g:ale_python_pyre_use_global* + *b:ale_python_pyre_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv* + *b:ale_python_pyre_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_pyre_auto_poetry *g:ale_python_pyre_auto_poetry* + *b:ale_python_pyre_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +pyright *ale-python-pyright* + +The `pyright` linter requires a recent version of `pyright` which includes +the `pyright-langserver` executable. You can install `pyright` on your system +through `npm` with `sudo npm install -g pyright` or similar. + +Refer to their README for installation instructions: +https://github.com/Microsoft/pyright + +`pyright` needs to know the path to your Python executable and probably a +virtualenv to run. ALE will try to detect these automatically. +See |g:ale_python_pyright_config|. + + +g:ale_python_pyright_executable *g:ale_python_pyright_executable* + *b:ale_python_pyright_executable* + Type: |String| + Default: `'pyright-langserver'` + + The executable for running `pyright`, which is typically installed globally. + + +g:ale_python_pyright_config *g:ale_python_pyright_config* + *b:ale_python_pyright_config* + Type: |Dictionary| + Default: `{}` + + Settings for configuring the `pyright` language server. + + See pyright's documentation for a full list of options: + https://github.com/microsoft/pyright/blob/master/docs/settings.md + + ALE will automatically try to set defaults for `venvPath` and `pythonPath` + so your project can automatically be checked with the right libraries. + You can override these settings with whatever you want in your ftplugin + file like so: > + + let b:ale_python_pyright_config = { + \ 'python': { + \ 'pythonPath': '/bin/python', + \ 'venvPath': '/other/dir', + \ }, + \} +< + If `venvPath` is set, but `pythonPath` is not, + ALE will use `venvPath . '/bin/python'` or similar as `pythonPath`. + + A commonly used setting for `pyright` is disabling language services + apart from type checking and "hover" (|ale-hover|), you can set this + setting like so, or use whatever other settings you want: > + + let b:ale_python_pyright_config = { + \ 'pyright': { + \ 'disableLanguageServices': v:true, + \ }, + \} +< + +=============================================================================== +reorder-python-imports *ale-python-reorder_python_imports* + +g:ale_python_reorder_python_imports_executable + *g:ale_python_reorder_python_imports_executable* + *b:ale_python_reorder_python_imports_executable* + Type: |String| + Default: `'reorder-python-imports'` + + See |ale-integrations-local-executables| + + +g:ale_python_reorder_python_imports_options + *g:ale_python_reorder_python_imports_options* + *b:ale_python_reorder_python_imports_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to reorder-python-imports. + + +g:ale_python_reorder_python_imports_use_global + *g:ale_python_reorder_python_imports_use_global* + *b:ale_python_reorder_python_imports_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +ruff *ale-python-ruff* + +g:ale_python_ruff_change_directory *g:ale_python_ruff_change_directory* + *b:ale_python_ruff_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, `ruff` will be run from a detected project root, per + |ale-python-root|. if set to `0` or no project root detected, + `ruff` will be run from the buffer's directory. + + +g:ale_python_ruff_executable *g:ale_python_ruff_executable* + *b:ale_python_ruff_executable* + Type: |String| + Default: `'ruff'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `ruff'`. + Set this to `'poetry'` to invoke `'poetry` `run` `ruff'`. + + +g:ale_python_ruff_options *g:ale_python_ruff_options* + *b:ale_python_ruff_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the ruff + invocation. + + For example, to select/enable and/or disable some error codes, + you may want to set > + let g:ale_python_ruff_options = '--ignore F401' + + +g:ale_python_ruff_use_global *g:ale_python_ruff_use_global* + *b:ale_python_ruff_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:ale_python_ruff_auto_pipenv *g:ale_python_ruff_auto_pipenv* + *b:ale_python_ruff_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_ruff_auto_poetry *g:ale_python_ruff_auto_poetry* + *b:ale_python_ruff_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +=============================================================================== +unimport *ale-python-unimport* + +`unimport` will be run from a detected project root, per |ale-python-root|. + + +g:ale_python_unimport_auto_pipenv *g:ale_python_unimport_auto_pipenv* + *b:ale_python_unimport_auto_pipenv* + Type: |Number| + Default: `0` + + Detect whether the file is inside a pipenv, and set the executable to `pipenv` + if true. This is overridden by a manually-set executable. + + +g:ale_python_unimport_auto_poetry *g:ale_python_unimport_auto_poetry* + *b:ale_python_unimport_auto_poetry* + Type: |Number| + Default: `0` + + Detect whether the file is inside a poetry, and set the executable to `poetry` + if true. This is overridden by a manually-set executable. + + +g:ale_python_unimport_executable *g:ale_python_unimport_executable* + *b:ale_python_unimport_executable* + Type: |String| + Default: `'unimport'` + + See |ale-integrations-local-executables| + + Set this to `'pipenv'` to invoke `'pipenv` `run` `unimport'`. + Set this to `'poetry'` to invoke `'poetry` `run` `unimport'`. + + +g:ale_python_unimport_options *g:ale_python_unimport_options* + *b:ale_python_unimport_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the unimport + invocation. + + +g:ale_python_unimport_use_global *g:ale_python_unimport_use_global* + *b:ale_python_unimport_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +vulture *ale-python-vulture* + +g:ale_python_vulture_change_directory *g:ale_python_vulture_change_directory* + *b:ale_python_vulture_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, ALE will switch to the directory the Python file being + checked with `vulture` is in before checking it and check the whole project + directory instead of checking only the file opened in the current buffer. + This helps `vulture` to know the context and avoid false-negative results. + + +g:ale_python_vulture_executable *g:ale_python_vulture_executable* + *b:ale_python_vulture_executable* + Type: |String| + Default: `'vulture'` + + See |ale-integrations-local-executables| + + +g:ale_python_vulture_options *g:ale_python_vulture_options* + *b:ale_python_vulture_options* + Type: |String| + Default: `''` + + This variable can be changed to add command-line arguments to the vulture + invocation. + + +g:ale_python_vulture_use_global *g:ale_python_vulture_use_global* + *b:ale_python_vulture_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yapf *ale-python-yapf* + +g:ale_python_yapf_executable *g:ale_python_yapf_executable* + *b:ale_python_yapf_executable* + Type: |String| + Default: `'yapf'` + + See |ale-integrations-local-executables| + + +g:ale_python_yapf_use_global *g:ale_python_yapf_use_global* + *b:ale_python_yapf_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-qml.txt b/sources_non_forked/ale/doc/ale-qml.txt new file mode 100644 index 00000000..f6d715a1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-qml.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE QML Integration *ale-qml-options* + + +=============================================================================== +qmlfmt *ale-qml-qmlfmt* + +g:ale_qml_qmlfmt_executable *g:ale_qml_qmlfmt_executable* + *b:ale_qml_qmlfmt_executable* + Type: |String| + Default: `'qmlfmt'` + + This variable can be set to change the path to qmlfmt. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-r.txt b/sources_non_forked/ale/doc/ale-r.txt new file mode 100644 index 00000000..3fabf702 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-r.txt @@ -0,0 +1,68 @@ +=============================================================================== +ALE R Integration *ale-r-options* + + +=============================================================================== +languageserver *ale-r-languageserver* + +g:ale_r_languageserver_cmd *g:ale_r_languageserver_cmd* + *b:ale_r_languageserver_cmd* + Type: |String| + Default: `'languageserver::run()'` + + This option can be configured to change the execution command for + languageserver. + + See the languageserver documentation for more options. + + +g:ale_r_languageserver_config *g:ale_r_languageserver_config* + *b:ale_r_languageserver_config* + Type: |Dictionary| + Default: `{}` + + This option can be configured to change settings for languageserver. See the + languageserver documentation for more information. + + +=============================================================================== +lintr *ale-r-lintr* + +g:ale_r_lintr_options *g:ale_r_lintr_options* + *b:ale_r_lintr_options* + Type: |String| + Default: `'lintr::with_defaults()'` + + This option can be configured to change the options for lintr. + + The value of this option will be run with `eval` for the `lintr::lint` + options. Consult the lintr documentation for more information. + + +g:ale_r_lintr_lint_package *g:ale_r_lintr_lint_package* + *b:ale_r_lintr_lint_package* + Type: |Number| + Default: `0` + + When set to `1`, the file will be checked with `lintr::lint_package` instead + of `lintr::lint`. This prevents erroneous namespace warnings when linting + package files. + + +=============================================================================== +styler *ale-r-styler* + +g:ale_r_styler_options *g:ale_r_styler_options* + *b:ale_r_styler_options* + Type: |String| + Default: `'styler::tidyverse_style'` + + This option can be configured to change the options for styler. + + The value of this option will be used as the `style` argument for the + `styler::style_file` options. Consult the styler documentation + for more information. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-reasonml.txt b/sources_non_forked/ale/doc/ale-reasonml.txt new file mode 100644 index 00000000..b8729a55 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-reasonml.txt @@ -0,0 +1,76 @@ +=============================================================================== +ALE ReasonML Integration *ale-reasonml-options* + + +=============================================================================== +merlin *ale-reasonml-merlin* + +To use merlin linter for ReasonML source code you need to make sure Merlin for +Vim is correctly configured. See the corresponding Merlin wiki page for +detailed instructions: +https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch + +=============================================================================== +ols *ale-reasonml-ols* + +The `ocaml-language-server` is the engine that powers OCaml and ReasonML +editor support using the Language Server Protocol. See the installation +instructions: +https://github.com/freebroccolo/ocaml-language-server#installation + + +g:ale_reason_ols_executable *g:ale_reason_ols_executable* + *b:ale_reason_ols_executable* + Type: |String| + Default: `'ocaml-language-server'` + + This variable can be set to change the executable path for `ols`. + + +g:ale_reason_ols_use_global *g:ale_reason_ols_use_global* + *b:ale_reason_ols_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable can be set to `1` to always use the globally installed + executable. See also |ale-integrations-local-executables|. + + +=============================================================================== +reason-language-server *ale-reasonml-language-server* + +Note: You must set an executable - there is no 'default' install location. +Go to https://github.com/jaredly/reason-language-server and download the +latest release. You can place it anywhere, but ensure you set the executable +path. + + +g:ale_reason_ls_executable *g:ale_reason_ls_executable* + *b:ale_reason_ls_executable* + Type: |String| + + This variable defines the standard location of the language server + executable. This must be set. + + +=============================================================================== +refmt *ale-reasonml-refmt* + +g:ale_reasonml_refmt_executable *g:ale_reasonml_refmt_executable* + *b:ale_reasonml_refmt_executable* + Type: |String| + Default: `'refmt'` + + This variable can be set to pass the path of the refmt fixer. + + +g:ale_reasonml_refmt_options *g:ale_reasonml_refmt_options* + *b:ale_reasonml_refmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the refmt fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-rego.txt b/sources_non_forked/ale/doc/ale-rego.txt new file mode 100644 index 00000000..9a39dbf0 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-rego.txt @@ -0,0 +1,50 @@ +=============================================================================== +ALE Rego Integration *ale-rego-options* + + +=============================================================================== +cspell *ale-rego-cspell* + +See |ale-cspell-options| + + +=============================================================================== +opacheck *ale-rego-opa-check* + +g:ale_rego_opacheck_executable *g:rego_opacheck_executable* + *b:rego_opacheck_executable* + + Type: |String| + Default: `'opa'` + + This variable can be changed to use a different executable for opa. + + +g:rego_opacheck_options *g:rego_opacheck_options* + *b:rego_opacheck_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to opa check. + + +=============================================================================== +opafmt *ale-rego-opa-fmt-fixer* + +g:ale_opa_fmt_executable *g:ale_opa_fmt_executable* + *b:ale_opa_fmt_executable* + + Type: |String| + Default: `'opa'` + + This variable can be changed to use a different executable for opa. + + +g:ale_opa_fmt_options *g:ale_opa_fmt_options* + *b:ale_opa_fmt_options* + Type: |String| + Default: `''` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-restructuredtext.txt b/sources_non_forked/ale/doc/ale-restructuredtext.txt new file mode 100644 index 00000000..7af62133 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-restructuredtext.txt @@ -0,0 +1,33 @@ +=============================================================================== +ALE reStructuredText Integration *ale-restructuredtext-options* + + +=============================================================================== +cspell *ale-restructuredtext-cspell* + +See |ale-cspell-options| + + +=============================================================================== +textlint *ale-restructuredtext-textlint* + +To use textlint at reStructuredText, please install `textlint-plugin-rst`. +https://github.com/jimo1001/textlint-plugin-rst +> + $ npm install textlint-plugin-rst + +To install `textlint-plugin-rst`, `docutils-ast-writer` python package +must be installed. +See: https://github.com/jimo1001/docutils-ast-writer + +See |ale-text-textlint| + + +=============================================================================== +write-good *ale-restructuredtext-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-robot.txt b/sources_non_forked/ale/doc/ale-robot.txt new file mode 100644 index 00000000..405ae277 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-robot.txt @@ -0,0 +1,16 @@ +=============================================================================== +ALE Robot Integration *ale-robot-options* + + +=============================================================================== +rflint *ale-robot-rflint* + +g:ale_robot_rflint_executable *g:ale_robot_rflint_executable* + *b:ale_robot_rflint_executable* + Type: |String| + Default: `'rflint'` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-ruby.txt b/sources_non_forked/ale/doc/ale-ruby.txt new file mode 100644 index 00000000..b0773fdd --- /dev/null +++ b/sources_non_forked/ale/doc/ale-ruby.txt @@ -0,0 +1,243 @@ +=============================================================================== +ALE Ruby Integration *ale-ruby-options* + + +=============================================================================== +brakeman *ale-ruby-brakeman* + +g:ale_ruby_brakeman_executable *g:ale_ruby_brakeman_executable* + *b:ale_ruby_brakeman_executable* + Type: |String| + Default: `'brakeman'` + + Override the invoked brakeman binary. Set this to `'bundle'` to invoke + `'bundle` `exec` brakeman'. + + +g:ale_ruby_brakeman_options *g:ale_ruby_brakeman_options* + *b:ale_ruby_brakeman_options* + Type: |String| + Default: `''` + + The contents of this variable will be passed through to brakeman. + + +=============================================================================== +cspell *ale-ruby-cspell* + +See |ale-cspell-options| + + +=============================================================================== +debride *ale-ruby-debride* + +g:ale_ruby_debride_executable *g:ale_ruby_debride_executable* + *b:ale_ruby_debride_executable* + Type: |String| + Default: `'debride'` + + Override the invoked debride binary. Set this to `'bundle'` to invoke + `'bundle` `exec` debride'. + + +g:ale_ruby_debride_options *g:ale_ruby_debride_options* + *b:ale_ruby_debride_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to debride. + + +=============================================================================== +prettier *ale-ruby-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +rails_best_practices *ale-ruby-rails_best_practices* + +g:ale_ruby_rails_best_practices_executable + *g:ale_ruby_rails_best_practices_executable* + *b:ale_ruby_rails_best_practices_executable* + Type: |String| + Default: `'rails_best_practices'` + + Override the invoked rails_best_practices binary. Set this to `'bundle'` to + invoke `'bundle` `exec` rails_best_practices'. + + +g:ale_ruby_rails_best_practices_options + *g:ale_ruby_rails_best_practices_options* + *b:ale_ruby_rails_best_practices_options* + Type: |String| + Default: `''` + + The contents of this variable will be passed through to rails_best_practices. + + +=============================================================================== +reek *ale-ruby-reek* + +g:ale_ruby_reek_executable *g:ale_ruby_reek_executable* + *b:ale_ruby_reek_executable* + Type: |String| + Default: `'reek'` + + Override the invoked reek binary. Set this to `'bundle'` to invoke + `'bundle` `exec` reek'. + + +g:ale_ruby_reek_show_context *g:ale_ruby_reek_show_context* + *b:ale_ruby_reek_show_context* + Type: |Number| + Default: `0` + + Controls whether context is included in the linter message. Defaults to off + because context is usually obvious while viewing a file. + + +g:ale_ruby_reek_show_wiki_link *g:ale_ruby_reek_show_wiki_link* + *b:ale_ruby_reek_show_wiki_link* + Type: |Number| + Default: `0` + + Controls whether linter messages contain a link to an explanatory wiki page + for the type of code smell. Defaults to off to improve readability. + + +=============================================================================== +rubocop *ale-ruby-rubocop* + +g:ale_ruby_rubocop_executable *g:ale_ruby_rubocop_executable* + *b:ale_ruby_rubocop_executable* + Type: |String| + Default: `'rubocop'` + + Override the invoked rubocop binary. Set this to `'bundle'` to invoke + `'bundle` `exec` rubocop'. + + +g:ale_ruby_rubocop_options *g:ale_ruby_rubocop_options* + *b:ale_ruby_rubocop_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to rubocop. + + +g:ale_ruby_rubocop_auto_correct_all *g:ale_ruby_rubocop_auto_correct_all* + *b:ale_ruby_rubocop_auto_correct_all* + Type: |Number| + Default: `0` + + This variable can be changed to make rubocop to correct all offenses (unsafe). + + +=============================================================================== +ruby *ale-ruby-ruby* + +g:ale_ruby_ruby_executable *g:ale_ruby_ruby_executable* + *b:ale_ruby_ruby_executable* + Type: |String| + Default: `'ruby'` + + This variable can be changed to use a different executable for ruby. + + +=============================================================================== +rufo *ale-ruby-rufo* + +g:ale_ruby_rufo_executable *g:ale_ruby_rufo_executable* + *b:ale_ruby_rufo_executable* + Type: |String| + Default: `'rufo'` + + Override the invoked rufo binary. This is useful for running rufo from + binstubs or a bundle. + + +=============================================================================== +solargraph *ale-ruby-solargraph* + +g:ale_ruby_solargraph_executable *g:ale_ruby_solargraph_executable* + *b:ale_ruby_solargraph_executable* + Type: |String| + Default: `'solargraph'` + + Override the invoked solargraph binary. This is useful for running solargraph + from binstubs or a bundle. + + +=============================================================================== +sorbet *ale-ruby-sorbet* + +g:ale_ruby_sorbet_executable *g:ale_ruby_sorbet_executable* + *b:ale_ruby_sorbet_executable* + Type: |String| + Default: `'srb'` + + Override the invoked sorbet binary. Set this to `'bundle'` to invoke + `'bundle` `exec` srb'. + + +g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options* + *b:ale_ruby_sorbet_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to sorbet. + + +g:ale_ruby_sorbet_enable_watchman *g:ale_ruby_sorbet_enable_watchman* + *b:ale_ruby_sorbet_enable_watchman* + Type: |Number| + Default: `0` + + Whether or not to use watchman to let the LSP server to know about changes + to files from outside of vim. Defaults to disable watchman because it + requires watchman to be installed separately from sorbet. + + +=============================================================================== +standardrb *ale-ruby-standardrb* + +g:ale_ruby_standardrb_executable *g:ale_ruby_standardrb_executable* + *b:ale_ruby_standardrb_executable* + Type: |String| + Default: `'standardrb'` + + Override the invoked standardrb binary. Set this to `'bundle'` to invoke + `'bundle` `exec` standardrb'. + + +g:ale_ruby_standardrb_options *g:ale_ruby_standardrb_options* + *b:ale_ruby_standardrb_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to standardrb. + + +=============================================================================== +syntax_tree *ale-ruby-syntax_tree* + +g:ale_ruby_syntax_tree_executable *g:ale_ruby_syntax_tree_executable* + *b:ale_ruby_syntax_tree_executable* + Type: |String| + Default: `'stree'` + + Override the invoked SyntaxTree binary. Set this to `'bundle'` to invoke + `'bundle` `exec` stree'. + + +g:ale_ruby_syntax_tree_options *g:ale_ruby_syntax_tree_options* + *b:ale_ruby_syntax_tree_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to SyntaxTree. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-rust.txt b/sources_non_forked/ale/doc/ale-rust.txt new file mode 100644 index 00000000..ceef12e3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-rust.txt @@ -0,0 +1,292 @@ +=============================================================================== +ALE Rust Integration *ale-rust-options* + *ale-integration-rust* + +=============================================================================== +Integration Information + + If Vim does not detect the Rust file type out-of-the-box, you need the runtime + files for Rust distributed in Vim >=8.0.0501 or upstream: + https://github.com/rust-lang/rust.vim + + Note that there are several possible linters and fixers for Rust files: + + 1. rustc -- The Rust compiler is used to check the currently edited file. + So, if your project consists of multiple files, you will get some errors + when you use e.g. a struct which is defined in another file. You can use + |g:ale_rust_ignore_error_codes| to ignore some of these errors. + 2. cargo -- If your project is managed by Cargo, the whole project is + checked. That means that all errors are properly shown, but cargo can + only operate on the files written on disk, so errors will not be reported + while you type. + 3. rls -- If you have `rls` installed, you might prefer using this linter + over cargo. rls implements the Language Server Protocol for incremental + compilation of Rust code, and can check Rust files while you type. `rls` + requires Rust files to be contained in Cargo projects. + 4. analyzer -- If you have rust-analyzer installed, you might prefer using + this linter over cargo and rls. rust-analyzer also implements the + Language Server Protocol for incremental compilation of Rust code, and is + the next iteration of rls. rust-analyzer either requires Rust files to be + contained in Cargo projects or requires the project to be described in + the rust-project.json format: + https://rust-analyzer.github.io/manual.html#non-cargo-based-projects + 5. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to + consistently reformat your Rust code. + + Only cargo and rls are enabled by default. To switch to using rustc instead + of cargo, configure |g:ale_linters| appropriately: > + + " See the help text for the option for more information. + let g:ale_linters = {'rust': ['rustc', 'rls']} +< + + Also note that rustc 1.18. or later is needed. + + +=============================================================================== +analyzer *ale-rust-analyzer* + +g:ale_rust_analyzer_executable *g:ale_rust_analyzer_executable* + *b:ale_rust_analyzer_executable* + Type: |String| + Default: `'rust-analyzer'` + + This variable can be modified to change the executable path for + `rust-analyzer`. + + +g:ale_rust_analyzer_config *g:ale_rust_analyzer_config* + *b:ale_rust_analyzer_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for rust-analyzer. + + +=============================================================================== +cargo *ale-rust-cargo* + +g:ale_rust_cargo_use_check *g:ale_rust_cargo_use_check* + *b:ale_rust_cargo_use_check* + Type: |Number| + Default: `1` + + When set to `1`, this option will cause ALE to use `cargo check` instead of + `cargo build` . `cargo check` is supported since version 1.16.0 of Rust. + + ALE will never use `cargo check` when the version of `cargo` is less than + 0.17.0. + + +g:ale_rust_cargo_check_all_targets *g:ale_rust_cargo_check_all_targets* + *b:ale_rust_cargo_check_all_targets* + Type: |Number| + Default: `0` + + When set to `1`, ALE will set the `--all-targets` option when `cargo check` + is used. See |g:ale_rust_cargo_use_check|, + + +g:ale_rust_cargo_check_tests *g:ale_rust_cargo_check_tests* + *b:ale_rust_cargo_check_tests* + Type: |Number| + Default: `0` + + When set to `1`, ALE will set the `--tests` option when `cargo check` + is used. This allows for linting of tests which are normally excluded. + See |g:ale_rust_cargo_use_check|, + + +g:ale_rust_cargo_check_examples *g:ale_rust_cargo_check_examples* + *b:ale_rust_cargo_check_examples* + Type: |Number| + Default: `0` + + When set to `1`, ALE will set the `--examples` option when `cargo check` + is used. This allows for linting of examples which are normally excluded. + See |g:ale_rust_cargo_use_check|, + + +g:ale_rust_cargo_default_feature_behavior + *g:ale_rust_cargo_default_feature_behavior* + *b:ale_rust_cargo_default_feature_behavior* + Type: |String| + Default: `default` + + When set to `none`, ALE will set the `--no-default-features` option when + invoking `cargo`. Only the features specified in + |g:ale_rust_cargo_include_features| will be included when performing the + lint check. + + When set to `default`, ALE will instruct `cargo` to build all default + features specified in the project's `Cargo.toml` file, in addition to + including any additional features defined in + |g:ale_rust_cargo_include_features|. + + When set to `all`, ALE will set the `--all-features` option when + invoking `cargo`, which will include all features defined in the project's + `Cargo.toml` file when performing the lint check. + + +g:ale_rust_cargo_include_features *g:ale_rust_cargo_include_features* + *b:ale_rust_cargo_include_features* + Type: |String| + Default: `''` + + When defined, ALE will set the `--features` option when invoking `cargo` to + perform the lint check. See |g:ale_rust_cargo_default_feature_behavior|. + + +g:ale_rust_cargo_avoid_whole_workspace *g:ale_rust_cargo_avoid_whole_workspace* + *b:ale_rust_cargo_avoid_whole_workspace* + Type: |Number| + Default: `1` + + When set to 1, and ALE is used to edit a crate that is part of a Cargo + workspace, avoid building the entire workspace by invoking `cargo` directly + in the crate's directory. Otherwise, behave as usual. + + +g:ale_rust_cargo_use_clippy *g:ale_rust_cargo_use_clippy* + *b:ale_rust_cargo_use_clippy* + Type: |Number| + Default: `0` + + When set to 1, `cargo clippy` will be used instead of `cargo check` or + `cargo build` as linter. + For details of `cargo clippy`, please visit the following link: + + https://github.com/rust-lang-nursery/rust-clippy + + Since `cargo clippy` is optional toolchain, it's safer to check whether + `cargo-clippy` is executable as follows: +> + let g:ale_rust_cargo_use_clippy = executable('cargo-clippy') +< + +g:ale_rust_cargo_clippy_options *g:ale_rust_cargo_clippy_options* + *b:ale_rust_cargo_clippy_options* + + Type: |String| + Default: `''` + + When `cargo clippy` is used, this value will be added to a command line to run + it. This variable is useful when you want to add some extra options which + only `cargo clippy` supports (e.g. `--deny`). + + +g:ale_rust_cargo_target_dir *g:ale_rust_cargo_target_dir* + *b:ale_rust_cargo_target_dir* + + Type: |String| + Default: `''` + + Use a custom target directory when running the commands for ALE. This can + help to avoid "waiting for file lock on build directory" messages when + running `cargo` commands manually while ALE is performing its checks. + + +=============================================================================== +cspell *ale-rust-cspell* + +See |ale-cspell-options| + + +=============================================================================== +rls *ale-rust-rls* + +g:ale_rust_rls_executable *g:ale_rust_rls_executable* + *b:ale_rust_rls_executable* + Type: |String| + Default: `'rls'` + + This variable can be modified to change the executable path for `rls`. + + +g:ale_rust_rls_toolchain *g:ale_rust_rls_toolchain* + *b:ale_rust_rls_toolchain* + Type: |String| + Default: `''` + + This option can be set to change the toolchain used for `rls`. Possible + values include `'nightly'`, `'beta'`, `'stable'`, and `''`. When using + option `''`, rls will automatically find the default toolchain set by + rustup. If you want to use `rls` from a specific toolchain version, you may + also use values like `'channel-yyyy-mm-dd-arch-target'` as long as + `'rls +{toolchain_name} -V'` runs correctly in your command line. + + The `rls` server will only be started once per executable. + + +g:ale_rust_rls_config *g:ale_rust_rls_config* + *b:ale_rust_rls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary with configuration settings for rls. For example, to force + using clippy as linter: > + { + \ 'rust': { + \ 'clippy_preference': 'on' + \ } + \ } + + +=============================================================================== +rustc *ale-rust-rustc* + + +g:ale_rust_rustc_options *g:ale_rust_rustc_options* + *b:ale_rust_rustc_options* + Type: |String| + Default: `'--emit=mir -o /dev/null'` + + The variable can be used to change the options passed to `rustc`. + + Users of nightly builds of Rust might want to use `-Z no-codegen` instead. + Be careful when setting the options, as running `rustc` could execute code + or generate binary files. + + +g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes* + *b:ale_rust_ignore_error_codes* + Type: |List| of |String|s + Default: `[]` + + This variable can contain error codes which will be ignored. For example, to + ignore most errors regarding failed imports, put this in your .vimrc + > + let g:ale_rust_ignore_error_codes = ['E0432', 'E0433'] + + +g:ale_rust_ignore_secondary_spans *g:ale_rust_ignore_secondary_spans* + *b:ale_rust_ignore_secondary_spans* + Type: |Number| + Default: `0` + + When set to 1, instructs the Rust error reporting to ignore secondary spans. + The problem with secondary spans is that they sometimes appear in error + messages before the main cause of the error, for example: > + + 1 src/main.rs|98 col 5 error| this function takes 4 parameters but 5 + parameters were supplied: defined here + 2 src/main.rs|430 col 32 error| this function takes 4 parameters but 5 + parameters were supplied: expected 4 parameters +< + This is due to the sorting by line numbers. With this option set to 1, + the 'defined here' span will not be presented. + + +=============================================================================== +rustfmt *ale-rust-rustfmt* + +g:ale_rust_rustfmt_options *g:ale_rust_rustfmt_options* + *b:ale_rust_rustfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the rustfmt fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-salt.tmt b/sources_non_forked/ale/doc/ale-salt.tmt new file mode 100644 index 00000000..ac500d37 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-salt.tmt @@ -0,0 +1,43 @@ +=============================================================================== +ALE SALT Integration *ale-salt-options* + +=============================================================================== +salt-lint *ale-salt-salt-lint* + +Website: https://github.com/warpnet/salt-lint + + +Installation +------------------------------------------------------------------------------- + +Install salt-lint in your a virtualenv directory, locally, or globally: > + + pip install salt-lint # After activating virtualenv + pip install --user salt-lint # Install to ~/.local/bin + sudo pip install salt-lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + + +Options +------------------------------------------------------------------------------- + +g:ale_salt_salt-lint_executable *g:ale_salt_salt_lint_executable* + *b:ale_salt_salt_lint_executable* + Type: |String| + Default: `'salt-lint'` + + This variable can be set to change the path to salt-lint. + + +g:ale_salt_salt-lint_options *g:ale_salt_salt-lint_options* + *b:ale_salt_salt-lint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to salt-lint. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-sass.txt b/sources_non_forked/ale/doc/ale-sass.txt new file mode 100644 index 00000000..22d7c472 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-sass.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE Sass Integration *ale-sass-options* + + +=============================================================================== +sasslint *ale-sass-sasslint* + +See |ale-scss-sasslint| for information about the available options. + + +=============================================================================== +stylelint *ale-sass-stylelint* + +g:ale_sass_stylelint_executable *g:ale_sass_stylelint_executable* + *b:ale_sass_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_sass_stylelint_use_global *g:ale_sass_stylelint_use_global* + *b:ale_sass_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-scala.txt b/sources_non_forked/ale/doc/ale-scala.txt new file mode 100644 index 00000000..0b0f1a9a --- /dev/null +++ b/sources_non_forked/ale/doc/ale-scala.txt @@ -0,0 +1,130 @@ +=============================================================================== +ALE Scala Integration *ale-scala-options* + + +=============================================================================== +cspell *ale-scala-cspell* + +See |ale-cspell-options| + + +=============================================================================== +metals *ale-scala-metals* + +`metals` requires either an SBT project, a Mill project, or a running Bloop +server. + + +g:ale_scala_metals_executable *g:ale_scala_metals_executable* + *b:ale_scala_metals_executable* + Type: |String| + Default: `'metals-vim'` + + Override the invoked `metals` binary. + + +g:ale_scala_metals_project_root *g:ale_scala_metals_project_root* + *b:ale_scala_metals_project_root* + Type: |String| + Default: `''` + + By default the project root is found by searching upwards for `build.sbt`, + `build.sc`, `.bloop` or `.metals`. + If the project root is elsewhere, you can override the project root + directory. + + +=============================================================================== +sbtserver *ale-scala-sbtserver* + +`sbtserver` requires a running ^1.1.x sbt shell to connect to. It will attempt +to connect via TCP to the address defined in `g:ale_scala_sbtserver_address`. +As `sbt` defaults to listening via unix sockets, place these settings into +your `~/.sbt/1.0/global.sbt` to ensure that ale will always attempt to connect +to the right socket: + +`serverConnectionType := ConnectionType.Tcp` and `serverPort := 4273` + + +g:ale_scala_sbtserver_address *g:ale_scala_sbtserver_address* + *b:ale_scala_sbtserver_address* + Type: |String| + Default: `'127.0.0.1:4273'` + + By default the address is found by parsing `active.json`, however, reading a + file is a blocking operation which should be avoided in ale. The easy way + around this is to configure sbt to always connect to the same port, which + the instructions above describe. + + +g:ale_scala_sbtserver_project_root *g:ale_scala_sbtserver_project_root* + *b:ale_scala_sbtserver_project_root* + Type: |String| + Default: `''` + + By default the project root is found by searching upwards for `build.sbt`. + If the project root is elsewhere, you can override the project root + directory. + + +=============================================================================== +scalafmt *ale-scala-scalafmt* + +If Nailgun is used, override `g:ale_scala_scalafmt_executable` like so: > + let g:ale_scala_scalafmt_executable = 'ng' + + +g:ale_scala_scalafmt_executable *g:ale_scala_scalafmt_executable* + *b:ale_scala_scalafmt_executable* + Type: |String| + Default: `'scalafmt'` + + Override the invoked `scalafmt` binary. This is useful for running `scalafmt` + with Nailgun. + + +g:ale_scala_scalafmt_options *g:ale_scala_scalafmt_options* + *b:ale_scala_scalafmt_options* + Type: |String| + Default: `''` + + A string containing additional options to pass to `'scalafmt'`, or + `'ng scalafmt'` if Nailgun is used. + + +=============================================================================== +scalastyle *ale-scala-scalastyle* + +`scalastyle` requires a configuration file for a project to run. When no +configuration file can be found, ALE will report a problem saying that a +configuration file is required at line 1. + +To disable `scalastyle` globally, use |g:ale_linters| like so: > + let g:ale_linters = {'scala': ['scalac']} " Enable only scalac instead +< + +See |g:ale_linters| for more information on disabling linters. + + +g:ale_scala_scalastyle_config *g:ale_scala_scalastyle_config* + *b:ale_scala_scalastyle_config* + Type: |String| + Default: `''` + + A string containing the location of a global fallback configuration file. + + By default, ALE will look for a configuration file named + `scalastyle_config.xml` or `scalastyle-config.xml` in the current file's + directory or parent directories. + + +g:ale_scala_scalastyle_options *g:ale_scala_scalastyle_options* + *b:ale_scala_scalastyle_options* + Type: |String| + Default: `''` + + A string containing additional options to pass to scalastyle. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-scss.txt b/sources_non_forked/ale/doc/ale-scss.txt new file mode 100644 index 00000000..07a94fe1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-scss.txt @@ -0,0 +1,64 @@ +=============================================================================== +ALE SCSS Integration *ale-scss-options* + + +=============================================================================== +prettier *ale-scss-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +sasslint *ale-scss-sasslint* + +g:ale_scss_sasslint_executable *g:ale_scss_sasslint_executable* + *b:ale_scss_sasslint_executable* + Type: |String| + Default: `'sass-lint'` + + See |ale-integrations-local-executables| + + +g:ale_scss_sasslint_options *g:ale_scss_sasslint_options* + *b:ale_scss_sasslint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to sass-lint. + + +g:ale_scss_sasslint_use_global *g:ale_scss_sasslint_use_global* + *b:ale_scss_sasslint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +stylelint *ale-scss-stylelint* + +g:ale_scss_stylelint_executable *g:ale_scss_stylelint_executable* + *b:ale_scss_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + +g:ale_scss_stylelint_options *g:ale_scss_stylelint_options* + *b:ale_scss_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + +g:ale_scss_stylelint_use_global *g:ale_scss_stylelint_use_global* + *b:ale_scss_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-sh.txt b/sources_non_forked/ale/doc/ale-sh.txt new file mode 100644 index 00000000..9a1928c4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-sh.txt @@ -0,0 +1,144 @@ +=============================================================================== +ALE Shell Integration *ale-sh-options* + + +=============================================================================== +bashate *ale-sh-bashate* + +g:ale_sh_bashate_executable *g:ale_sh_bashate_executable* + *b:ale_sh_bashate_executable* + Type: |String| + Default: `'bashate'` + + This variable sets executable used for bashate. + + +g:ale_sh_bashate_options *g:ale_sh_bashate_options* + *b:ale_sh_bashate_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for bashate. For + example to ignore the indentation rule: + +> + let g:ale_sh_bashate_options = '-i E003' +< + +=============================================================================== +cspell *ale-sh-cspell* + +See |ale-cspell-options| + + +=============================================================================== +sh-language-server *ale-sh-language-server* + +g:ale_sh_language_server_executable *g:ale_sh_language_server_executable* + *b:ale_sh_language_server_executable* + Type: |String| + Default: `'bash-language-server'` + + See |ale-integrations-local-executables| + + +g:ale_sh_language_server_use_global *g:ale_sh_language_server_use_global* + *b:ale_sh_language_server_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +shell *ale-sh-shell* + +g:ale_sh_shell_default_shell *g:ale_sh_shell_default_shell* + *b:ale_sh_shell_default_shell* + Type: |String| + Default: The current shell (`$SHELL`). Falls back to `'bash'` if that cannot be + read or if the current shell is `'fish'`. + + When ALE runs the linter for shells with the `-n` flag, it will attempt to + read the shell from the shebang (`#!`) line from the shell script to + determine the shell program to run. When this detection fails, this variable + will be used instead. + + +=============================================================================== +shellcheck *ale-sh-shellcheck* + +g:ale_sh_shellcheck_executable *g:ale_sh_shellcheck_executable* + *b:ale_sh_shellcheck_executable* + Type: |String| + Default: `'shellcheck'` + + This variable sets executable used for shellcheck. + + +g:ale_sh_shellcheck_options *g:ale_sh_shellcheck_options* + *b:ale_sh_shellcheck_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for shellcheck + for shellcheck invocation. + + For example, if we want shellcheck to follow external sources (`see SC1091`) + we can set the variable as such: +> + let g:ale_sh_shellcheck_options = '-x' +< + + +g:ale_sh_shellcheck_change_directory *g:ale_sh_shellcheck_change_directory* + *b:ale_sh_shellcheck_change_directory* + Type: |Number| + Default: `1` + + If set to `1`, ALE will switch to the directory the shell file being + checked with `shellcheck` is in before checking it. This helps `shellcheck` + determine the path to sourced files more easily. This option can be turned + off if you want to control the directory `shellcheck` is executed from + yourself. + + +g:ale_sh_shellcheck_dialect *g:ale_sh_shellcheck_dialect* + *b:ale_sh_shellcheck_dialect* + Type: |String| + Default: `'auto'` + + This variable specifies the shellcheck dialect (`-s` option). The value + `'auto'` causes ALE to detect the dialect automatically, based on the shebang + line (if present) or the value of `b:is_bash`, `b:is_sh`, or `b:is_kornshell` + (set and used by |sh.vim|). + + +g:ale_sh_shellcheck_exclusions *g:ale_sh_shellcheck_exclusions* + *b:ale_sh_shellcheck_exclusions* + Type: |String| + Default: `''` + + Set this variable to exclude test(s) for shellcheck (-e/--exclude option). + To exclude more than one option, separate them with commas. + + For example, to ignore some warnings that aren't applicable to files that + will be sourced by other scripts, use the buffer-local variant: +> + autocmd BufEnter PKGBUILD,.env + \ let b:ale_sh_shellcheck_exclusions = 'SC2034,SC2154,SC2164' +< + +=============================================================================== +shfmt *ale-sh-shfmt* + +g:ale_sh_shfmt_options *g:ale_sh_shfmt_options* + *b:ale_sh_shfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the shfmt fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-sml.txt b/sources_non_forked/ale/doc/ale-sml.txt new file mode 100644 index 00000000..cc8d6794 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-sml.txt @@ -0,0 +1,36 @@ +=============================================================================== +ALE SML Integration *ale-sml-options* + +=============================================================================== +smlnj *ale-sml-smlnj* + *ale-sml-smlnj-cm* + +There are two SML/NJ powered checkers: + +- one using Compilation Manager that works on whole projects, but requires you + to save before errors show up +- one using the SML/NJ REPL that works as you change the text, but might fail + if your project can only be built with CM. + +We dynamically select which one to use based whether we find a `*.cm` file at +or above the directory of the file being checked. Only one checker (`smlnj`, +`smlnj-cm`) will be enabled at a time. + +------------------------------------------------------------------------------- + +g:ale_sml_smlnj_cm_file *g:ale_sml_smlnj_cm_file* + *b:ale_sml_smlnj_cm_file* + Type: |String| + Default: `'*.cm'` + + By default, ALE will look for a `*.cm` file in your current directory, + searching upwards. It stops when it finds at least one `*.cm` file (taking + the first file if there are more than one). + + Change this option (in the buffer or global scope) to control how ALE finds + CM files. For example, to always search for a CM file named `sandbox.cm`: +> + let g:ale_sml_smlnj_cm_file = 'sandbox.cm' + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-solidity.txt b/sources_non_forked/ale/doc/ale-solidity.txt new file mode 100644 index 00000000..c4d2f02f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-solidity.txt @@ -0,0 +1,41 @@ +=============================================================================== +ALE Solidity Integration *ale-solidity-options* + + +=============================================================================== +solc *ale-solidity-solc* + +g:ale_solidity_solc_executable *g:ale_solidity_solc_executable* + *b:ale_solidity_solc_executable* + Type: |String| + Default: `'solc'` + + Override the invoked solc binary. For truffle/hardhat binaries. + +g:ale_solidity_solc_options *g:ale_solidity_solc_options* + *b:ale_solidity_solc_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to solc. + + +=============================================================================== +solhint *ale-solidity-solhint* + + Solhint should work out-of-the-box. You can further configure it using a + `.solihint.json` file. See https://github.com/protofire/solhint for more + information. + + +=============================================================================== +solium *ale-solidity-solium* + + Use of Solium linter for Solidity source code requires a .soliumrc.json + file in project root. This file can be generated by running `solium --init`. + See the corresponding solium usage for detailed instructions + (https://github.com/duaraghav8/Solium#usage). + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-spec.txt b/sources_non_forked/ale/doc/ale-spec.txt new file mode 100644 index 00000000..3da950c8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-spec.txt @@ -0,0 +1,43 @@ +=============================================================================== +ALE Spec Integration *ale-spec-options* + *ale-integration-spec* + +=============================================================================== +Integration Information + + The rpmlint linter is disabled by default, because running rpmlint can + result in the execution of code embedded in the spec file and rpmlint makes + no distinction between checks which are safe to run on untrusted files and + those which are not. + + Currently linters must be enabled globally. The rpmlint linter can be + enabled with: +> + let g:ale_linters = {'spec': ['rpmlint']} +< + +=============================================================================== +rpmlint *ale-spec-rpmlint* + +g:ale_spec_rpmlint_executable *g:ale_spec_rpmlint_executable* + *b:ale_spec_rpmlint_executable* + Type: |String| + Default: `'rpmlint'` + + This variable sets executable used for rpmlint. + + +g:ale_spec_rpmlint_options *g:ale_spec_rpmlint_options* + *b:ale_spec_rpmlint_options* + Type: |String| + Default: `''` + + Set this to pass extra arguments to rpmlint. + + For example, to instruct rpmlint to use a specific configuration file: +> + let g:ale_spec_rpmlint_options = '-f custom.cf' +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-sql.txt b/sources_non_forked/ale/doc/ale-sql.txt new file mode 100644 index 00000000..80929264 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-sql.txt @@ -0,0 +1,68 @@ +=============================================================================== +ALE SQL Integration *ale-sql-options* + + +=============================================================================== +dprint *ale-sql-dprint* + +See |ale-dprint-options| +and https://github.com/dprint/dprint-plugin-sql/releases + + +=============================================================================== +pgformatter *ale-sql-pgformatter* + +g:ale_sql_pgformatter_executable *g:ale_sql_pgformatter_executable* + *b:ale_sql_pgformatter_executable* + Type: |String| + Default: `'pg_format'` + + This variable sets executable used for pgformatter. + +g:ale_sql_pgformatter_options *g:ale_sql_pgformatter_options* + *b:ale_sql_pgformatter_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the pgformatter fixer. + + +=============================================================================== +sqlfmt *ale-sql-sqlfmt* + +g:ale_sql_sqlfmt_executable *g:ale_sql_sqlfmt_executable* + *b:ale_sql_sqlfmt_executable* + Type: |String| + Default: `'sqlfmt'` + + This variable sets executable used for sqlfmt. + +g:ale_sql_sqlfmt_options *g:ale_sql_sqlfmt_options* + *b:ale_sql_sqlfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the sqlfmt fixer. + At this time only the -u flag is available to format with upper-case. + + +=============================================================================== +sqlformat *ale-sql-sqlformat* + +g:ale_sql_sqlformat_executable *g:ale_sql_sqlformat_executable* + *b:ale_sql_sqlformat_executable* + Type: |String| + Default: `'sqlformat'` + + This variable sets executable used for sqlformat. + +g:ale_sql_sqlformat_options *g:ale_sql_sqlformat_options* + *b:ale_sql_sqlformat_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the sqlformat fixer. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-stylus.txt b/sources_non_forked/ale/doc/ale-stylus.txt new file mode 100644 index 00000000..3e6ba906 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-stylus.txt @@ -0,0 +1,33 @@ +=============================================================================== +ALE Stylus Integration *ale-stylus-options* + + +=============================================================================== +stylelint *ale-stylus-stylelint* + +g:ale_stylus_stylelint_executable *g:ale_stylus_stylelint_executable* + *b:ale_stylus_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + + +g:ale_stylus_stylelint_options *g:ale_stylus_stylelint_options* + *b:ale_stylus_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + + +g:ale_stylus_stylelint_use_global *g:ale_stylus_stylelint_use_global* + *b:ale_stylus_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-sugarss.txt b/sources_non_forked/ale/doc/ale-sugarss.txt new file mode 100644 index 00000000..8e991e54 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-sugarss.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE SugarSS Integration *ale-sugarss-options* + + +=============================================================================== +stylelint *ale-sugarss-stylelint* + +g:ale_sugarss_stylelint_executable *g:ale_sugarss_stylelint_executable* + *b:ale_sugarss_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + +g:ale_sugarss_stylelint_options *g:ale_sugarss_stylelint_options* + *b:ale_sugarss_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + +g:ale_sugarss_stylelint_use_global *g:ale_sugarss_stylelint_use_global* + *b:ale_sugarss_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt new file mode 100644 index 00000000..591f1cb3 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-supported-languages-and-tools.txt @@ -0,0 +1,691 @@ +*ale-supported-languages-and-tools.txt* For Vim version 8.0. +*ale-supported-list* + +ALE Supported Languages and Tools + +=============================================================================== + +The following languages and tools are supported by ALE. + +Notes: + +`^` No linters for text or Vim help filetypes are enabled by default. +`!!` These linters check only files on disk. See |ale-lint-file-linters| + +* Ada + * `ada_language_server` + * `cspell` + * `gcc` + * `gnatpp` +* Ansible + * `ansible-lint`!! +* API Blueprint + * `drafter` +* APKBUILD + * `apkbuild-lint` + * `secfixes-check` +* AsciiDoc + * `alex` + * `cspell` + * `languagetool`!! + * `proselint` + * `redpen` + * `textlint` + * `vale` + * `write-good` +* ASM + * `gcc` +* AVRA + * `avra` +* Awk + * `gawk` +* Bash + * `bashate` + * `cspell` + * `language-server` + * `shell` (-n flag) + * `shellcheck` + * `shfmt` +* Bats + * `shellcheck` +* Bazel + * `buildifier` +* BibTeX + * `bibclean` +* Bicep + * `bicep` +* BitBake + * `oelint-adv` +* Bourne Shell + * `shell` (-n flag) + * `shellcheck` + * `shfmt` +* C + * `astyle` + * `ccls` + * `clang` (`cc`) + * `clang-format` + * `clangd` + * `clangtidy`!! + * `cppcheck` + * `cpplint`!! + * `cquery` + * `cspell` + * `flawfinder` + * `gcc` (`cc`) + * `uncrustify` +* C# + * `csc`!! + * `cspell` + * `dotnet-format` + * `mcs` + * `mcsc`!! + * `uncrustify` +* C++ (filetype cpp) + * `astyle` + * `ccls` + * `clang` (`cc`) + * `clang-format` + * `clangcheck`!! + * `clangd` + * `clangtidy`!! + * `clazy`!! + * `cppcheck` + * `cpplint`!! + * `cquery` + * `cspell` + * `flawfinder` + * `gcc` (`cc`) + * `uncrustify` +* Cairo + * `starknet` +* Chef + * `cookstyle` + * `foodcritic`!! +* Clojure + * `clj-kondo` + * `joker` +* CloudFormation + * `cfn-python-lint` +* CMake + * `cmake-format` + * `cmake-lint` + * `cmakelint` +* CoffeeScript + * `coffee` + * `coffeelint` +* Crystal + * `ameba`!! + * `crystal`!! +* CSS + * `VSCode CSS language server` + * `cspell` + * `css-beautify` + * `csslint` + * `fecs` + * `prettier` + * `stylelint` +* Cucumber + * `cucumber` +* CUDA + * `clangd` + * `nvcc`!! +* Cypher + * `cypher-lint` +* Cython (pyrex filetype) + * `cython` +* D + * `dfmt` + * `dls` + * `dmd` + * `uncrustify` +* Dafny + * `dafny`!! +* Dart + * `analysis_server` + * `dart-analyze`!! + * `dart-format`!! + * `dartfmt`!! + * `language_server` +* desktop + * `desktop-file-validate` +* Dhall + * `dhall-format` + * `dhall-freeze` + * `dhall-lint` +* Dockerfile + * `dockerfile_lint` + * `dprint` + * `hadolint` +* Elixir + * `credo` + * `cspell` + * `dialyxir` + * `dogma`!! + * `elixir-ls` + * `mix`!! +* Elm + * `elm-format` + * `elm-ls` + * `elm-make` +* Erb + * `erb` + * `erblint` + * `erubi` + * `erubis` + * `ruumba` +* Erlang + * `SyntaxErl` + * `dialyzer`!! + * `elvis`!! + * `erlang_ls` + * `erlc` + * `erlfmt` +* Fish + * `fish` (-n flag) + * `fish_indent` +* Fortran + * `gcc` + * `language_server` +* Fountain + * `proselint` +* FusionScript + * `fusion-lint` +* Git Commit Messages + * `gitlint` +* GLSL + * `glslang` + * `glslls` +* Go + * `bingo` + * `cspell` + * `go build`!! + * `go mod`!! + * `go vet`!! + * `gofmt` + * `gofumpt` + * `goimports` + * `golangci-lint`!! + * `golangserver` + * `golines` + * `golint` + * `gometalinter`!! + * `gopls` + * `gosimple`!! + * `gotype`!! + * `revive`!! + * `staticcheck`!! +* GraphQL + * `eslint` + * `gqlint` + * `prettier` +* Hack + * `hack` + * `hackfmt` + * `hhast` +* Haml + * `haml-lint` +* Handlebars + * `ember-template-lint` +* Haskell + * `brittany` + * `cabal-ghc` + * `cspell` + * `floskell` + * `ghc` + * `ghc-mod` + * `hdevtools` + * `hfmt` + * `hie` + * `hindent` + * `hlint` + * `hls` + * `ormolu` + * `stack-build`!! + * `stack-ghc` + * `stylish-haskell` +* HCL + * `packer-fmt` + * `terraform-fmt` +* HTML + * `VSCode HTML language server` + * `alex` + * `angular` + * `cspell` + * `fecs` + * `html-beautify` + * `htmlhint` + * `prettier` + * `proselint` + * `tidy` + * `write-good` +* Idris + * `idris` +* Ink + * `ink-language-server` +* Inko + * `inko` !! +* ISPC + * `ispc`!! +* Java + * `PMD` + * `checkstyle`!! + * `cspell` + * `eclipselsp` + * `google-java-format` + * `javac` + * `javalsp` + * `uncrustify` +* JavaScript + * `cspell` + * `deno` + * `dprint` + * `eslint` + * `fecs` + * `flow` + * `jscs` + * `jshint` + * `prettier` + * `prettier-eslint` + * `prettier-standard` + * `standard` + * `tsserver` + * `xo` +* JSON + * `VSCode JSON language server` + * `cspell` + * `dprint` + * `eslint` + * `fixjson` + * `jq` + * `jsonlint` + * `prettier` + * `spectral` +* JSON5 + * `eslint` +* JSONC + * `eslint` +* Jsonnet + * `jsonnet-lint` + * `jsonnetfmt` +* Julia + * `languageserver` +* Kotlin + * `kotlinc`!! + * `ktlint` + * `languageserver` +* LaTeX (tex) + * `alex` + * `chktex` + * `cspell` + * `lacheck` + * `proselint` + * `redpen` + * `texlab` + * `textlint` + * `vale` + * `write-good` +* Less + * `lessc` + * `prettier` + * `stylelint` +* LLVM + * `llc` +* Lua + * `cspell` + * `lua-format` + * `luac` + * `luacheck` + * `luafmt` + * `selene` + * `stylua` +* Mail + * `alex` + * `languagetool`!! + * `proselint` + * `vale` +* Make + * `checkmake` +* Markdown + * `alex` + * `cspell` + * `languagetool`!! + * `markdownlint`!! + * `mdl` + * `pandoc` + * `prettier` + * `proselint` + * `redpen` + * `remark-lint` + * `textlint` + * `vale` + * `write-good` +* MATLAB + * `mlint` +* Mercury + * `mmc`!! +* NASM + * `nasm`!! +* Nim + * `nim check`!! + * `nimlsp` + * `nimpretty` +* nix + * `nix-instantiate` + * `nixfmt` + * `nixpkgs-fmt` + * `rnix-lsp` + * `statix` +* nroff + * `alex` + * `proselint` + * `write-good` +* Objective-C + * `ccls` + * `clang` + * `clangd` + * `uncrustify` +* Objective-C++ + * `clang` + * `clangd` + * `uncrustify` +* OCaml + * `dune` + * `merlin` (see |ale-ocaml-merlin|) + * `ocamlformat` + * `ocamllsp` + * `ocp-indent` + * `ols` +* OpenApi + * `ibm_validator` + * `prettier` + * `yamllint` +* OpenSCAD + * `SCA2D` +* Packer + * `packer-fmt-fixer` +* Pascal + * `ptop` +* Pawn + * `uncrustify` +* Perl + * `perl -c` + * `perl-critic` + * `perltidy` +* Perl6 + * `perl6 -c` +* PHP + * `cspell` + * `intelephense` + * `langserver` + * `phan` + * `php -l` + * `php-cs-fixer` + * `phpactor` + * `phpcbf` + * `phpcs` + * `phpmd` + * `phpstan` + * `pint` + * `psalm`!! + * `tlint` +* PO + * `alex` + * `msgfmt` + * `proselint` + * `write-good` +* Pod + * `alex` + * `proselint` + * `write-good` +* Pony + * `ponyc` +* PowerShell + * `cspell` + * `powershell` + * `psscriptanalyzer` +* Prolog + * `swipl` +* proto + * `buf-format`!! + * `buf-lint`!! + * `protoc-gen-lint`!! + * `protolint`!! +* Pug + * `pug-lint` +* Puppet + * `languageserver` + * `puppet` + * `puppet-lint` +* PureScript + * `purescript-language-server` + * `purs-tidy` + * `purty` +* Python + * `autoflake`!! + * `autoimport` + * `autopep8` + * `bandit` + * `black` + * `cspell` + * `flake8` + * `flakehell` + * `isort` + * `mypy` + * `prospector`!! + * `pycodestyle` + * `pydocstyle` + * `pyflakes` + * `pyflyby` + * `pylama`!! + * `pylint`!! + * `pylsp` + * `pyre` + * `pyright` + * `reorder-python-imports` + * ruff + * `unimport` + * `vulture`!! + * `yapf` +* QML + * `qmlfmt` + * `qmllint` +* R + * `languageserver` + * `lintr` + * `styler` +* Racket + * `racket-langserver` + * `raco` + * `raco_fmt` +* Re:VIEW + * `redpen` +* ReasonML + * `merlin` + * `ols` + * `reason-language-server` + * `refmt` +* Rego + * `cspell` + * `opacheck` + * `opafmt` +* reStructuredText + * `alex` + * `cspell` + * `proselint` + * `redpen` + * `rstcheck` + * `textlint` + * `vale` + * `write-good` +* Robot + * `rflint` +* RPM spec + * `rpmlint` +* Ruby + * `brakeman`!! + * `cspell` + * `debride` + * `prettier` + * `rails_best_practices`!! + * `reek` + * `rubocop` + * `ruby` + * `rufo` + * `solargraph` + * `sorbet` + * `standardrb` + * `syntax_tree` +* Rust + * `cargo`!! + * `cspell` + * `rls` + * `rust-analyzer` + * `rustc` (see |ale-integration-rust|) + * `rustfmt` +* Salt + * `salt-lint` +* Sass + * `sass-lint` + * `stylelint` +* Scala + * `cspell` + * `fsc` + * `metals` + * `sbtserver` + * `scalac` + * `scalafmt` + * `scalastyle` +* SCSS + * `prettier` + * `sass-lint` + * `scss-lint` + * `stylelint` +* Slim + * `slim-lint` +* SML + * `smlnj` +* Solidity + * `solc` + * `solhint` + * `solium` +* SQL + * `dprint` + * `pgformatter` + * `sql-lint` + * `sqlfmt` + * `sqlformat` + * `sqlint` +* Stylus + * `stylelint` +* SugarSS + * `stylelint` +* Svelte + * `prettier` + * `svelteserver` +* Swift + * Apple `swift-format` + * `cspell` + * `sourcekit-lsp` + * `swiftformat` + * `swiftlint` +* systemd + * `systemd-analyze`!! +* Tcl + * `nagelfar`!! +* Terraform + * `checkov` + * `terraform` + * `terraform-fmt-fixer` + * `terraform-ls` + * `terraform-lsp` + * `tflint` + * `tfsec` +* Texinfo + * `alex` + * `cspell` + * `proselint` + * `write-good` +* Text^ + * `alex` + * `cspell` + * `languagetool`!! + * `proselint` + * `redpen` + * `textlint` + * `vale` + * `write-good` +* Thrift + * `thrift` + * `thriftcheck` +* TOML + * `dprint` +* TypeScript + * `cspell` + * `deno` + * `dprint` + * `eslint` + * `fecs` + * `prettier` + * `standard` + * `tslint` + * `tsserver` + * `typecheck` +* V + * `v`!! + * `vfmt` +* VALA + * `uncrustify` + * `vala_lint`!! +* Verilog + * `hdl-checker` + * `iverilog` + * `verilator` + * `vlog` + * `xvlog` + * `yosys`!! +* VHDL + * `ghdl` + * `vcom` + * `xvhdl` +* Vim + * `vimls` + * `vint` +* Vim help^ + * `alex` + * `proselint` + * `write-good` +* Vue + * `cspell` + * `prettier` + * `vls` + * `volar` +* WGSL + * `naga` +* XHTML + * `alex` + * `cspell` + * `proselint` + * `write-good` +* XML + * `xmllint` +* YAML + * `actionlint` + * `circleci`!! + * `gitlablint` + * `prettier` + * `spectral` + * `swaglint` + * `yaml-language-server` + * `yamlfix` + * `yamllint` +* YANG + * `yang-lsp` +* Zeek + * `zeek`!! +* Zig + * `zigfmt` + * `zls` + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-svelte.txt b/sources_non_forked/ale/doc/ale-svelte.txt new file mode 100644 index 00000000..92f109f7 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-svelte.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE Svelte Integration *ale-svelte-options* + + +=============================================================================== +prettier *ale-svelte-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +svelteserver *ale-svelte-svelteserver* + +g:ale_svelte_svelteserver_executable *g:ale_svelte_svelteserver_executable* + *b:ale_svelte_svelteserver_executable* + Type: |String| + Default: `'svelteserver'` + + See |ale-integrations-local-executables| + + +g:ale_svelte_svelteserver_use_global *g:ale_svelte_svelteserver_use_global* + *b:ale_svelte_svelteserver_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-swift.txt b/sources_non_forked/ale/doc/ale-swift.txt new file mode 100644 index 00000000..a443eab8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-swift.txt @@ -0,0 +1,67 @@ +=============================================================================== +ALE Swift Integration *ale-swift-options* + + +=============================================================================== +apple-swift-format *ale-swift-apple-swift-format* + +There are 3 options to enable linting and fixing with Apple's swift-format: + +1. Install the local executable in your path, as described here: + https://github.com/apple/swift-format +2. Install the executable via your OS package manager, for instance via + Homebrew with `brew install swift-format` +3. Your Swift project has a dependency on the swift-format package, so it can + be run with `swift run swift-format lint ...` In this case, you need to set + a variable, see |g:ale_swift_appleswiftformat_use_swiftpm|. + +Additionally, ALE tries to locate and use the nearest existing `.swift-format` +configuration file. + + +g:ale_swift_appleswiftformat_executable + *g:ale_swift_appleswiftformat_executable* + *b:ale_swift_appleswiftformat_executable* + Type: |String| + Default: `'swift-format'` + + This variable can be modified to change the executable path for + `swift-format`. + + +g:ale_swift_appleswiftformat_use_swiftpm + *g:ale_swift_appleswiftformat_use_swiftpm* + *b:ale_swift_appleswiftformat_use_swiftpm* + Type: |Number| + Default: `0` + + When set to `1`, this option will cause ALE to use + `swift run swift-format lint ...` instead of the global executable. Use this + option if your Swift project has a dependency on the swift-format package. + + See |ale-integrations-local-executables| + + +=============================================================================== +cspell *ale-swift-cspell* + +See |ale-cspell-options| + + +=============================================================================== +sourcekitlsp *ale-swift-sourcekitlsp* + +To enable the SourceKit-LSP you need to install and build the executable as +described here: https://github.com/apple/sourcekit-lsp#building-sourcekit-lsp + + +g:ale_sourcekit_lsp_executable *g:ale_sourcekit_lsp_executable* + *b:ale_sourcekit_lsp_executable* + Type: |String| + Default: `'sourcekit-lsp'` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-systemd.txt b/sources_non_forked/ale/doc/ale-systemd.txt new file mode 100644 index 00000000..13c7037f --- /dev/null +++ b/sources_non_forked/ale/doc/ale-systemd.txt @@ -0,0 +1,14 @@ +=============================================================================== +ALE systemd Integration *ale-systemd-options* + + +=============================================================================== +systemd-analyze *ale-systemd-analyze* + +ALE supports checking user systemd units with `systemd-analyze --user verify` +Checks will only work with user unit files in their proper location. There +aren't any options, and checks can only run after saving the file. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-tcl.txt b/sources_non_forked/ale/doc/ale-tcl.txt new file mode 100644 index 00000000..497c9fd4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-tcl.txt @@ -0,0 +1,25 @@ +=============================================================================== +ALE Tcl Integration *ale-tcl-options* + + +=============================================================================== +nagelfar *ale-tcl-nagelfar* + +g:ale_tcl_nagelfar_executable *g:ale_tcl_nagelfar_executable* + *b:ale_tcl_nagelfar_executable* + Type: |String| + Default: `'nagelfar.tcl'` + + This variable can be changed to change the path to nagelfar. + + +g:ale_tcl_nagelfar_options *g:ale_tcl_nagelfar_options* + *b:ale_tcl_nagelfar_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to nagelfar. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-terraform.txt b/sources_non_forked/ale/doc/ale-terraform.txt new file mode 100644 index 00000000..91a7dd16 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-terraform.txt @@ -0,0 +1,138 @@ +=============================================================================== +ALE Terraform Integration *ale-terraform-options* + + +=============================================================================== +checkov *ale-terraform-checkov* + +g:ale_terraform_checkov_executable *g:ale_terraform_checkov_executable* + *b:ale_terraform_checkov_executable* + + Type: |String| + Default: `'checkov'` + + This variable can be changed to use a different executable for checkov. + + +g:ale_terraform_checkov_options *g:ale_terraform_checkov_options* + *b:ale_terraform_checkov_options* + Type: |String| + Default: `''` + + This variable can be changed to set additional options for checkov. + +=============================================================================== +terraform-fmt-fixer *ale-terraform-fmt-fixer* + +g:ale_terraform_fmt_executable *g:ale_terraform_fmt_executable* + *b:ale_terraform_fmt_executable* + + Type: |String| + Default: `'terraform'` + + This variable can be changed to use a different executable for terraform. + + +g:ale_terraform_fmt_options *g:ale_terraform_fmt_options* + *b:ale_terraform_fmt_options* + Type: |String| + Default: `''` + + +=============================================================================== +terraform *ale-terraform-terraform* + +g:ale_terraform_terraform_executable *g:ale_terraform_terraform_executable* + *b:ale_terraform_terraform_executable* + + Type: |String| + Default: `'terraform'` + + This variable can be changed to use a different executable for terraform. + + +=============================================================================== +terraform-ls *ale-terraform-terraform-ls* + +Official terraform language server. More stable than *terraform-lsp* but +currently has less features. + +g:ale_terraform_ls_executable *g:ale_terraform_ls_executable* + *b:ale_terraform_ls_executable* + Type: |String| + Default: `'terraform-ls'` + + This variable can be changed to use a different executable for terraform-ls. + + +g:ale_terraform_ls_options *g:ale_terraform_ls_options* + *b:ale_terraform_ls_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-ls. + + +=============================================================================== +terraform-lsp *ale-terraform-terraform-lsp* + +g:ale_terraform_langserver_executable *g:ale_terraform_langserver_executable* + *b:ale_terraform_langserver_executable* + Type: |String| + Default: `'terraform-lsp'` + + This variable can be changed to use a different executable for terraform-lsp. + + +g:ale_terraform_langserver_options *g:ale_terraform_langserver_options* + *b:ale_terraform_langserver_options* + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to terraform-lsp. + + +=============================================================================== +tflint *ale-terraform-tflint* + +g:ale_terraform_tflint_executable *g:ale_terraform_tflint_executable* + *b:ale_terraform_tflint_executable* + + Type: |String| + Default: `'tflint'` + + This variable can be changed to use a different executable for tflint. + + +g:ale_terraform_tflint_options *g:ale_terraform_tflint_options* + *b:ale_terraform_tflint_options* + Type: |String| + Default: `'-f json'` + + This variable can be changed to pass different options to tflint. Ale does + expect json output from tflint, so if you change this, you'll probably want + to include '-f json' in your new value. + + +=============================================================================== +tfsec *ale-terraform-tfsec* + +g:ale_terraform_tfsec_executable *g:ale_terraform_tfsec_executable* + *b:ale_terraform_tfsec_executable* + + Type: |String| + Default: `'tfsec'` + + This variable can be changed to use a different executable for tfsec. + +g:ale_terraform_tfsec_options *g:ale_terraform_tfsec_options* + *b:ale_terraform_tfsec_options* + + Type: |String| + Default: `''` + + This variable can be changed to pass custom CLI flags to tfsec. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-tex.txt b/sources_non_forked/ale/doc/ale-tex.txt new file mode 100644 index 00000000..fa0d827e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-tex.txt @@ -0,0 +1,95 @@ +=============================================================================== +ALE TeX Integration *ale-tex-options* + + +=============================================================================== +chktex *ale-tex-chktex* + +g:ale_tex_chktex_executable *g:ale_tex_chktex_executable* + *b:ale_tex_chktex_executable* + Type: |String| + Default: `'chktex'` + + This variable can be changed to change the path to chktex. + + +g:ale_tex_chktex_options *g:ale_tex_chktex_options* + *b:ale_tex_chktex_options* + Type: |String| + Default: `'-I'` + + This variable can be changed to modify flags given to chktex. + + +=============================================================================== +cspell *ale-tex-cspell* + +See |ale-cspell-options| + + +=============================================================================== +lacheck *ale-tex-lacheck* + +g:ale_lacheck_executable *g:ale_lacheck_executable* + *b:ale_lacheck_executable* + Type: |String| + Default: `'lacheck'` + + This variable can be changed to change the path to lacheck. + + +=============================================================================== +latexindent *ale-tex-latexindent* + +g:ale_tex_latexindent_executable *g:ale_tex_latexindent_executable* + *b:ale_tex_latexindent_executable* + Type: |String| + Default: `'latexindent'` + + This variable can be changed to change the path to latexindent. + + +g:ale_tex_latexindent_options *g:ale_tex_latexindent_options* + *b:ale_tex_latexindent_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to latexindent. + + +=============================================================================== +texlab *ale-tex-texlab* + +g:ale_tex_texlab_executable *g:ale_tex_texlab_executable* + *b:ale_tex_texlab_executable* + Type: |String| + Default: `'texlab'` + + This variable can be changed to change the path to texlab. + + +g:ale_tex_texlab_options *g:ale_tex_texlab_options* + *b:ale_tex_texlab_options* + Type: |String| + Default: `''` + + This variable can be changed to modify flags given to texlab command. + +g:ale_tex_texlab_config *g:ale_tex_texlab_config* + *b:ale_tex_texlab_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing LSP configuration settings used to initialize texlab + language server. Refer to texlab documentation for possible settings: + + https://github.com/latex-lsp/texlab/blob/master/docs/options.md + + For example to set build onSave initialization setting: + +> + let g:ale_tex_texlab_config = {"build":{"onSave":v:true}} +< + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-texinfo.txt b/sources_non_forked/ale/doc/ale-texinfo.txt new file mode 100644 index 00000000..53d42b69 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-texinfo.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE Texinfo Integration *ale-texinfo-options* + + +=============================================================================== +cspell *ale-texinfo-cspell* + +See |ale-cspell-options| + + +=============================================================================== +write-good *ale-texinfo-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-text.txt b/sources_non_forked/ale/doc/ale-text.txt new file mode 100644 index 00000000..4e4d0b2e --- /dev/null +++ b/sources_non_forked/ale/doc/ale-text.txt @@ -0,0 +1,48 @@ +=============================================================================== +ALE Text Integration *ale-text-options* + + +============================================================================== +cspell *ale-text-cspell* + +See |ale-cspell-options| + + +=============================================================================== +textlint *ale-text-textlint* + +The options for the textlint linter are global because it does not make +sense to have them specified on a per-language basis. + +g:ale_textlint_executable *g:ale_textlint_executable* + *b:ale_textlint_executable* + Type: |String| + Default: `'textlint'` + + See |ale-integrations-local-executables| + + +g:ale_textlint_options *g:ale_textlint_options* + *b:ale_textlint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to textlint. + + +g:ale_textlint_use_global *g:ale_textlint_use_global* + *b:ale_textlint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +write-good *ale-text-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-thrift.txt b/sources_non_forked/ale/doc/ale-thrift.txt new file mode 100644 index 00000000..810127b4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-thrift.txt @@ -0,0 +1,65 @@ +=============================================================================== +ALE Thrift Integration *ale-thrift-options* + + +=============================================================================== +thrift *ale-thrift-thrift* + +The `thrift` linter works by compiling the buffer's contents and reporting any +errors reported by the parser and the configured code generator(s). + +g:ale_thrift_thrift_executable *g:ale_thrift_thrift_executable* + *b:ale_thrift_thrift_executable* + Type: |String| + Default: `'thrift'` + + See |ale-integrations-local-executables| + + +g:ale_thrift_thrift_generators *g:ale_thrift_thrift_generators* + *b:ale_thrift_thrift_generators* + Type: |List| of |String|s + Default: `['cpp']` + + This list must contain one or more named code generators. Generator options + can be included as part of each string, e.g. `['py:dynamic']`. + + +g:ale_thrift_thrift_includes *g:ale_thrift_thrift_includes* + *b:ale_thrift_thrift_includes* + Type: |List| of |String|s + Default: `['.']` + + This list contains paths that will be searched for thrift `include` + directives. + + +g:ale_thrift_thrift_options *g:ale_thrift_thrift_options* + *b:ale_thrift_thrift_options* + Type: |String| + Default: `'-strict'` + + This variable can be changed to customize the additional command-line + arguments that are passed to the thrift compiler. + +=============================================================================== +thriftcheck *ale-thrift-thriftcheck* + +g:ale_thrift_thriftcheck_executable *g:ale_thrift_thriftcheck_executable* + *b:ale_thrift_thriftcheck_executable* + Type: |String| + Default: `'thriftcheck'` + + See |ale-integrations-local-executables| + + +g:ale_thrift_thriftcheck_options *g:ale_thrift_thriftcheck_options* + *b:ale_thrift_thriftcheck_options* + Type: |String| + Default: `''` + + This variable can be changed to customize the additional command-line + arguments that are passed to thriftcheck. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-toml.txt b/sources_non_forked/ale/doc/ale-toml.txt new file mode 100644 index 00000000..222a91f4 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-toml.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE TOML Integration *ale-toml-options* + + +=============================================================================== +dprint *ale-toml-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/toml + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-typescript.txt b/sources_non_forked/ale/doc/ale-typescript.txt new file mode 100644 index 00000000..4a993793 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-typescript.txt @@ -0,0 +1,223 @@ +=============================================================================== +ALE TypeScript Integration *ale-typescript-options* + + +=============================================================================== +cspell *ale-typescript-cspell* + +See |ale-cspell-options| + + +=============================================================================== +deno *ale-typescript-deno* + +Starting from version 1.6.0, Deno comes with its own language server. Earlier +versions are not supported. + +g:ale_deno_executable *g:ale_deno_executable* + *b:ale_deno_executable* + Type: |String| + Default: `'deno'` + + +g:ale_deno_lsp_project_root *g:ale_deno_lsp_project_root* + *b:ale_deno_lsp_project_root* + Type: |String| + Default: `''` + + If this variable is left unset, ALE will try to find the project root by + executing the following steps in the given order: + + 1. Find an ancestor directory containing a tsconfig.json. + 2. Find an ancestor directory containing a .git folder. + 3. Use the directory of the current buffer (if the buffer was opened from + a file). + + +g:ale_deno_unstable *g:ale_deno_unstable* + *b:ale_deno_unstable* + Type: |Number| + Default: `0` + + Enable or disable unstable Deno features and APIs. + + +g:ale_deno_importMap *g:ale_deno_importMap* + *b:ale_deno_importMap* + Type: |String| + Default: `'import_map.json'` + + Specify the import map filename to load url maps in a deno project. + + +=============================================================================== +dprint *ale-typescript-dprint* + +See |ale-dprint-options| and https://dprint.dev/plugins/typescript + + +=============================================================================== +eslint *ale-typescript-eslint* + +Because of how TypeScript compiles code to JavaScript and how interrelated +the two languages are, the `eslint` linter for TypeScript uses the JavaScript +options for `eslint` too. See: |ale-javascript-eslint|. + + +=============================================================================== +prettier *ale-typescript-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +standard *ale-typescript-standard* + +g:ale_typescript_standard_executable *g:ale_typescript_standard_executable* + *b:ale_typescript_standard_executable* + Type: |String| + Default: `'standard'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_standard_options *g:ale_typescript_standard_options* + *b:ale_typescript_standard_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to standard. + + +g:ale_typescript_standard_use_global *g:ale_typescript_standard_use_global* + *b:ale_typescript_standard_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +tslint *ale-typescript-tslint* + +This linter isn't recommended, because TSLint can't be used for checking for +problems while you type. You should probably use the tsserver plugin instead. +tsserver plugins are described here: +https://github.com/Microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin + +Follow the instructions on the plugin website for installing it: +https://github.com/Microsoft/typescript-tslint-plugin + +Then disable TSLint in vimrc or any other Vim configuration file. > + let g:ale_linters_ignore = {'typescript': ['tslint']} +< + +g:ale_typescript_tslint_executable *g:ale_typescript_tslint_executable* + *b:ale_typescript_tslint_executable* + Type: |String| + Default: `'tslint'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_tslint_config_path *g:ale_typescript_tslint_config_path* + *b:ale_typescript_tslint_config_path* + Type: |String| + Default: `''` + + ALE will first discover the tslint.json path in an ancestor directory. If no + such path exists, this variable will be used instead. + + +g:ale_typescript_tslint_ignore_empty_files + *g:ale_typescript_tslint_ignore_empty_files* + *b:ale_typescript_tslint_ignore_empty_files* + Type: |Number| + Default: `0` + + When set to `1`, ALE will not report any problems for empty files with + TSLint. ALE will still execute TSLint for the files, but ignore any problems + reported. This stops ALE from complaining about newly created files, + and files where lines have been added and then removed. + + +g:ale_typescript_tslint_rules_dir *g:ale_typescript_tslint_rules_dir* + *b:ale_typescript_tslint_rules_dir* + Type: |String| + Default: `''` + + If this variable is set, ALE will use it as the rules directory for tslint. + + +g:ale_typescript_tslint_use_global *g:ale_typescript_tslint_use_global* + *b:ale_typescript_tslint_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +tsserver *ale-typescript-tsserver* + +g:ale_typescript_tsserver_executable *g:ale_typescript_tsserver_executable* + *b:ale_typescript_tsserver_executable* + Type: |String| + Default: `'tsserver'` + + ALE will first discover the tsserver path in an ancestor node_modules + directory. If no such path exists, this variable will be used instead. + + If you wish to use only a globally installed version of tsserver, set + |g:ale_typescript_tsserver_use_global| to `1`. + + +g:ale_typescript_tsserver_config_path *g:ale_typescript_tsserver_config_path* + *b:ale_typescript_tsserver_config_path* + Type: |String| + Default: `''` + + ALE will first discover the tsserver.json path in an ancestor directory. If + no such path exists, this variable will be used instead. + + +g:ale_typescript_tsserver_use_global *g:ale_typescript_tsserver_use_global* + *b:ale_typescript_tsserver_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + This variable controls whether or not ALE will search for a local path for + tsserver first. If this variable is set to `1`, then ALE will always use the + global version of tsserver, in preference to locally installed versions of + tsserver in node_modules. + + +=============================================================================== +xo *ale-typescript-xo* + +g:ale_typescript_xo_executable *g:ale_typescript_xo_executable* + *b:ale_typescript_xo_executable* + Type: |String| + Default: `'xo'` + + See |ale-integrations-local-executables| + + +g:ale_typescript_xo_options *g:ale_typescript_xo_options* + *b:ale_typescript_xo_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xo. + + +g:ale_typescript_xo_use_global *g:ale_typescript_xo_use_global* + *b:ale_typescript_xo_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-v.txt b/sources_non_forked/ale/doc/ale-v.txt new file mode 100644 index 00000000..8c641447 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-v.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE V Integration *ale-v-options* + + +=============================================================================== +Integration Information + +`v` is V's build tool. `vfmt` (called as `v fmt` from the same +executable that does the builds) is the autoformatter/fixer. + +g:ale_v_v_executable *g:ale_v_v_executable* + *b:ale_v_v_executable* + + Type: |String| + Default: `'v'` + + The executable that will be run for the `v` linter and the `vfmt` fixer. + + +=============================================================================== +v *ale-v-v* + +g:ale_v_v_options *g:ale_v_v_options* + *b:ale_v_v_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the v linter. + They are injected directly after "v .". + + +=============================================================================== +vfmt *ale-v-vfmt* + +g:ale_v_vfmt_options *g:ale_v_vfmt_options* + *b:ale_v_vfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the vfmt fixer. + They are injected directly after "v fmt". + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vala.txt b/sources_non_forked/ale/doc/ale-vala.txt new file mode 100644 index 00000000..d48f68bb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-vala.txt @@ -0,0 +1,33 @@ +=============================================================================== +ALE VALA Integration *ale-vala-options* + + +=============================================================================== +uncrustify *ale-vala-uncrustify* + +See |ale-c-uncrustify| for information about the available options. + + +=============================================================================== +Vala-Lint *ale-vala-vala-lint* + +g:vala_vala_lint_executable *g:vala_vala_lint_executable* + *b:vala_vala_lint_executable* + Type: |String| + Default: `'io.elementary.vala-lint'` + + This variable can be set to specify a Vala-Lint executable file. + + +g:vala_vala_lint_config_filename *g:vala_vala_lint_config_filename* + *b:vala_vala_lint_config_filename* + Type: |String| + Default: `'vala-lint.conf'` + + This variable can be set to specify a Vala-Lint config filename. When a file + with the specified name was not found or this variable was set to empty, + Vala-Lint will be executed without specifying a config filename. + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-verilog.txt b/sources_non_forked/ale/doc/ale-verilog.txt new file mode 100644 index 00000000..611ed2f9 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-verilog.txt @@ -0,0 +1,142 @@ +=============================================================================== +ALE Verilog/SystemVerilog Integration *ale-verilog-options* + + +=============================================================================== +ALE can use six different linters for Verilog HDL: + + HDL Checker + Using `hdl_checker --lsp` + + iverilog: + Using `iverilog -t null -Wall` + + verilator + Using `verilator --lint-only -Wall` + + ModelSim/Questa + Using `vlog -quiet -lint` + + Vivado + Using `xvlog` + + Yosys + Using `ysoys -Q -T -p 'read_verilog'` + +By default, both 'verilog' and 'systemverilog' filetypes are checked. + +You can limit 'systemverilog' files to be checked using only 'verilator' by +defining 'g:ale_linters' variable: +> + au FileType systemverilog + \ let g:ale_linters = {'systemverilog' : ['verilator'],} +< + +=============================================================================== +General notes + +Linters/compilers that utilize a "work" directory for analyzing designs- such +as ModelSim and Vivado- can be passed the location of these directories as +part of their respective option strings listed below. This is useful for +holistic analysis of a file (e.g. a design with components, packages, or other +code defined external to the current file as part of a larger project) or +when wanting to simply pass an alternative location for the auto-generated +work directories (such as '/tmp') so as to not muddle the current directory. +Since these type of linters often use this work directory for holding compiled +design data as part of a single build process, they sometimes cannot handle +the frequent, asynchronous application launches when linting while text is +changing. This can happen in the form of hangs or crashes. To help prevent +this when using these linters, it may help to run linting less frequently; for +example, only when a file is saved. + +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + +=============================================================================== +hdl-checker *ale-verilog-hdl-checker* + +See |ale-vhdl-hdl-checker| + + +=============================================================================== +iverilog *ale-verilog-iverilog* + + No additional options + + +=============================================================================== +verilator *ale-verilog-verilator* + +g:ale_verilog_verilator_options *g:ale_verilog_verilator_options* + *b:ale_verilog_verilator_options* + Type: |String| + Default: `''` + + This variable can be changed to modify 'verilator' command arguments + + For example `'-sv --default-language "1800-2012"'` if you want to enable + SystemVerilog parsing and select the 2012 version of the language. + + +=============================================================================== +vlog *ale-verilog-vlog* + +g:ale_verilog_vlog_executable *g:ale_verilog_vlog_executable* + *b:ale_verilog_vlog_executable* + Type: |String| + Default: `'vlog'` + + This variable can be changed to the path to the 'vlog' executable. + + +g:ale_verilog_vlog_options *g:ale_verilog_vlog_options* + *b:ale_verilog_vlog_options* + Type: |String| + Default: `'-quiet -lint'` + + This variable can be changed to modify the flags/options passed to 'vlog'. + + +=============================================================================== +xvlog *ale-verilog-xvlog* + +g:ale_verilog_xvlog_executable *g:ale_verilog_xvlog_executable* + *b:ale_verilog_xvlog_executable* + Type: |String| + Default: `'xvlog'` + + This variable can be changed to the path to the 'xvlog' executable. + + +g:ale_verilog_xvlog_options *g:ale_verilog_xvlog_options* + *b:ale_verilog_xvlog_options* + Type: |String| + Default: `''` + + This variable can be changed to modify the flags/options passed to 'xvlog'. + + +=============================================================================== +yosys *ale-verilog-yosys* + +g:ale_verilog_yosys_executable *g:ale_verilog_yosys_executable* + *b:ale_verilog_yosys_executable* + Type: |String| + Default: `'yosys'` + + This variable can be changed to the path to the 'yosys' executable. + + +g:ale_verilog_yosys_options *g:ale_verilog_yosys_options* + *b:ale_verilog_yosys_options* + Type: |String| + Default: `'-Q -T -p ''read_verilog %s'''` + + This variable can be changed to modify the flags/options passed to 'yosys'. + By default, Yosys is an interactive program. To obtain linting functionality, + the `'read_verilog'` command is used. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vhdl.txt b/sources_non_forked/ale/doc/ale-vhdl.txt new file mode 100644 index 00000000..c2870240 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-vhdl.txt @@ -0,0 +1,157 @@ +=============================================================================== +ALE VHDL Integration *ale-vhdl-options* + + +=============================================================================== +ALE can use four different linters for VHDL: + + ghdl: + Using `ghdl --std=08` + + ModelSim/Questa + Using `vcom -2008 -quiet -lint` + + Vivado + Using `xvhdl --2008` + + HDL Checker + Using `hdl_checker --lsp` + +=============================================================================== +General notes + +ghdl, ModelSim/Questa and Vivado linters default to VHDL-2008 support. This, +and other options, can be changed with each linter's respective option +variable. + +Linters/compilers that utilize a "work" directory for analyzing designs- such +as ModelSim and Vivado- can be passed the location of these directories as +part of their respective option strings listed below. This is useful for +holistic analysis of a file (e.g. a design with components, packages, or other +code defined external to the current file as part of a larger project) or +when wanting to simply pass an alternative location for the auto-generated +work directories (such as '/tmp') so as to not muddle the current directory. +Since these type of linters often use this work directory for holding compiled +design data as part of a single build process, they sometimes cannot handle +the frequent, asynchronous application launches when linting while text is +changing. This can happen in the form of hangs or crashes. To help prevent +this when using these linters, it may help to run linting less frequently; for +example, only when a file is saved. + +HDL Checker is an alternative for some of the issues described above. It wraps +around ghdl, Vivado and ModelSim/Questa and, when using the latter, it can +handle mixed language (VHDL, Verilog, SystemVerilog) designs. + +=============================================================================== +ghdl *ale-vhdl-ghdl* + +g:ale_vhdl_ghdl_executable *g:ale_vhdl_ghdl_executable* + *b:ale_vhdl_ghdl_executable* + Type: |String| + Default: `'ghdl'` + + This variable can be changed to the path to the 'ghdl' executable. + + +g:ale_vhdl_ghdl_options *g:ale_vhdl_ghdl_options* + *b:ale_vhdl_ghdl_options* + Type: |String| + Default: `'--std=08'` + + This variable can be changed to modify the flags/options passed to 'ghdl'. + + +=============================================================================== +hdl-checker *ale-vhdl-hdl-checker* + +HDL Checker is a wrapper for VHDL/Verilg/SystemVerilog tools that aims to +reduce the boilerplate code needed to set things up. It can automatically +infer libraries for VHDL sources, determine the compilation order and provide +some static checks. + +You can install it using pip: +> + $ pip install hdl-checker + +`hdl-checker` will be run from a detected project root, determined by the +following methods, in order: + +1. Find the first directory containing a configuration file (see + |g:ale_hdl_checker_config_file|) +2. If no configuration file can be found, find the first directory containing + a folder named `'.git' +3. If no such folder is found, use the directory of the current buffer + + +g:ale_hdl_checker_executable + *g:ale_hdl_checker_executable* + *b:ale_hdl_checker_executable* + Type: |String| + Default: `'hdl_checker'` + + This variable can be changed to the path to the 'hdl_checker' executable. + + +g:ale_hdl_checker_options *g:ale_hdl_checker_options* + *b:ale_hdl_checker_options* + Type: |String| + Default: `''` + + This variable can be changed to modify the flags/options passed to the + 'hdl_checker' server startup command. + + +g:ale_hdl_checker_config_file *g:ale_hdl_checker_config_file* + *b:ale_hdl_checker_config_file* + Type: |String| + Default: `'.hdl_checker.config'` (Unix), + `'_hdl_checker.config'` (Windows) + + This variable can be changed to modify the config file HDL Checker will try + to look for. It will also affect how the project's root directory is + determined (see |ale-vhdl-hdl-checker|). + + More info on the configuration file format can be found at: + https://github.com/suoto/hdl_checker/wiki/Setting-up-a-project + + +=============================================================================== +vcom *ale-vhdl-vcom* + +g:ale_vhdl_vcom_executable *g:ale_vhdl_vcom_executable* + *b:ale_vhdl_vcom_executable* + Type: |String| + Default: `'vcom'` + + This variable can be changed to the path to the 'vcom' executable. + + +g:ale_vhdl_vcom_options *g:ale_vhdl_vcom_options* + *b:ale_vhdl_vcom_options* + Type: |String| + Default: `'-2008 -quiet -lint'` + + This variable can be changed to modify the flags/options passed to 'vcom'. + + +=============================================================================== +xvhdl *ale-vhdl-xvhdl* + +g:ale_vhdl_xvhdl_executable *g:ale_vhdl_xvhdl_executable* + *b:ale_vhdl_xvhdl_executable* + Type: |String| + Default: `'xvhdl'` + + This variable can be changed to the path to the 'xvhdl' executable. + + +g:ale_vhdl_xvhdl_options *g:ale_vhdl_xvhdl_options* + *b:ale_vhdl_xvhdl_options* + Type: |String| + Default: `'--2008'` + + This variable can be changed to modify the flags/options passed to 'xvhdl'. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vim-help.txt b/sources_non_forked/ale/doc/ale-vim-help.txt new file mode 100644 index 00000000..3cbe20d5 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-vim-help.txt @@ -0,0 +1,12 @@ +=============================================================================== +ALE Vim help Integration *ale-vim-help-options* + + +=============================================================================== +write-good *ale-vim-help-write-good* + +See |ale-write-good-options| + + +=============================================================================== +vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vim.txt b/sources_non_forked/ale/doc/ale-vim.txt new file mode 100644 index 00000000..f85b43eb --- /dev/null +++ b/sources_non_forked/ale/doc/ale-vim.txt @@ -0,0 +1,82 @@ +=============================================================================== +ALE Vim Integration *ale-vim-options* + + +=============================================================================== +vimls *ale-vim-vimls* + + The `vim-language-server` is the engine that powers VimL editor support + using the Language Server Protocol. See the installation instructions: + https://github.com/iamcco/vim-language-server#install + +g:ale_vim_vimls_executable *g:ale_vim_vimls_executable* + *b:ale_vim_vimls_executable* + Type: |String| + Default: `'vim-language-server'` + + This option can be set to change the executable path for vimls. + + +g:ale_vim_vimls_config *g:ale_vim_vimls_config* + *b:ale_vim_vimls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example: > + { + \ 'vim': { + \ 'iskeyword': '@,48-57,_,192-255,-#', + \ 'vimruntime': '', + \ 'runtimepath': '', + \ 'diagnostic': { + \ 'enable': v:true + \ }, + \ 'indexes': { + \ 'runtimepath': v:true, + \ 'gap': 100, + \ 'count': 3, + \ 'projectRootPatterns' : ['.git', 'autoload', 'plugin'] + \ }, + \ 'suggest': { + \ 'fromVimruntime': v:true, + \ 'fromRuntimepath': v:false + \ }, + \ } + \} +< + Consult the vim-language-server documentation for more information about + settings. + + +g:ale_vim_vimls_use_global *g:ale_vim_vimls_use_global* + *b:ale_vim_vimls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +vint *ale-vim-vint* + +g:ale_vim_vint_executable *g:ale_vim_vint_executable* + *b:ale_vim_vint_executable* + Type: |String| + Default: `'vint'` + + This option can be set to change the executable path for Vint. + + +g:ale_vim_vint_show_style_issues *g:ale_vim_vint_show_style_issues* + *b:ale_vim_vint_show_style_issues* + Type: |Number| + Default: `1` + + This variable will enable/disable style issues for Vint. When this option + is disabled, only warnings and errors which are not purely style issues + will be reported. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-vue.txt b/sources_non_forked/ale/doc/ale-vue.txt new file mode 100644 index 00000000..40106b2b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-vue.txt @@ -0,0 +1,68 @@ +=============================================================================== +ALE Vue Integration *ale-vue-options* + + +=============================================================================== +cspell *ale-vue-cspell* + +See |ale-cspell-options| + + +=============================================================================== +prettier *ale-vue-prettier* + +See |ale-javascript-prettier| for information about the available options. + + +=============================================================================== +vls *ale-vue-vls* + +g:ale_vue_vls_executable *g:ale_vue_vls_executable* + *b:ale_vue_vls_executable* + Type: |String| + Default: `'vls'` + + See |ale-integrations-local-executables| + + +g:ale_vue_vls_use_global *g:ale_vue_vls_use_global* + *b:ale_vue_vls_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +volar *ale-vue-volar* + + It is required to have typescript installed in your project as your dev + dependency: `npm i -D typescript` + +g:ale_vue_volar_executable *g:ale_vue_volar_executable* + *b:ale_vue_volar_executable* + Type: |String| + Default: `'vue-language-server'` + + See |ale-integrations-local-executables| + + +g:ale_vue_volar_use_global *g:ale_vue_volar_use_global* + *b:ale_vue_volar_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +g:vue_volar_init_options *g:ale_vue_volar_init_options* + *b:ale_vue_volar_init_options* + Type: |Dictionary| + Default: `{ ... }` + + Default is too long to show here, take a look at it over + `ale_linters/vue/volar.vim` + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-wgsl.txt b/sources_non_forked/ale/doc/ale-wgsl.txt new file mode 100644 index 00000000..5254f43b --- /dev/null +++ b/sources_non_forked/ale/doc/ale-wgsl.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE WGSL Integration *ale-wgsl-options* + + +=============================================================================== +naga *ale-wgsl-naga* + +g:ale_wgsl_naga_executable *g:ale_wgsl_naga_executable* + *b:ale_wgsl_naga_executable* + Type: |String| + Default: `'naga'` + + The executable that will be run for the `naga` linter. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-xhtml.txt b/sources_non_forked/ale/doc/ale-xhtml.txt new file mode 100644 index 00000000..10ca5b82 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-xhtml.txt @@ -0,0 +1,18 @@ +=============================================================================== +ALE XHTML Integration *ale-xhtml-options* + + +=============================================================================== +cspell *ale-xhtml-cspell* + +See |ale-cspell-options| + + +=============================================================================== +write-good *ale-xhtml-write-good* + +See |ale-write-good-options| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-xml.txt b/sources_non_forked/ale/doc/ale-xml.txt new file mode 100644 index 00000000..a7180df8 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-xml.txt @@ -0,0 +1,34 @@ +=============================================================================== +ALE XML Integration *ale-xml-options* + + +=============================================================================== +xmllint *ale-xml-xmllint* + +g:ale_xml_xmllint_executable *g:ale_xml_xmllint_executable* + *b:ale_xml_xmllint_executable* + Type: |String| + Default: `'xmllint'` + + This variable can be set to change the path to xmllint. + + +g:ale_xml_xmllint_options *g:ale_xml_xmllint_options* + *b:ale_xml_xmllint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to xmllint. + + +g:ale_xml_xmllint_indentsize *g:ale_xml_xmllint_indentsize* + *b:ale_xml_xmllint_indentsize* + Type: |Number| + Default: `2` + + This variable can be sent to specify the amount of spaces used for + indentation. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-yaml.txt b/sources_non_forked/ale/doc/ale-yaml.txt new file mode 100644 index 00000000..b3450b87 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-yaml.txt @@ -0,0 +1,331 @@ +=============================================================================== +ALE YAML Integration *ale-yaml-options* + + +=============================================================================== +actionlint *ale-yaml-actionlint* + +Website: https://github.com/rhysd/actionlint + + +Installation +------------------------------------------------------------------------------- + +See installation guide: https://github.com/rhysd/actionlint#quick-start + +This linter is disabled by default and must be enabled by setting `g:ale_linters`. +To enable it only for Github Action YAML files a configuration like this is +better: + +> + au BufRead,BufNewFile */.github/*/*.y{,a}ml + \ let b:ale_linters = {'yaml': ['actionlint']} +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable* + *b:ale_yaml_actionlint_executable* + Type: |String| + Default: `'actionlint'` + + This variable can be set to change the path to actionlint. + +g:ale_yaml_actionlint_options *g:ale_yaml_actionlint_options* + *b:ale_yaml_actionlint_options* + + Type: |String| + Default: `''` + + This variable can be set to add extra options to actionlint executable. + + For example, to disable running `shellcheck` and `pyflakes` external commands, + you may want to set: +> + let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes=' +< + Please note that passing `-format` as option is not supported at the moment. + +=============================================================================== +circleci *ale-yaml-circleci* + +Website: https://circleci.com/docs/2.0/local-cli + + +Installation +------------------------------------------------------------------------------- + +Follow the instructions on the website, and make sure to test that you can +validate configuration files with: > + + circleci config validate - < .circleci/config.yml +< + +As long as the validator runs correctly, you should be able to see errors when +you save the configuration file. The validator doesn't run as you type because +it sends network requests, and running too often would overload the circleci +servers. + + +=============================================================================== +prettier *ale-yaml-prettier* + +Website: https://github.com/prettier/prettier + + +Installation +------------------------------------------------------------------------------- + +Install prettier either globally or locally: > + + npm install prettier -g # global + npm install prettier # local +< + +=============================================================================== +spectral *ale-yaml-spectral* + +Website: https://github.com/stoplightio/spectral + + +Installation +------------------------------------------------------------------------------- + +Install spectral either globally or locally: > + + npm install @stoplight/spectral -g # global + npm install @stoplight/spectral # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_spectral_executable *g:ale_yaml_spectral_executable* + *b:ale_yaml_spectral_executable* + Type: |String| + Default: `'spectral'` + + This variable can be set to change the path to spectral. + +g:ale_yaml_spectral_use_global *g:ale_yaml_spectral_use_global* + *b:ale_yaml_spectral_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +swaglint *ale-yaml-swaglint* + +Website: https://github.com/byCedric/swaglint + + +Installation +------------------------------------------------------------------------------- + +Install swaglint either globally or locally: > + + npm install swaglint -g # global + npm install swaglint # local +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_swaglint_executable *g:ale_yaml_swaglint_executable* + *b:ale_yaml_swaglint_executable* + Type: |String| + Default: `'swaglint'` + + This variable can be set to change the path to swaglint. + + +g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global* + *b:ale_yaml_swaglint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yaml-language-server *ale-yaml-language-server* + +Website: https://github.com/redhat-developer/yaml-language-server + + +Installation +------------------------------------------------------------------------------- + +Install yaml-language-server either globally or locally: > + + npm install yaml-language-server -g # global + npm install yaml-language-server # local + + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_ls_executable *g:ale_yaml_ls_executable* + *b:ale_yaml_ls_executable* + Type: |String| + Default: `'yaml-language-server'` + + This variable can be set to change the path to yaml-language-server. + + +g:ale_yaml_ls_config *g:ale_yaml_ls_config* + *b:ale_yaml_ls_config* + Type: |Dictionary| + Default: `{}` + + Dictionary containing configuration settings that will be passed to the + language server. For example, to enable schema store: > + { + \ 'yaml': { + \ 'schemaStore': { + \ 'enable': v:true, + \ }, + \ }, + \ } +< + Consult the yaml-language-server documentation for more information about + settings. + + +g:ale_yaml_ls_use_global *g:ale_yaml_ls_use_global* + *b:ale_yaml_ls_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yamlfix *ale-yaml-yamlfix* + +Website: https://lyz-code.github.io/yamlfix + + +Installation +------------------------------------------------------------------------------- + +Install yamlfix: > + + pip install yamlfix +< + +Options +------------------------------------------------------------------------------- +g:ale_yaml_yamlfix_executable *g:ale_yaml_yamlfix_executable* + *b:ale_yaml_yamlfix_executable* + Type: |String| + Default: `'yamlfix'` + + See |ale-integrations-local-executables| + + +g:ale_yaml_yamlfix_options *g:ale_yaml_yamlfix_options* + *b:ale_yaml_yamlfix_options* + Type: |String| + Default: `''` + + This variable can be set to pass extra options to yamlfix. + +g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global* + *b:ale_yaml_yamlfix_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== +yamllint *ale-yaml-yamllint* + +Website: https://github.com/adrienverge/yamllint + + +Installation +------------------------------------------------------------------------------- + +Install yamllint in your a virtualenv directory, locally, or globally: > + + pip install yamllint # After activating virtualenv + pip install --user yamllint # Install to ~/.local/bin + sudo pip install yamllint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_yamllint_executable *g:ale_yaml_yamllint_executable* + *b:ale_yaml_yamllint_executable* + Type: |String| + Default: `'yamllint'` + + This variable can be set to change the path to yamllint. + + +g:ale_yaml_yamllint_options *g:ale_yaml_yamllint_options* + *b:ale_yaml_yamllint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to yamllint. + + +=============================================================================== +gitlablint *ale-yaml-gitlablint* + +Website: https://github.com/elijah-roberts/gitlab-lint + + +Installation +------------------------------------------------------------------------------- + +Install yamllint in your a virtualenv directory, locally, or globally: > + + pip3 install gitlab_lint # After activating virtualenv + pip3 install --user gitlab_lint # Install to ~/.local/bin + sudo pip3 install gitlab_lint # Install globally + +See |g:ale_virtualenv_dir_names| for configuring how ALE searches for +virtualenv directories. + +Is recommended to use |g:ale_pattern_options| to enable this linter so it only +applies to 'gitlab-ci.yml' files and not all yaml files: +> + let g:ale_pattern_options = { + \ '.gitlab-ci\.yml$': { + \ 'ale_linters': ['gitlablint'], + \ }, + \} +< + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_gitlablint_executable *g:ale_yaml_gitlablint_executable* + *b:ale_yaml_gitlablint_executable* + Type: |String| + Default: `'gll'` + + This variable can be set to change the path to gll. + + +g:ale_yaml_gitlablint_options *g:ale_yaml_gitlablint_options* + *b:ale_yaml_gitlablint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to gll. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-yang.txt b/sources_non_forked/ale/doc/ale-yang.txt new file mode 100644 index 00000000..ad619733 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-yang.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE YANG Integration *ale-yang-options* + + +=============================================================================== +yang-lsp *ale-yang-lsp* + +g:ale_yang_lsp_executable *g:ale_yang_lsp_executable* + *b:ale_yang_lsp_executable* + Type: |String| + Default: `'yang-language-server'` + + This variable can be changed to use a different executable for yang-lsp. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale-zeek.txt b/sources_non_forked/ale/doc/ale-zeek.txt new file mode 100644 index 00000000..910bc060 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-zeek.txt @@ -0,0 +1,23 @@ +=============================================================================== +ALE Zeek Integration *ale-zeek-options* + *ale-integration-zeek* + +=============================================================================== +Integration Information + + Currently, the only supported linter for Zeek is zeek. + +=============================================================================== +zeek *ale-zeek-zeek* + +g:ale_zeek_zeek_executable *g:ale_zeek_zeek_executable* + *b:ale_zeek_zeek_executable* + Type: |String| + Default: `'zeek'` + + This variable can be modified to change the executable path for `zeek`. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: + diff --git a/sources_non_forked/ale/doc/ale-zig.txt b/sources_non_forked/ale/doc/ale-zig.txt new file mode 100644 index 00000000..cafa12a1 --- /dev/null +++ b/sources_non_forked/ale/doc/ale-zig.txt @@ -0,0 +1,45 @@ +=============================================================================== +ALE Zig Integration *ale-zig-options* + *ale-integration-zig* + +=============================================================================== +Integration Information + + Currently, the only supported linter for zig is zls. + + +=============================================================================== +zigfmt *ale-zig-zigfmt* + +g:ale_zig_zigfmt_executable *g:ale_zig_zigfmt_executable* + *b:ale_zig_zigfmt_executable* + Type: |String| + Default: `'zig'` + + The executable that will be run for the `zig fmt` fixer. + + +=============================================================================== +zls *ale-zig-zls* + +g:ale_zig_zls_executable *g:ale_zig_zls_executable* + *b:ale_zig_zls_executable* + Type: |String| + Default: `'zls'` + + This variable can be modified to change the executable path for `zls`. + + +g:ale_zig_zls_config *g:ale_zig_zls_config* + *b:ale_zig_zls_config* + Type: |Dictionary| + Default: `{}` + + WARNING: As of writing, zls does not support receiving configuration + from the client. This variable is a PLACEHOLDER until it does. + + Dictionary with configuration settings for zls. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/doc/ale.txt b/sources_non_forked/ale/doc/ale.txt new file mode 100644 index 00000000..27d2c65c --- /dev/null +++ b/sources_non_forked/ale/doc/ale.txt @@ -0,0 +1,4638 @@ +*ale.txt* Plugin to lint and fix files asynchronously +*ale* + +ALE - Asynchronous Lint Engine + +=============================================================================== +CONTENTS *ale-contents* + + 1. Introduction.........................|ale-introduction| + 2. Supported Languages & Tools..........|ale-support| + 3. Linting..............................|ale-lint| + 3.1 Linting On Other Machines.........|ale-lint-other-machines| + 3.2 Adding Language Servers...........|ale-lint-language-servers| + 3.3 Other Sources.....................|ale-lint-other-sources| + 4. Fixing Problems......................|ale-fix| + 5. Language Server Protocol Support.....|ale-lsp| + 5.1 Completion........................|ale-completion| + 5.2 Go To Definition..................|ale-go-to-definition| + 5.3 Go To Type Definition.............|ale-go-to-type-definition| + 5.4 Go To Implementation..............|ale-go-to-type-implementation| + 5.5 Find References...................|ale-find-references| + 5.6 Hovering..........................|ale-hover| + 5.7 Symbol Search.....................|ale-symbol-search| + 5.8 Refactoring: Rename, Actions......|ale-refactor| + 6. Global Options.......................|ale-options| + 6.1 Highlights........................|ale-highlights| + 7. Linter/Fixer Options.................|ale-integration-options| + 7.1 Options for alex..................|ale-alex-options| + 7.2 Options for cspell................|ale-cspell-options| + 7.3 Options for languagetool..........|ale-languagetool-options| + 7.4 Options for write-good............|ale-write-good-options| + 7.5 Other Linter/Fixer Options........|ale-other-integration-options| + 8. Commands/Keybinds....................|ale-commands| + 9. API..................................|ale-api| + 10. Special Thanks......................|ale-special-thanks| + 11. Contact.............................|ale-contact| + +=============================================================================== +1. Introduction *ale-introduction* + +ALE provides the means to run linters asynchronously in Vim in a variety of +languages and tools. ALE sends the contents of buffers to linter programs +using the |job-control| features available in Vim 8 and NeoVim. For Vim 8, +Vim must be compiled with the |job| and |channel| and |timers| features +as a minimum. + +ALE supports the following key features for linting: + +1. Running linters when text is changed. +2. Running linters when files are opened. +3. Running linters when files are saved. (When a global flag is set.) +4. Populating the |loclist| with warning and errors. +5. Setting |signs| with warnings and errors for error markers. +6. Using |echo| to show error messages when the cursor moves. +7. Setting syntax highlights for errors. + +ALE can fix problems with files with the |ALEFix| command, using the same job +control functionality used for checking for problems. Try using the +|ALEFixSuggest| command for browsing tools that can be used to fix problems +for the current buffer. + +If you are interested in contributing to the development of ALE, read the +developer documentation. See |ale-development| + +=============================================================================== +2. Supported Languages & Tools *ale-support* + +ALE supports a wide variety of languages and tools. See |ale-supported-list| +for the full list. + +=============================================================================== +3. Linting *ale-lint* + +ALE's primary focus is on checking for problems with your code with various +programs via some Vim code for integrating with those programs, referred to +as 'linters.' ALE supports a wide array of programs for linting by default, +but additional programs can be added easily by defining files in |runtimepath| +with the filename pattern `ale_linters//.vim`. For more +information on defining new linters, see the extensive documentation +for |ale#linter#Define()|. + +Without any configuration, ALE will attempt to check all of the code for every +file you open in Vim with all available tools by default. To see what ALE +is doing, and what options have been set, try using the |:ALEInfo| command. + +Most of the linters ALE runs will check the Vim buffer you are editing instead +of the file on disk. This allows you to check your code for errors before you +have even saved your changes. ALE will check your code in the following +circumstances, which can be configured with the associated options. + +* When you modify a buffer. - |g:ale_lint_on_text_changed| +* On leaving insert mode. - |g:ale_lint_on_insert_leave| +* When you open a new or modified buffer. - |g:ale_lint_on_enter| +* When you save a buffer. - |g:ale_lint_on_save| +* When the filetype changes for a buffer. - |g:ale_lint_on_filetype_changed| +* If ALE is used to check code manually. - |:ALELint| + + *ale-lint-settings-on-startup* + +It is worth reading the documentation for every option. You should configure +which events ALE will use before ALE is loaded, so it can optimize which +autocmd commands to run. You can force autocmd commands to be reloaded with +`:ALEDisable | ALEEnable` + +This also applies to the autocmd commands used for |g:ale_echo_cursor|. + + *ale-lint-file-linters* + +Some programs must be run against files which have been saved to disk, and +simply do not support reading temporary files or stdin, either of which are +required for ALE to be able to check for errors as you type. The programs +which behave this way are documented in the lists and tables of supported +programs. ALE will only lint files with these programs in the following +circumstances. + +* When you open a new or modified buffer. - |g:ale_lint_on_enter| +* When you save a buffer. - |g:ale_lint_on_save| +* When the filetype changes for a buffer. - |g:ale_lint_on_filetype_changed| +* If ALE is used to check code manually. - |:ALELint| + +ALE will report problems with your code in the following ways, listed with +their relevant options. + +* By updating loclist. (On by default) - |g:ale_set_loclist| +* By updating quickfix. (Off by default) - |g:ale_set_quickfix| +* By setting error highlights. - |g:ale_set_highlights| +* By creating signs in the sign column. - |g:ale_set_signs| +* By echoing messages based on your cursor. - |g:ale_echo_cursor| +* By inline text based on your cursor. - |g:ale_virtualtext_cursor| +* By displaying the preview based on your cursor. - |g:ale_cursor_detail| +* By showing balloons for your mouse cursor - |g:ale_set_balloons| + +Please consult the documentation for each option, which can reveal some other +ways of tweaking the behavior of each way of displaying problems. You can +disable or enable whichever options you prefer. + +Most settings can be configured for each buffer. (|b:| instead of |g:|), +including disabling ALE for certain buffers with |b:ale_enabled|. The +|g:ale_pattern_options| setting can be used to configure files differently +based on regular expressions for filenames. For configuring entire projects, +the buffer-local options can be used with external plugins for reading Vim +project configuration files. Buffer-local settings can also be used in +ftplugin files for different filetypes. + +ALE offers several options for controlling which linters are run. + +* Selecting linters to run. - |g:ale_linters| +* Aliasing filetypes for linters - |g:ale_linter_aliases| +* Only running linters you asked for. - |g:ale_linters_explicit| +* Disabling only a subset of linters. - |g:ale_linters_ignore| +* Disabling LSP linters and `tsserver`. - |g:ale_disable_lsp| + +You can stop ALE any currently running linters with the |ALELintStop| command. +Any existing problems will be kept. + +------------------------------------------------------------------------------- +3.1 Linting On Other Machines *ale-lint-other-machines* + +ALE offers support for running linters or fixers on files you are editing +locally on other machines, so long as the other machine has access to the file +you are editing. This could be a linter or fixer run inside of a Docker image, +running in a virtual machine, running on a remote server, etc. + +In order to run tools on other machines, you will need to configure your tools +to run via scripts that execute commands on those machines, such as by setting +the ALE `_executable` options for those tools to a path for a script to run, +or by using |g:ale_command_wrapper| to specify a script to wrap all commands +that are run by ALE, before they are executed. For tools that ALE runs where +ALE looks for locally installed executables first, you may need to set the +`_use_global` options for those tools to `1`, or you can set +|g:ale_use_global_executables| to `1` before ALE is loaded to only use global +executables for all tools. + +In order for ALE to properly lint or fix files which are running on another +file system, you must provide ALE with |List|s of strings for mapping paths to +and from your local file system and the remote file system, such as the file +system of your Docker container. See |g:ale_filename_mappings| for all of the +different ways these filename mappings can be configured. + +For example, you might configure `pylint` to run via Docker by creating a +script like so. > + + #!/usr/bin/env bash + + exec docker run -i --rm -v "$(pwd):/data" cytopia/pylint "$@" +< + +You will run to run Docker commands with `-i` in order to read from stdin. + +With the above script in mind, you might configure ALE to lint your Python +project with `pylint` by providing the path to the script to execute, and +mappings which describe how to between the two file systems in your +`python.vim` |ftplugin| file, like so: > + + if expand('%:p') =~# '^/home/w0rp/git/test-pylint/' + let b:ale_linters = ['pylint'] + let b:ale_python_pylint_use_global = 1 + " This is the path to the script above. + let b:ale_python_pylint_executable = '/home/w0rp/git/test-pylint/pylint.sh' + " /data matches the path in Docker. + let b:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/w0rp/git/test-pylint', '/data'], + \ ], + \} + endif +< + +You might consider using a Vim plugin for loading Vim configuration files +specific to each project, if you have a lot of projects to manage. + + +------------------------------------------------------------------------------- +3.2 Adding Language Servers *ale-lint-language-servers* + +ALE comes with many default configurations for language servers, so they can +be detected and run automatically. ALE can connect to other language servers +by defining a new linter for a filetype. New linters can be defined in |vimrc|, +in plugin files, or `ale_linters` directories in |runtimepath|. + +See |ale-linter-loading-behavior| for more information on loading linters. + +A minimal configuration for a language server linter might look so. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'stdio', + \ 'executable': '/path/to/executable', + \ 'command': '%e run', + \ 'project_root': '/path/to/root_of_project', + \}) +< +For language servers that use a TCP or named pipe socket connection, you +should define the address to connect to instead. > + + call ale#linter#Define('filetype_here', { + \ 'name': 'any_name_you_want', + \ 'lsp': 'socket', + \ 'address': 'servername:1234', + \ 'project_root': '/path/to/root_of_project', + \}) +< + Most of the options for a language server can be replaced with a |Funcref| + for a function accepting a buffer number for dynamically computing values + such as the executable path, the project path, the server address, etc, + most of which can also be determined based on executing some other + asynchronous task. See |ale#command#Run()| for computing linter options + based on asynchronous results. + + See |ale#linter#Define()| for a detailed explanation of all of the options + for configuring linters. + + +------------------------------------------------------------------------------- +3.3 Other Sources *ale-lint-other-sources* + +Problems for a buffer can be taken from other sources and rendered by ALE. +This allows ALE to be used in combination with other plugins which also want +to display any problems they might find with a buffer. ALE's API includes the +following components for making this possible. + +* |ale#other_source#StartChecking()| - Tell ALE that a buffer is being checked. +* |ale#other_source#ShowResults()| - Show results from another source. +* |ALEWantResults| - A signal for when ALE wants results. + +Other resources can provide results for ALE to display at any time, following +ALE's loclist format. (See |ale-loclist-format|) For example: > + + " Tell ALE to show some results. + " This function can be called at any time. + call ale#other_source#ShowResults(bufnr(''), 'some-linter-name', [ + \ {'text': 'Something went wrong', 'lnum': 13}, + \]) +< + +Other sources should use a unique name for identifying themselves. A single +linter name can be used for all problems from another source, or a series of +unique linter names can be used. Results can be cleared for that source by +providing an empty List. + +|ale#other_source#StartChecking()| should be called whenever another source +starts checking a buffer, so other tools can know that a buffer is being +checked by some plugin. The |ALEWantResults| autocmd event can be used to +start checking a buffer for problems every time that ALE does. When +|ALEWantResults| is signaled, |g:ale_want_results_buffer| will be set to the +number of the buffer that ALE wants to check. +|ale#other_source#StartChecking()| should be called synchronously, and other +sources should perform their checks on a buffer in the background +asynchronously, so they don't interrupt editing. + +|ale#other_source#ShowResults()| must not be called synchronously before +ALE's engine executes its code after the |ALEWantResults| event runs. If +there are immediate results to provide to ALE, a 0 millisecond timer with +|timer_start()| can be set instead up to call |ale#other_source#ShowResults()| +after ALE has first executed its engine code for its own sources. + +A plugin might integrate its own checks with ALE like so: > + + augroup SomeGroupName + autocmd! + autocmd User ALEWantResults call Hook(g:ale_want_results_buffer) + augroup END + + function! DoBackgroundWork(buffer) abort + " Start some work in the background here. + " ... + " Then call WorkDone(a:buffer, results) + endfunction + + function! Hook(buffer) abort + " Tell ALE we're going to check this buffer. + call ale#other_source#StartChecking(a:buffer, 'some-name') + call DoBackgroundWork(a:buffer) + endfunction + + function! WorkDone(buffer, results) abort + " Send results to ALE after they have been collected. + call ale#other_source#ShowResults(a:buffer, 'some-name', a:results) + endfunction +< + +=============================================================================== +4. Fixing Problems *ale-fix* + +ALE can fix problems with files with the |ALEFix| command. |ALEFix| +accepts names of fixers to be applied as arguments. Alternatively, +when no arguments are provided, the variable |g:ale_fixers| will be +read for getting a |List| of commands for filetypes, split on `.`, and +the functions named in |g:ale_fixers| will be executed for fixing the +errors. + +The |ALEFixSuggest| command can be used to suggest tools that be used to +fix problems for the current buffer. + +The values for `g:ale_fixers` can be a list of |String|, |Funcref|, or +|lambda| values. String values must either name a function, or a short name +for a function set in the ALE fixer registry. + +Each function for fixing errors must accept either one argument `(buffer)` or +two arguments `(buffer, lines)`, representing the buffer being fixed and the +lines to fix. The functions must return either `0`, for changing nothing, a +|List| for new lines to set, a |Dictionary| for describing a command to be +run in the background, or the result of |ale#command#Run()|. + +Functions receiving a variable number of arguments will not receive the second +argument `lines`. Functions should name two arguments if the `lines` argument +is desired. This is required to avoid unnecessary copying of the lines of +the buffers being checked. + +When a |Dictionary| is returned for an |ALEFix| callback, the following keys +are supported for running the commands. + + `cwd` An optional |String| for setting the working directory + for the command. + + If not set, or `v:null`, the `cwd` of the last command + that spawn this one will be used. + + `command` A |String| for the command to run. This key is required. + + When `%t` is included in a command string, a temporary + file will be created, containing the lines from the file + after previous adjustment have been done. + + See |ale-command-format-strings| for formatting options. + + `read_temporary_file` When set to `1`, ALE will read the contents of the + temporary file created for `%t`. This option can be used + for commands which need to modify some file on disk in + order to fix files. + + `process_with` An optional callback for post-processing. + + The callback must accept arguments `(bufnr, output)`: + the buffer number undergoing fixing and the fixer's + output as a |List| of |String|s. It must return a |List| + of |String|s that will be the new contents of the + buffer. + + This callback is useful to remove excess lines from the + command's output or apply additional changes to the + output. + + + `read_buffer` An optional key for disabling reading the buffer. + + When set to `0`, ALE will not pipe the buffer's data + into the command via stdin. This option is ignored and + the buffer is not read when `read_temporary_file` is + `1`. + + This option defaults to `1`. + + *ale-fix-configuration* + +Synchronous functions and asynchronous jobs will be run in a sequence for +fixing files, and can be combined. For example: +> + let g:ale_fixers = { + \ 'javascript': [ + \ 'DoSomething', + \ 'eslint', + \ {buffer, lines -> filter(lines, 'v:val !=~ ''^\s*//''')}, + \ ], + \} + + ALEFix +< +The above example will call a function called `DoSomething` which could act +upon some lines immediately, then run `eslint` from the ALE registry, and +then call a lambda function which will remove every single line comment +from the file. + +For buffer-local settings, such as in |g:ale_pattern_options| or in ftplugin +files, a |List| may be used for configuring the fixers instead. +> + " Same as the above, only a List can be used instead of a Dictionary. + let b:ale_fixers = [ + \ 'DoSomething', + \ 'eslint', + \ {buffer, lines -> filter(lines, 'v:val !=~ ''^\s*//''')}, + \] + + ALEFix +< +For convenience, a plug mapping is defined for |ALEFix|, so you can set up a +keybind easily for fixing files. > + + " Bind F8 to fixing problems with ALE + nmap (ale_fix) +< +Files can be fixed automatically with the following options, which are all off +by default. + +|g:ale_fix_on_save| - Fix files when they are saved. + +Fixers can be disabled on save with |g:ale_fix_on_save_ignore|. They will +still be run when you manually run |ALEFix|. + +Fixers can be run on another machines, just like linters, such as fixers run +from a Docker container, running in a virtual machine, running a remote +server, etc. See |ale-lint-other-machines|. + + +=============================================================================== +5. Language Server Protocol Support *ale-lsp* + +ALE offers some support for integrating with Language Server Protocol (LSP) +servers. LSP linters can be used in combination with any other linter, and +will automatically connect to LSP servers when needed. ALE also supports +`tsserver` for TypeScript, which uses a different but very similar protocol. + +If you want to use another plugin for LSP features and tsserver, you can use +the |g:ale_disable_lsp| setting to disable ALE's own LSP integrations, or +ignore particular linters with |g:ale_linters_ignore|. + +------------------------------------------------------------------------------- +5.1 Completion *ale-completion* + +ALE offers support for automatic completion of code while you type. +Completion is only supported while at least one LSP linter is enabled. ALE +will only suggest symbols provided by the LSP servers. + + *ale-deoplete-integration* + +ALE integrates with Deoplete for offering automatic completion data. ALE's +completion source for Deoplete is named `'ale'`, and should enabled +automatically if Deoplete is enabled and configured correctly. Deoplete +integration should not be combined with ALE's own implementation. + + *ale-asyncomplete-integration* + +ALE additionally integrates with asyncomplete.vim for offering automatic +completion data. ALE's asyncomplete source requires registration and should +use the defaults provided by the |asyncomplete#sources#ale#get_source_options| function > + + " Use ALE's function for asyncomplete defaults + au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#ale#get_source_options({ + \ 'priority': 10, " Provide your own overrides here + \ })) +> +ALE also offers its own completion implementation, which does not require any +other plugins. Suggestions will be made while you type after completion is +enabled. ALE's own completion implementation can be enabled by setting +|g:ale_completion_enabled| to `1`. This setting must be set to `1` before ALE +is loaded. The delay for completion can be configured with +|g:ale_completion_delay|. This setting should not be enabled if you wish to +use ALE as a completion source for other plugins. + +ALE automatic completion will not work when 'paste' is active. Only set +'paste' when you are copy and pasting text into your buffers. + +ALE automatic completion will interfere with default insert completion with +`CTRL-N` and so on (|compl-vim|). You can write your own keybinds and a +function in your |vimrc| file to force insert completion instead, like so: > + + function! SmartInsertCompletion() abort + " Use the default CTRL-N in completion menus + if pumvisible() + return "\" + endif + + " Exit and re-enter insert mode, and use insert completion + return "\a\" + endfunction + + inoremap =SmartInsertCompletion() +< +ALE provides an 'omnifunc' function |ale#completion#OmniFunc| for triggering +completion manually with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O| > + + " Use ALE's function for omnicompletion. + set omnifunc=ale#completion#OmniFunc +< + *ale-completion-fallback* + +You can write your own completion function and fallback on other methods of +completion by checking if there are no results that ALE can determine. For +example, for Python code, you could fall back on the `python3complete` +function. > + + function! TestCompletionFunc(findstart, base) abort + let l:result = ale#completion#OmniFunc(a:findstart, a:base) + + " Check if ALE couldn't find anything. + if (a:findstart && l:result is -3) + \|| (!a:findstart && empty(l:result)) + " Defer to another omnifunc if ALE couldn't find anything. + return python3complete#Complete(a:findstart, a:base) + endif + + return l:result + endfunction + + set omnifunc=TestCompletionFunc +< +See |complete-functions| for documentation on how to write completion +functions. + +ALE will only suggest so many possible matches for completion. The maximum +number of items can be controlled with |g:ale_completion_max_suggestions|. + +If you don't like some of the suggestions you see, you can filter them out +with |g:ale_completion_excluded_words| or |b:ale_completion_excluded_words|. + +The |ALEComplete| command can be used to show completion suggestions manually, +even when |g:ale_completion_enabled| is set to `0`. For manually requesting +completion information with Deoplete, consult Deoplete's documentation. + +ALE supports automatic imports from external modules. This behavior can be +disabled by setting the |g:ale_completion_autoimport| variable to `0`. +Disabling automatic imports can drop some or all completion items from +some LSP servers (e.g. eclipselsp). + +You can manually request imports for symbols at the cursor with the +|ALEImport| command. The word at the cursor must be an exact match for some +potential completion result which includes additional text to insert into the +current buffer, which ALE will assume is code for an import line. This command +can be useful when your code already contains something you need to import. + +You can execute other commands whenever ALE inserts some completion text with +the |ALECompletePost| event. + +When working with TypeScript files, ALE can remove warnings from your +completions by setting the |g:ale_completion_tsserver_remove_warnings| +variable to 1. + + *ale-completion-completeopt-bug* + +ALE Automatic completion implementation replaces |completeopt| before opening +the omnicomplete menu with . In some versions of Vim, the value set +for the option will not be respected. If you experience issues with Vim +automatically inserting text while you type, set the following option in +vimrc, and your issues should go away. > + + set completeopt=menu,menuone,preview,noselect,noinsert +< +Or alternatively, if you want to show documentation in popups: > + + set completeopt=menu,menuone,popup,noselect,noinsert +< + *ale-symbols* + +ALE provides a set of basic completion symbols. If you want to replace those +symbols with others, you can set the variable |g:ale_completion_symbols| with +a mapping of the type of completion to the symbol or other string that you +would like to use. An example here shows the available options for symbols > + + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'unit', + \ 'value': 'val', + \ 'enum': '', + \ 'keyword': 'keyword', + \ 'snippet': '', + \ 'color': 'color', + \ 'file': '', + \ 'reference': 'ref', + \ 'folder': '', + \ 'enum member': '', + \ 'constant': '', + \ 'struct': '', + \ 'event': 'event', + \ 'operator': '', + \ 'type_parameter': 'type param', + \ '': 'v' + \ } +< +------------------------------------------------------------------------------- +5.2 Go To Definition *ale-go-to-definition* + +ALE supports jumping to the files and locations where symbols are defined +through any enabled LSP linters. The locations ALE will jump to depend on the +information returned by LSP servers. The |ALEGoToDefinition| command will jump +to the definition of symbols under the cursor. See the documentation for the +command for configuring how the location will be displayed. + +ALE will update Vim's |tagstack| automatically unless |g:ale_update_tagstack| is +set to `0`. + +------------------------------------------------------------------------------- +5.3 Go To Type Definition *ale-go-to-type-definition* + +ALE supports jumping to the files and locations where symbols' types are +defined through any enabled LSP linters. The locations ALE will jump to depend +on the information returned by LSP servers. The |ALEGoToTypeDefinition| +command will jump to the definition of symbols under the cursor. See the +documentation for the command for configuring how the location will be +displayed. + +------------------------------------------------------------------------------- +5.4 Go To Implementation *ale-go-to-implementation* + +ALE supports jumping to the files and locations where symbols are implemented +through any enabled LSP linters. The locations ALE will jump to depend on the +information returned by LSP servers. The |ALEGoToImplementation| command will +jump to the implementation of symbols under the cursor. See the documentation +for the command for configuring how the location will be displayed. + +------------------------------------------------------------------------------- +5.5 Find References *ale-find-references* + +ALE supports finding references for symbols though any enabled LSP linters +with the |ALEFindReferences| command. See the documentation for the command +for a full list of options. + +------------------------------------------------------------------------------- +5.6 Hovering *ale-hover* + +ALE supports "hover" information for printing brief information about symbols +at the cursor taken from LSP linters. The following commands are supported: + +|ALEHover| - Print information about the symbol at the cursor. + +Truncated information will be displayed when the cursor rests on a symbol by +default, as long as there are no problems on the same line. You can disable +this behavior by setting |g:ale_hover_cursor| to `0`. + +If |g:ale_set_balloons| is set to `1` and your version of Vim supports the +|balloon_show()| function, then "hover" information also show up when you move +the mouse over a symbol in a buffer. Diagnostic information will take priority +over hover information for balloons. If a line contains a problem, that +problem will be displayed in a balloon instead of hover information. + +Hover information can be displayed in the preview window instead by setting +|g:ale_hover_to_preview| to `1`. + +When using Neovim or Vim with |popupwin|, if |g:ale_hover_to_floating_preview| +or |g:ale_floating_preview| is set to 1, the hover information will show in a +floating window. The borders of the floating preview window can be customized +by setting |g:ale_floating_window_border|. + +For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling +|balloonexpr| commands in terminals can cause scrolling issues in terminals, +so ALE will not attempt to show balloons unless |g:ale_set_balloons| is set to +`1` before ALE is loaded. + +For enabling mouse support in terminals, you may have to change your mouse +settings. For example: > + + " Example mouse settings. + " You will need to try different settings, depending on your terminal. + set mouse=a + set ttymouse=xterm +< + +Documentation for symbols at the cursor can be retrieved using the +|ALEDocumentation| command. This command is only available for `tsserver`. + +------------------------------------------------------------------------------- +5.7 Symbol Search *ale-symbol-search* + +ALE supports searching for workspace symbols via LSP linters with the +|ALESymbolSearch| command. See the documentation for the command +for a full list of options. + +------------------------------------------------------------------------------- +5.8 Refactoring: Rename, Actions *ale-refactor* + +ALE supports renaming symbols in code such as variables or class names with +the |ALERename| command. + +`ALEFileRename` will rename file and fix import paths (tsserver only). + +|ALECodeAction| will execute actions on the cursor or applied to a visual +range selection, such as automatically fixing errors. + +Actions will appear in the right click mouse menu by default for GUI versions +of Vim, unless disabled by setting |g:ale_popup_menu_enabled| to `0`. + +Make sure to set your Vim to move the cursor position whenever you right +click, and enable the mouse menu: > + + set mouse=a + set mousemodel=popup_setpos +< +You may wish to remove some other menu items you don't want to see: > + + silent! aunmenu PopUp.Select\ Word + silent! aunmenu PopUp.Select\ Sentence + silent! aunmenu PopUp.Select\ Paragraph + silent! aunmenu PopUp.Select\ Line + silent! aunmenu PopUp.Select\ Block + silent! aunmenu PopUp.Select\ Blockwise + silent! aunmenu PopUp.Select\ All +< +=============================================================================== +6. Global Options *ale-options* + +g:airline#extensions#ale#enabled *g:airline#extensions#ale#enabled* + + Type: |Number| + Default: `1` + + Enables or disables the |airline|'s native extension for ale, which displays + warnings and errors in the status line, prefixed by + |airline#extensions#ale#error_symbol| and + |airline#extensions#ale#warning_symbol|. + + +g:ale_cache_executable_check_failures *g:ale_cache_executable_check_failures* + + Type: |Number| + Default: not set + + When set to `1`, ALE will cache failing executable checks for linters. By + default, only executable checks which succeed will be cached. + + When this option is set to `1`, Vim will have to be restarted after new + executables are installed for ALE to be able to run linters for those + executables. + + +g:ale_change_sign_column_color *g:ale_change_sign_column_color* + + Type: |Number| + Default: `0` + + When set to `1`, this option will set different highlights for the sign + column itself when ALE reports problems with a file. This option can be + combined with |g:ale_sign_column_always|. + + ALE uses the following highlight groups for highlighting the sign column: + + `ALESignColumnWithErrors` - Links to `error` by default. + `ALESignColumnWithoutErrors` - Uses the value for `SignColumn` by default. + + The sign column color can only be changed globally in Vim. The sign column + might produce unexpected results if editing different files in split + windows. + + +g:ale_close_preview_on_insert *g:ale_close_preview_on_insert* + + Type: |Number| + Default: `0` + + When this option is set to `1`, ALE's |preview-window| will be automatically + closed upon entering Insert Mode. This option can be used in combination + with |g:ale_cursor_detail| for automatically displaying the preview window + on problem lines, and automatically closing it again when editing text. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + +g:ale_command_wrapper *g:ale_command_wrapper* + *b:ale_command_wrapper* + Type: |String| + Default: `''` + + An option for wrapping all commands that ALE runs, for linters, fixers, + and LSP commands. This option can be set globally, or for specific buffers. + + This option can be used to apply nice to all commands. For example: > + + " Prefix all commands with nice. + let g:ale_command_wrapper = 'nice -n5' +< + Use the |ALEInfo| command to view the commands that are run. All of the + arguments for commands will be put on the end of the wrapped command by + default. A `%*` marker can be used to spread the arguments in the wrapped + command. > + + " Has the same effect as the above. + let g:ale_command_wrapper = 'nice -n5 %*' +< + + For passing all of the arguments for a command as one argument to a wrapper, + `%@` can be used instead. > + + " Will result in say: /bin/bash -c 'other-wrapper -c "some command" -x' + let g:ale_command_wrapper = 'other-wrapper -c %@ -x' +< + For commands including `&&` or `;`, only the last command in the list will + be passed to the wrapper. `&&` is most commonly used in ALE to change the + working directory before running a command. + + +g:ale_completion_delay *g:ale_completion_delay* + + Type: |Number| + Default: `100` + + The number of milliseconds before ALE will send a request to a language + server for completions after you have finished typing. + + See |ale-completion| + + +g:ale_completion_enabled *g:ale_completion_enabled* + *b:ale_completion_enabled* + + Type: |Number| + Default: `0` + + When this option is set to `1`, completion support will be enabled. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. + + This setting should not be enabled if you wish to use ALE as a completion + source for other completion plugins. + + ALE automatic completion will not work when 'paste' is active. Only set + 'paste' when you are copy and pasting text into your buffers. + + A buffer-local version of this setting `b:ale_completion_enabled` can be set + to `0` to disable ALE's automatic completion support for a single buffer. + ALE's completion support must be enabled globally to be enabled locally. + + See |ale-completion| + + + *g:ale_completion_tsserver_remove_warnings* +g:ale_completion_tsserver_remove_warnings + + Type: |Number| + Default: `0` + + When this option is set to `0`, ALE will return all completion items, + including those that are a warning. Warnings can be excluded from completed + items by setting it to `1`. + + +g:ale_completion_autoimport *g:ale_completion_autoimport* + + Type: |Number| + Default: `1` + + When this option is set to `1`, ALE will try to automatically import + completion results from external modules. It can be disabled by setting it + to `0`. Some LSP servers include auto imports on every completion item so + disabling automatic imports may drop some or all completion items returnend + by it (e.g. eclipselsp). + + +g:ale_completion_excluded_words *g:ale_completion_excluded_words* + *b:ale_completion_excluded_words* + Type: |List| + Default: `[]` + + This option can be set to a list of |String| values for "words" to exclude + from completion results, as in the words for |complete-items|. The strings + will be matched exactly in a case-sensitive manner. (|==#|) + + This setting can be configured in ftplugin files with buffer variables, so + that different lists can be used for different filetypes. For example: > + + " In ~/.vim/ftplugin/typescript.vim + + " Don't suggest `it` or `describe` so we can use snippets for those words. + let b:ale_completion_excluded_words = ['it', 'describe'] +< + +g:ale_completion_symbols *g:ale_completion_symbols* + + Type: |Dictionary| + + + A mapping from completion types to symbols for completions. See + |ale-symbols| for more information. + + By default, this mapping only uses built in Vim completion kinds, but it can + be updated to use any unicode character for the completion kind. For + example: > + let g:ale_completion_symbols = { + \ 'text': '', + \ 'method': '', + \ 'function': '', + \ 'constructor': '', + \ 'field': '', + \ 'variable': '', + \ 'class': '', + \ 'interface': '', + \ 'module': '', + \ 'property': '', + \ 'unit': 'v', + \ 'value': 'v', + \ 'enum': 't', + \ 'keyword': 'v', + \ 'snippet': 'v', + \ 'color': 'v', + \ 'file': 'v', + \ 'reference': 'v', + \ 'folder': 'v', + \ 'enum_member': 'm', + \ 'constant': 'm', + \ 'struct': 't', + \ 'event': 'v', + \ 'operator': 'f', + \ 'type_parameter': 'p', + \ '': 'v' + \ }) +< + +g:ale_completion_max_suggestions *g:ale_completion_max_suggestions* + + Type: |Number| + Default: `50` + + The maximum number of items ALE will suggest in completion menus for + automatic completion. + + Setting this number higher will require more processing time, and may + suggest too much noise. Setting this number lower will require less + processing time, but some suggestions will not be included, so you might not + be able to see the suggestions you want. + + Adjust this option as needed, depending on the complexity of your codebase + and your available processing power. + +g:ale_cursor_detail *g:ale_cursor_detail* + + Type: |Number| + Default: `0` + + When this option is set to `1`, ALE's |preview-window| will be automatically + opened when the cursor moves onto lines with problems. ALE will search for + problems using the same logic that |g:ale_echo_cursor| uses. The preview + window will be closed automatically when you move away from the line. + + Messages are only displayed after a short delay. See |g:ale_echo_delay|. + + The preview window is opened without stealing focus, which means your cursor + will stay in the same buffer as it currently is. + + The preview window can be closed automatically upon entering Insert mode + by setting |g:ale_close_preview_on_insert| to `1`. + + Either this setting or |g:ale_echo_cursor| must be set to `1` before ALE is + loaded for messages to be displayed. See |ale-lint-settings-on-startup|. + + +g:ale_default_navigation *g:ale_default_navigation* + *b:ale_default_navigation* + + Type: |String| + Default: `'buffer'` + + The default method for navigating away from the current buffer to another + buffer, such as for |ALEFindReferences|, or |ALEGoToDefinition|. + + +g:ale_detail_to_floating_preview *g:ale_detail_to_floating_preview* + *b:ale_detail_to_floating_preview* + Type: |Number| + Default: `0` + + When this option is set to `1`, Neovim or Vim with |popupwin| will use a + floating window for ALEDetail output. + + +g:ale_disable_lsp *g:ale_disable_lsp* + *b:ale_disable_lsp* + + Type: |Number| + Default: `0` + + When this option is set to `1`, ALE ignores all linters powered by LSP, + and also `tsserver`. + + Please see also |ale-lsp|. + + +g:ale_echo_cursor *g:ale_echo_cursor* + + Type: |Number| + Default: `1` + + When this option is set to `1`, a truncated message will be echoed when a + cursor is near a warning or error. ALE will attempt to find the warning or + error at a column nearest to the cursor when the cursor is resting on a line + which contains a warning or error. This option can be set to `0` to disable + this behavior. + + Messages are only displayed after a short delay. See |g:ale_echo_delay|. + + The format of the message can be customized with |g:ale_echo_msg_format|. + + Either this setting or |g:ale_cursor_detail| must be set to `1` before ALE + is loaded for messages to be displayed. See |ale-lint-settings-on-startup|. + + +g:ale_echo_delay *g:ale_echo_delay* + *b:ale_echo_delay* + Type: |Number| + Default: `10` + + Given any integer, this option controls the number of milliseconds before + ALE will echo or preview a message for a problem near the cursor. + + The value can be increased to decrease the amount of processing ALE will do + for files displaying a large number of problems. + + +g:ale_echo_msg_error_str *g:ale_echo_msg_error_str* + + Type: |String| + Default: `'Error'` + + The string used for `%severity%` for errors. See |g:ale_echo_msg_format| + + +g:ale_echo_msg_format *g:ale_echo_msg_format* + *b:ale_echo_msg_format* + + Type: |String| + Default: `'%code: %%s'` + + This variable defines a message format for echoed messages. The following + sequences of characters will be replaced. + + `%s` - replaced with the text for the problem + `%...code...% `- replaced with the error code + `%linter%` - replaced with the name of the linter + `%severity%` - replaced with the severity of the problem + + The strings for `%severity%` can be configured with the following options. + + |g:ale_echo_msg_error_str| - Defaults to `'Error'` + |g:ale_echo_msg_info_str| - Defaults to `'Info'` + |g:ale_echo_msg_warning_str| - Defaults to `'Warning'` + + `%code%` is replaced with the error code, and replaced with an empty string + when there is no error code. Any extra characters between the percent signs + will be printed when an error code is present. For example, a message like + `(error code): message` will be printed for `'%(code): %%s'` and simply the + message will be printed when there is no code. + + |g:ale_echo_cursor| needs to be set to 1 for messages to be displayed. + + The echo message format can also be configured separately for each buffer, + so different formats can be used for different languages. (Say in ftplugin + files.) + + +g:ale_echo_msg_info_str *g:ale_echo_msg_info_str* + + Type: |String| + Default: `'Info'` + + The string used for `%severity%` for info. See |g:ale_echo_msg_format| + + +g:ale_echo_msg_log_str *g:ale_echo_msg_log_str* + + Type: |String| + Default: `'Log'` + + The string used for `%severity%` for log, used only for handling LSP show + message requests. See |g:ale_lsp_show_message_format| + + +g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str* + + Type: |String| + Default: `'Warning'` + + The string used for `%severity%` for warnings. See |g:ale_echo_msg_format| + + +g:ale_enabled *g:ale_enabled* + *b:ale_enabled* + + Type: |Number| + Default: `1` + + When set to `0`, this option will completely disable ALE, such that no + error checking will be performed, etc. ALE can be toggled on and off with + the |ALEToggle| command, which changes this option. + + ALE can be disabled in each buffer by setting `let b:ale_enabled = 0` + Disabling ALE based on filename patterns can be accomplished by setting + a regular expression for |g:ale_pattern_options|. For example: > + + " Disable linting for all minified JS files. + let g:ale_pattern_options = {'\.min.js$': {'ale_enabled': 0}} +< + + See |g:ale_pattern_options| for more information on that option. + + +g:ale_exclude_highlights *g:ale_exclude_highlights* + *b:ale_exclude_highlights* + + Type: |List| + Default: `[]` + + A list of regular expressions for matching against highlight messages to + remove. For example: > + + " Do not highlight messages matching strings like these. + let b:ale_exclude_highlights = ['line too long', 'foo.*bar'] +< + See also: |g:ale_set_highlights| + + +g:ale_fixers *g:ale_fixers* + *b:ale_fixers* + + Type: |Dictionary| + Default: `{}` + + A mapping from filetypes to |List| values for functions for fixing errors. + See |ale-fix| for more information. + + This variable can be overridden with variables in each buffer. + `b:ale_fixers` can be set to a |List| of callbacks instead, which can be + more convenient. + + A special `'*'` key be used as a wildcard filetype for configuring fixers + for every other type of file. For example: > + + " Fix Python files with 'bar'. + " Don't fix 'html' files. + " Fix everything else with 'foo'. + let g:ale_fixers = {'python': ['bar'], 'html': [], '*': ['foo']} +< + +g:ale_fix_on_save *g:ale_fix_on_save* + *b:ale_fix_on_save* + + Type: |Number| + Default: `0` + + When set to 1, ALE will fix files when they are saved. + + If |g:ale_lint_on_save| is set to 1, files will be checked with linters + after files are fixed, only when the buffer is open, or re-opened. Changes + to the file will be saved to the file on disk. + + Files will not be fixed on `:wq`, so you should check your code before + closing a buffer. + + Fixing files can be disabled or enabled for individual buffers by setting + `b:ale_fix_on_save` to `0` or `1`. + + Some fixers can be excluded from being run automatically when you save files + with the |g:ale_fix_on_save_ignore| setting. + + +g:ale_fix_on_save_ignore *g:ale_fix_on_save_ignore* + *b:ale_fix_on_save_ignore* + + Type: |Dictionary| or |List| + Default: `{}` + + Given a |Dictionary| mapping filetypes to |Lists| of fixers to ignore, or + just a |List| of fixers to ignore, exclude those fixers from being run + automatically when files are saved. + + You can disable some fixers in your ftplugin file: > + + " Disable fixers 'b' and 'c' when fixing on safe for this buffer. + let b:ale_fix_on_save_ignore = ['b', 'c'] + " Alternatively, define ignore lists for different filetypes. + let b:ale_fix_on_save_ignore = {'foo': ['b'], 'bar': ['c']} +< + You can disable some fixers globally per filetype like so: > + + let g:ale_fixers = {'foo': ['a', 'b'], 'bar': ['c', 'd']} + let g:ale_fix_on_save = 1 + " For filetype `foo.bar`, only fixers 'b' and 'd' will be run on save. + let g:ale_fix_on_save_ignore = {'foo': ['a'], 'bar': ['c']} + " Alternatively, disable these fixers on save for all filetypes. + let g:ale_fix_on_save_ignore = ['a', 'c'] +< + You can ignore fixers based on matching |Funcref| values too: > + + let g:AddBar = {buffer, lines -> lines + ['bar']} + let g:ale_fixers = {'foo': g:AddBar} + " The lambda fixer will be ignored, as it will be found in the ignore list. + let g:ale_fix_on_save_ignore = [g:AddBar] +< + +g:ale_floating_preview *g:ale_floating_preview* + + Type: |Number| + Default: `0` + + When set to `1`, Neovim or Vim with |popupwin| will use a floating window + for ale's preview window. + This is equivalent to setting |g:ale_hover_to_floating_preview| and + |g:ale_detail_to_floating_preview| to `1`. + + +g:ale_floating_preview_popup_opts *g:ale_floating_preview_popup_opts* + + Type: |String| or |Dictionary| + Default: `''` + + Either a dictionary of options or the string name of a function that returns a + dictionary of options. This will be used as an argument to |popup_create| for + Vim users or |nvim_open_win| for NeoVim users. Note that in either case, the + resulting dictionary is merged with ALE defaults rather than expliciting overriding + them. This only takes effect if |g:ale_floating_preview| is enabled. + + NOTE: for Vim users see |popup_create-arguments|, for NeoVim users see + |nvim_open_win| for argument details + + For example, to enhance popups with a title: > + + function! CustomOpts() abort { + let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr('')) + return {'title': ' ALE: ' . (l:loc.linter_name) . ' '} + endfunction +< + + +g:ale_floating_window_border *g:ale_floating_window_border* + + Type: |List| + Default: `['|', '-', '+', '+', '+', '+', '|', '-']` + + When set to `[]`, window borders are disabled. The elements in the list set + the the characters for the left side, top, top-left corner, top-right + corner, bottom-right corner, bottom-left corner, right side, and bottom of + the floating window, respectively. + + If the terminal supports Unicode, you might try setting the value to + ` ['│', '─', '╭', '╮', '╯', '╰', '│', '─']`, to make it look nicer. + + NOTE: For compatibility with previous versions, if the list does not have + elements for the right side and bottom, the left side and top will be used + instead. + + +g:ale_history_enabled *g:ale_history_enabled* + + Type: |Number| + Default: `1` + + When set to `1`, ALE will remember the last few commands which were run + for every buffer which is open. This information can be viewed with the + |ALEInfo| command. The size of the buffer can be controlled with the + |g:ale_max_buffer_history_size| option. + + This option can be disabled if storing a command history is not desired. + + +g:ale_history_log_output *g:ale_history_log_output* + + Type: |Number| + Default: `1` + + When set to `1`, ALE will store the output of commands which have completed + successfully in the command history, and the output will be displayed when + using |ALEInfo|. + + |g:ale_history_enabled| must be set to `1` for this output to be stored or + printed. + + Some memory will be consumed by this option. It is very useful for figuring + out what went wrong with linters, and for bug reports. Turn this option off + if you want to save on some memory usage. + + +g:ale_hover_cursor *g:ale_hover_cursor* + + Type: |Number| + Default: `1` + + If set to `1`, ALE will show truncated information in the echo line about + the symbol at the cursor automatically when the |CursorHold| event is fired. + The delay before requesting hover information is based on 'updatetime', as + with all |CursorHold| events. + + If there's a problem on the line where the cursor is resting, ALE will not + show any hover information. + + See |ale-hover| for more information on hover information. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + +g:ale_hover_to_preview *g:ale_hover_to_preview* + *b:ale_hover_to_preview* + Type: |Number| + Default: `0` + + If set to `1`, hover messages will be displayed in the preview window, + instead of in balloons or the message line. + + +g:ale_hover_to_floating_preview *g:ale_hover_to_floating_preview* + *b:ale_hover_to_floating_preview* + Type: |Number| + Default: `0` + + If set to `1`, Neovim or Vim with |popupwin| will use floating windows for + hover messages. + + +g:ale_keep_list_window_open *g:ale_keep_list_window_open* + *b:ale_keep_list_window_open* + Type: |Number| + Default: `0` + + When set to `1`, this option will keep the loclist or quickfix windows event + after all warnings/errors have been removed for files. By default the + loclist or quickfix windows will be closed automatically when there are no + warnings or errors. + + See |g:ale_open_list| + + +g:ale_list_window_size *g:ale_list_window_size* + *b:ale_list_window_size* + Type: |Number| + Default: `10` + + This number configures the number of lines to set for the height of windows + opened automatically for ALE problems. The default of `10` matches the Vim + default height. + + See |g:ale_open_list| for information on automatically opening windows + for quickfix or the loclist. + + +g:ale_lint_delay *g:ale_lint_delay* + *b:ale_lint_delay* + Type: |Number| + Default: `200` + + This variable controls the milliseconds delay after which the linters will + be run after text is changed. This option is only meaningful with the + |g:ale_lint_on_text_changed| variable set to `always`, `insert`, or `normal`. + + A buffer-local option, `b:ale_lint_delay`, can be set to change the delay + for different buffers, such as in |ftplugin| files. + + +g:ale_lint_on_enter *g:ale_lint_on_enter* + + Type: |Number| + Default: `1` + + When this option is set to `1`, the |BufWinEnter| event will be used to + apply linters when buffers are first opened. If this is not desired, this + variable can be set to `0` in your vimrc file to disable this behavior. + + The |FileChangedShellPost| and |BufEnter| events will be used to check if + files have been changed outside of Vim. If a file is changed outside of + Vim, it will be checked when it is next opened. + + You should set this setting once before ALE is loaded, and restart Vim if + you want to change your preferences. See |ale-lint-settings-on-startup|. + + +g:ale_lint_on_filetype_changed *g:ale_lint_on_filetype_changed* + + Type: |Number| + Default: `1` + + This option will cause ALE to run when the filetype for a file is changed + after a buffer has first been loaded. A short delay will be used before + linting will be done, so the filetype can be changed quickly several times + in a row, but resulting in only one lint cycle. + + You should set this setting once before ALE is loaded, and restart Vim if + you want to change your preferences. See |ale-lint-settings-on-startup|. + + +g:ale_lint_on_save *g:ale_lint_on_save* + + Type: |Number| + Default: `1` + + This option will make ALE run the linters whenever a file is saved when it + it set to `1` in your vimrc file. This option can be used in combination + with the |g:ale_lint_on_enter| and |g:ale_lint_on_text_changed| options to + make ALE only check files after that have been saved, if that is what is + desired. + + +g:ale_lint_on_text_changed *g:ale_lint_on_text_changed* + + Type: |String| + Default: `'normal'` + + This option controls how ALE will check your files as you make changes. + The following values can be used. + + `'always'`, `'1'`, or `1` - Check buffers on |TextChanged| or |TextChangedI|. + `'normal'` - Check buffers only on |TextChanged|. + `'insert'` - Check buffers only on |TextChangedI|. + `'never'`, `'0'`, or `0` - Never check buffers on changes. + + ALE will check buffers after a short delay, with a timer which resets on + each change. The delay can be configured by adjusting the |g:ale_lint_delay| + variable. + *ale-linting-interrupts-mapping* + + Due to a bug in Vim, ALE can interrupt mappings with pending key presses, + per |timeoutlen|. If this happens, follow the advice for enabling + |g:ale_lint_on_insert_leave| below, and set this option to `'normal'`, or + disable it entirely. + + You should set this setting once before ALE is loaded, and restart Vim if + you want to change your preferences. See |ale-lint-settings-on-startup|. + + +g:ale_lint_on_insert_leave *g:ale_lint_on_insert_leave* + *b:ale_lint_on_insert_leave* + + Type: |Number| + Default: `1` + + When set to `1` in your vimrc file, this option will cause ALE to run + linters when you leave insert mode. + + ALE will not lint files when you escape insert mode with |CTRL-C| by + default. You can make ALE lint files with this option when you use |CTRL-C| + with the following mapping. > + + " Make using Ctrl+C do the same as Escape, to trigger autocmd commands + inoremap +< + A buffer-local version of this setting `b:ale_lint_on_insert_leave` can be + set to `0` to disable linting when leaving insert mode. The setting must + be enabled globally to be enabled locally. + + You should set this setting once before ALE is loaded, and restart Vim if + you want to change your preferences. See |ale-lint-settings-on-startup|. + + +g:ale_linter_aliases *g:ale_linter_aliases* + *b:ale_linter_aliases* + Type: |Dictionary| + Default: `{}` + + The |g:ale_linter_aliases| option can be used to set aliases from one + filetype to another. A given filetype can be mapped to use the linters + run for another given filetype. + + This |Dictionary| will be merged with a default dictionary containing the + following values: > + + { + \ 'Dockerfile': 'dockerfile', + \ 'csh': 'sh', + \ 'javascriptreact': ['javascript', 'jsx'], + \ 'plaintex': 'tex', + \ 'ps1': 'powershell', + \ 'rmarkdown': 'r', + \ 'rmd': 'r', + \ 'systemverilog': 'verilog', + \ 'typescriptreact': ['typescript', 'tsx'], + \ 'vader': ['vim', 'vader'], + \ 'verilog_systemverilog': ['verilog_systemverilog', 'verilog'], + \ 'vimwiki': 'markdown', + \ 'vue': ['vue', 'javascript'], + \ 'xsd': ['xsd', 'xml'], + \ 'xslt': ['xslt', 'xml'], + \ 'zsh': 'sh', + \} +< + For example, if you wish to map a new filetype `'foobar'` to run the `'php'` + linters, you could set the following: > + + let g:ale_linter_aliases = {'foobar': 'php'} +< + When combined with the |g:ale_linters| option, the original filetype + (`'foobar'`) will be used for determining which linters to run, + not the aliased type (`'php'`). This allows an aliased type to run a + different set of linters from the type it is being mapped to. + + Passing a list of filetypes is also supported. Say you want to lint + javascript and css embedded in HTML (using linters that support that). + You could alias `html` like so: + + `let g:ale_linter_aliases = {'html': ['html', 'javascript', 'css']}` + + Note that `html` itself was included as an alias. That is because aliases + will override the original linters for the aliased filetype. + + Linter aliases can be configured in each buffer with buffer-local variables. + ALE will first look for aliases for filetypes in the `b:ale_linter_aliases` + variable, then `g:ale_linter_aliases`, and then a default Dictionary. + + `b:ale_linter_aliases` can be set to a |List| or a |String|, to tell ALE to + load the linters for specific filetypes for a given buffer. > + + let b:ale_linter_aliases = ['html', 'javascript', 'css'] + " OR, Alias a filetype to only a single filetype with a String. + let b:ale_linter_aliases = 'javascript' +< + No linters will be loaded when the buffer's filetype is empty. + + +g:ale_filename_mappings *g:ale_filename_mappings* + *b:ale_filename_mappings* + + Type: |Dictionary| or |List| + Default: `{}` + + Either a |Dictionary| mapping a linter or fixer name, as displayed in + |:ALEInfo|, to a |List| of two-item |List|s for filename mappings, or just a + |List| of two-item |List|s. When given some paths to files, the value of + this setting will be used to convert filenames on a local file system to + filenames on some remote file system, such as paths in a Docker image, + virtual machine, or network drive. + + For example: > + + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \} +< + With the above configuration, a filename such as `/home/john/proj/foo.py` + will be provided to the linter/fixer as `/data/foo.py`, and paths parsed + from linter results such as `/data/foo.py` will be converted back to + `/home/john/proj/foo.py`. + + You can use `*` as to apply a |List| of filename mappings to all other + linters or fixers not otherwise matched. > + + " Use one List of paths for pylint. + " Use another List of paths for everything else. + let g:ale_filename_mappings = { + \ 'pylint': [ + \ ['/home/john/proj', '/data'], + \ ], + \ '*': [ + \ ['/home/john/proj', '/other-data'], + \ ], + \} +< + If you just want every single linter or fixer to use the same filename + mapping, you can just use a |List|. > + + " Same as above, but for ALL linters and fixers. + let g:ale_filename_mappings = [ + \ ['/home/john/proj', '/data'], + \] +< + You can provide many such filename paths for multiple projects. Paths are + matched by checking if the start of a file path matches the given strings, + in a case-sensitive manner. Earlier entries in the |List| will be tried + before later entries when mapping to a given file system. + + Buffer-local options can be set to the same values to override the global + options, such as in |ftplugin| files. + + NOTE: Only fixers registered with a short name can support filename mapping + by their fixer names. See |ale-fix|. Filename mappings set for all tools by + using only a |List| for the setting will also be applied to fixers not in + the registry. + + NOTE: In order for this filename mapping to work correctly, linters and + fixers must exclusively determine paths to files to lint or fix via ALE + command formatting as per |ale-command-format-strings|, and paths parsed + from linter files must be provided in `filename` keys if a linter returns + results for more than one file at a time, as per |ale-loclist-format|. If + you discover a linter or fixer which does not behave properly, please report + it as an issue. + + If you are running a linter or fixer through Docker or another remote file + system, you may have to mount your temporary directory, which you can + discover with the following command: > + + :echo fnamemodify(tempname(), ':h:h') +< + You should provide a mapping from this temporary directory to whatever you + mount this directory to in Docker, or whatever remote file system you are + working with. + + You can inspect the filename mappings ALE will use with the + |ale#GetFilenameMappings()| function. + + +g:ale_linters *g:ale_linters* + *b:ale_linters* + Type: |Dictionary| + Default: `{}` + + The |g:ale_linters| option sets a |Dictionary| mapping a filetype to a + |List| of linter programs to be run when checking particular filetypes. + + This |Dictionary| will be merged with a default dictionary containing the + following values: > + + { + \ 'apkbuild': ['apkbuild_lint', 'secfixes_check'], + \ 'csh': ['shell'], + \ 'elixir': ['credo', 'dialyxir', 'dogma'], + \ 'go': ['gofmt', 'golint', 'gopls', 'govet'], + \ 'hack': ['hack'], + \ 'help': [], + \ 'inko': ['inko'], + \ 'json': ['jsonlint', 'spectral'], + \ 'json': ['jsonlint', 'spectral', 'vscodejson'], + \ 'json5': [], + \ 'jsonc': [], + \ 'perl': ['perlcritic'], + \ 'perl6': [], + \ 'python': ['flake8', 'mypy', 'pylint', 'pyright'], + \ 'rust': ['cargo', 'rls'], + \ 'spec': [], + \ 'text': [], + \ 'vader': ['vimls'], + \ 'vue': ['eslint', 'vls'], + \ 'zsh': ['shell'], + \ 'v': ['v'], + \ 'yaml': ['spectral', 'yaml-language-server', 'yamllint'], + \} +< + This option can be used to enable only a particular set of linters for a + file. For example, you can enable only `eslint` for JavaScript files: > + + let g:ale_linters = {'javascript': ['eslint']} +< + If you want to disable all linters for a particular filetype, you can pass + an empty list of linters as the value: > + + let g:ale_linters = {'javascript': []} +< + All linters will be run for unspecified filetypes. All available linters can + be enabled explicitly for a given filetype by passing the string `'all'`, + instead of a List. > + + let g:ale_linters = {'c': 'all'} +< + Linters can be configured in each buffer with buffer-local variables. ALE + will first look for linters for filetypes in the `b:ale_linters` variable, + then `g:ale_linters`, and then the default Dictionary mentioned above. + + `b:ale_linters` can be set to a List, or the string `'all'`. When linters + for two different filetypes share the same name, the first linter loaded + will be used. Any ambiguity can be resolved by using a Dictionary specifying + which linter to run for which filetype instead. > + + " Use ESLint for the buffer if the filetype includes 'javascript'. + let b:ale_linters = {'javascript': ['eslint'], 'html': ['tidy']} + " Use a List for the same setting. This will work in most cases. + let b:ale_linters = ['eslint', 'tidy'] + " Disable all linters for the buffer. + let b:ale_linters = [] + " Explicitly enable all available linters for the filetype. + let b:ale_linters = 'all' +< + ALE can be configured to disable all linters unless otherwise specified with + `g:ale_enabled` or `b:ale_enabled` with the option |g:ale_linters_explicit|. + + +g:ale_linters_explicit *g:ale_linters_explicit* + + Type: |Number| + Default: `0` + + When set to `1`, only the linters from |g:ale_linters| and |b:ale_linters| + will be enabled. The default behavior for ALE is to enable as many linters + as possible, unless otherwise specified. + + +g:ale_linters_ignore *g:ale_linters_ignore* + *b:ale_linters_ignore* + + Type: |Dictionary| or |List| + Default: `{}` + + Linters to ignore. Commands for ignored linters will not be run, and + diagnostics for LSP linters will be ignored. (See |ale-lsp|) + + This setting can be set to a |Dictionary| mapping filetypes to linter names, + just like |g:ale_linters|, to list linters to ignore. Ignore lists will be + applied after everything else. > + + " Select flake8 and pylint, and ignore pylint, so only flake8 is run. + let g:ale_linters = {'python': ['flake8', 'pylint']} + let g:ale_linters_ignore = {'python': ['pylint']} +< + This setting can be set to simply a |List| of linter names, which is + especially more convenient when using the setting in ftplugin files for + particular buffers. > + + " The same as above, in a ftplugin/python.vim. + let b:ale_linters = ['flake8', 'pylint'] + let b:ale_linters_ignore = ['pylint'] +< + +g:ale_list_vertical *g:ale_list_vertical* + *b:ale_list_vertical* + Type: |Number| + Default: `0` + + When set to `1`, this will cause ALE to open any windows (loclist or + quickfix) vertically instead of horizontally (|vert| |lopen|) or (|vert| + |copen|) + + +g:ale_loclist_msg_format *g:ale_loclist_msg_format* + *b:ale_loclist_msg_format* + + Type: |String| + Default: `g:ale_echo_msg_format` + + This option is the same as |g:ale_echo_msg_format|, but for formatting the + message used for the loclist and the quickfix list. + + The strings for configuring `%severity%` are also used for this option. + + +g:ale_lsp_show_message_format *g:ale_lsp_show_message_format* + + Type: |String| + Default: `'%severity%:%linter%: %s'` + + This variable defines the format that messages received from an LSP will + have when echoed. The following sequences of characters will be replaced. + + `%s` - replaced with the message text + `%linter%` - replaced with the name of the linter + `%severity%` - replaced with the severity of the message + + The strings for `%severity%` levels "error", "info" and "warning" are shared + with |g:ale_echo_msg_format|. Severity "log" is unique to + |g:ale_lsp_show_message_format| and it can be configured via + + |g:ale_echo_msg_log_str| - Defaults to `'Log'` + + Please note that |g:ale_lsp_show_message_format| *can not* be configured + separately for each buffer like |g:ale_echo_msg_format| can. + + +g:ale_lsp_show_message_severity *g:ale_lsp_show_message_severity* + + Type: |String| + Default: `'error'` + + This variable defines the minimum severity level an LSP message needs to be + displayed. Messages below this level are discarded; please note that + messages with `Log` severity level are always discarded. + + Possible values follow the LSP spec `MessageType` definition: + + `'error'` - Displays only errors. + `'warning'` - Displays errors and warnings. + `'information'` - Displays errors, warnings and infos + `'log'` - Same as `'information'` + `'disabled'` - Doesn't display any information at all. + + +g:ale_lsp_suggestions *g:ale_lsp_suggestions* + + Type: |Number| + Default: `0` + + If set to `1`, show hints/suggestions from LSP servers or tsserver, in + addition to warnings and errors. + + +g:ale_max_buffer_history_size *g:ale_max_buffer_history_size* + + Type: |Number| + Default: `20` + + This setting controls the maximum number of commands which will be stored in + the command history used for |ALEInfo|. Command history will be rotated in + a FIFO manner. If set to a number <= 0, then the history will be + continuously set to an empty |List|. + + History can be disabled completely with |g:ale_history_enabled|. + + +g:ale_max_signs *g:ale_max_signs* + *b:ale_max_signs* + Type: |Number| + Default: `-1` + + When set to any positive integer, ALE will not render any more than the + given number of signs for any one buffer. + + When set to `0`, no signs will be set, but sign processing will still be + done, so existing signs can be removed. + + When set to any other value, no limit will be imposed on the number of signs + set. + + For disabling sign processing, see |g:ale_set_signs|. + + +g:ale_maximum_file_size *g:ale_maximum_file_size* + *b:ale_maximum_file_size* + Type: |Number| + Default: not set + + A maximum file size in bytes for ALE to check. If set to any positive + number, ALE will skip checking files larger than the given size. + + +g:ale_open_list *g:ale_open_list* + *b:ale_open_list* + Type: |Number| or |String| + Default: `0` + + When set to `1`, this will cause ALE to automatically open a window for the + loclist (|lopen|) or for the quickfix list instead if |g:ale_set_quickfix| + is `1`. (|copen|) + + When set to any higher numberical value, ALE will only open the window when + the number of warnings or errors are at least that many. + + When set to `'on_save'`, ALE will only open the loclist after buffers have + been saved. The list will be opened some time after buffers are saved and + any linter for a buffer returns results. + + The window will be kept open until all warnings or errors are cleared, + including those not set by ALE, unless |g:ale_keep_list_window_open| is set + to `1`, in which case the window will be kept open when no problems are + found. + + The window size can be configured with |g:ale_list_window_size|. + + Windows can be opened vertically with |g:ale_list_vertical|. + + If you want to close the loclist window automatically when the buffer is + closed, you can set up the following |autocmd| command: > + + augroup CloseLoclistWindowGroup + autocmd! + autocmd QuitPre * if empty(&buftype) | lclose | endif + augroup END + +< +g:ale_pattern_options *g:ale_pattern_options* + + Type: |Dictionary| + Default: not set + + This option maps regular expression patterns to |Dictionary| values for + buffer variables. This option can be set to automatically configure + different settings for different files. For example: > + + " Use just ESLint for linting and fixing files which end in '.foo.js' + let g:ale_pattern_options = { + \ '\.foo\.js$': { + \ 'ale_linters': ['eslint'], + \ 'ale_fixers': ['eslint'], + \ }, + \} +< + See |b:ale_linters| and |b:ale_fixers| for information for those options. + + Filenames are matched with |match()|, and patterns depend on the |magic| + setting, unless prefixed with the special escape sequences like `'\v'`, etc. + The patterns can match any part of a filename. The absolute path of the + filename will be used for matching, taken from `expand('%:p')`. + + The options for every match for the filename will be applied, with the + pattern keys sorted in alphabetical order. Options for `'zebra'` will + override the options for `'alpha'` for a filename `alpha-zebra`. + + +g:ale_pattern_options_enabled *g:ale_pattern_options_enabled* + + Type: |Number| + Default: not set + + This option can be used for disabling pattern options. If set to `0`, ALE + will not set buffer variables per |g:ale_pattern_options|. + + +g:ale_popup_menu_enabled *g:ale_popup_menu_enabled* + + Type: |Number| + Default: `has('gui_running')` + + When this option is set to `1`, ALE will show code actions and rename + capabilities in the right click mouse menu when there's a LSP server or + tsserver available. See |ale-refactor|. + + This feature is only supported in GUI versions of Vim. + + This setting must be set to `1` before ALE is loaded for this behavior + to be enabled. See |ale-lint-settings-on-startup|. + + +g:ale_rename_tsserver_find_in_comments *g:ale_rename_tsserver_find_in_comments* + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + comments when calling |ALERename|. It can be enabled by settings the value + to `1`. + + +g:ale_rename_tsserver_find_in_strings *g:ale_rename_tsserver_find_in_strings* + + + Type: |Number| + Default: `0` + + If enabled, this option will tell tsserver to find and replace text in + strings when calling |ALERename|. It can be enabled by settings the value to + `1`. + + +g:ale_root *g:ale_root* + *b:ale_root* + + Type: |Dictionary| or |String| + Default: `{}` + + This option is used to determine the project root for a linter. If the value + is a |Dictionary|, it maps a linter to either a |String| containing the + project root or a |Funcref| to call to look up the root. The |Funcref| is + provided the buffer number as its argument. + + The buffer-specific variable may additionally be a string containing the + project root itself. + + If neither variable yields a result, a linter-specific function is invoked to + detect a project root. If this, too, yields no result, and the linter is an + LSP linter, it will not run. + + +g:ale_set_balloons *g:ale_set_balloons* + *b:ale_set_balloons* + + Type: |Number| or |String| + Default: `has('balloon_eval') && has('gui_running')` + + When this option is set to `1`, balloon messages will be displayed for + problems or hover information if available. + + Problems nearest to the line the mouse cursor is over will be displayed. If + there are no problems to show, and one of the linters is an LSP linter + supporting "Hover" information, per |ale-hover|, then brief information + about the symbol under the cursor will be displayed in a balloon. + + This option can be set to `'hover'` to only enable balloons for hover + message, so diagnostics are never shown in balloons. You may wish to + configure use this setting only in GUI Vim like so: > + + let g:ale_set_balloons = has('gui_running') ? 'hover' : 0 +< + + Balloons can be enabled for terminal versions of Vim that support balloons, + but some versions of Vim will produce strange mouse behavior when balloons + are enabled. To configure balloons for your terminal, you should first + configure your |ttymouse| setting, and then consider setting + `g:ale_set_balloons` to `1` before ALE is loaded. + + `b:ale_set_balloons` can be set to `0` to disable balloons for a buffer. + Balloons cannot be enabled for a specific buffer when not initially enabled + globally. + + Balloons will not be shown when |g:ale_enabled| or |b:ale_enabled| is `0`. + + +g:ale_set_balloons_legacy_echo *g:ale_set_balloons_legacy_echo* + *b:ale_set_balloons_legacy_echo* + Type: |Number| + Default: not set + + If set to `1`, moving your mouse over documents in Vim will make ALE ask + `tsserver` or `LSP` servers for information about the symbol where the mouse + cursor is, and print that information into Vim's echo line. This is an + option for supporting older versions of Vim which do not properly support + balloons in an asynchronous manner. + + If your version of Vim supports the |balloon_show| function, then this + option does nothing meaningful. + + +g:ale_set_highlights *g:ale_set_highlights* + + Type: |Number| + Default: `has('syntax')` + + When this option is set to `1`, highlights will be set for problems. + + ALE will use the following highlight groups for problems: + + |ALEError| - Items with `'type': 'E'` + |ALEWarning| - Items with `'type': 'W'` + |ALEInfo.| - Items with `'type': 'I'` + |ALEStyleError| - Items with `'type': 'E'` and `'sub_type': 'style'` + |ALEStyleWarning| - Items with `'type': 'W'` and `'sub_type': 'style'` + + When |g:ale_set_signs| is set to `0`, the following highlights for entire + lines will be set. + + |ALEErrorLine| - All items with `'type': 'E'` + |ALEWarningLine| - All items with `'type': 'W'` + |ALEInfoLine| - All items with `'type': 'I'` + + Vim can only highlight the characters up to the last column in a buffer for + match highlights, whereas the line highlights when signs are enabled will + run to the edge of the screen. + + Highlights can be excluded with the |g:ale_exclude_highlights| option. + + +g:ale_set_loclist *g:ale_set_loclist* + + Type: |Number| + Default: `1` + + When this option is set to `1`, the |loclist| will be populated with any + warnings and errors which are found by ALE. This feature can be used to + implement jumping between errors through typical use of |lnext| and |lprev|. + + +g:ale_set_quickfix *g:ale_set_quickfix* + + Type: |Number| + Default: `0` + + When this option is set to `1`, the |quickfix| list will be populated with + any problems which are found by ALE, instead of the |loclist|. The loclist + will never be populated when this option is on. + + Problems from every buffer ALE has checked will be included in the quickfix + list, which can be checked with |:copen|. Problems will be de-duplicated. + + This feature should not be used in combination with tools for searching for + matches and commands like |:cfdo|, as ALE will replace the quickfix list + pretty frequently. If you wish to use such tools, you should populate the + loclist or use |ALEPopulateQuickfix| instead. + + +g:ale_set_signs *g:ale_set_signs* + + Type: |Number| + Default: `has('signs')` + + When this option is set to `1`, the |sign| column will be populated with + signs marking where problems appear in the file. + + ALE will use the following highlight groups for problems: + + |ALEErrorSign| - Items with `'type': 'E'` + |ALEWarningSign| - Items with `'type': 'W'` + |ALEInfoSign| - Items with `'type': 'I'` + |ALEStyleErrorSign| - Items with `'type': 'E'` and `'sub_type': 'style'` + |ALEStyleWarningSign| - Items with `'type': 'W'` and `'sub_type': 'style'` + + In addition to the style of the signs, the style of lines where signs appear + can be configured with the following highlights: + + |ALEErrorLine| - All items with `'type': 'E'` + |ALEWarningLine| - All items with `'type': 'W'` + |ALEInfoLine| - All items with `'type': 'I'` + + With Neovim 0.3.2 or higher, ALE can use the `numhl` option to highlight the + 'number' column. It uses the following highlight groups. + + |ALEErrorSignLineNr| - Items with `'type': 'E'` + |ALEWarningSignLineNr| - Items with `'type': 'W'` + |ALEInfoSignLineNr| - Items with `'type': 'I'` + |ALEStyleErrorSignLineNr| - Items with `'type': 'E'` and `'sub_type': 'style'` + |ALEStyleWarningSignLineNr| - Items with `'type': 'W'` and `'sub_type': 'style'` + + To enable line number highlighting |g:ale_sign_highlight_linenrs| must be + set to `1` before ALE is loaded. + + The markers for the highlights can be customized with the following options: + + |g:ale_sign_error| + |g:ale_sign_warning| + |g:ale_sign_info| + |g:ale_sign_style_error| + |g:ale_sign_style_warning| + + When multiple problems exist on the same line, the signs will take + precedence in the order above, from highest to lowest. + + To limit the number of signs ALE will set, see |g:ale_max_signs|. + + +g:ale_sign_priority *g:ale_sign_priority* + + Type: |Number| + Default: `30` + + From Neovim 0.4.0 and Vim 8.1, ALE can set sign priority to all signs. The + larger this value is, the higher priority ALE signs have over other plugin + signs. See |sign-priority| for further details on how priority works. + + +g:ale_shell *g:ale_shell* + *b:ale_shell* + + Type: |String| + Default: not set + + Override the shell used by ALE for executing commands. ALE uses 'shell' by + default, but falls back in `/bin/sh` if the default shell looks like `fish` + or `pwsh`, which are not compatible with all of the commands run by ALE. The + shell specified with this option will be used even if it might not work in + all cases. + + For Windows, ALE uses `cmd` when this option isn't set. Setting this option + will apply shell escaping to the command string, even on Windows. + + NOTE: Consider setting |g:ale_shell_arguments| if this option is defined. + + +g:ale_shell_arguments *g:ale_shell_arguments* + *b:ale_shell_arguments* + + Type: |String| + Default: not set + + This option specifies the arguments to use for executing a command with a + custom shell, per |g:ale_shell|. If this option is not set, 'shellcmdflag' + will be used instead. + + +g:ale_sign_column_always *g:ale_sign_column_always* + + Type: |Number| + Default: `0` + + By default, the sign gutter will disappear when all warnings and errors have + been fixed for a file. When this option is set to `1`, the sign column will + remain open. This can be preferable if you don't want the text in your file + to move around as you edit a file. + + +g:ale_sign_error *g:ale_sign_error* + + Type: |String| + Default: `'>>'` + + The sign for errors in the sign gutter. + + +g:ale_sign_info *g:ale_sign_info* + + Type: |String| + Default: `g:ale_sign_warning` + + The sign for "info" markers in the sign gutter. + + +g:ale_sign_style_error *g:ale_sign_style_error* + + Type: |String| + Default: `g:ale_sign_error` + + The sign for style errors in the sign gutter. + + +g:ale_sign_style_warning *g:ale_sign_style_warning* + + Type: |String| + Default: `g:ale_sign_warning` + + The sign for style warnings in the sign gutter. + + +g:ale_sign_offset *g:ale_sign_offset* + + Type: |Number| + Default: `1000000` + + This variable controls offset from which numeric IDs will be generated for + new signs. Signs cannot share the same ID values, so when two Vim plugins + set signs at the same time, the IDs have to be configured such that they do + not conflict with one another. If the IDs used by ALE are found to conflict + with some other plugin, this offset value can be changed, and hopefully both + plugins will work together. See |sign-place| for more information on how + signs are set. + + +g:ale_sign_warning *g:ale_sign_warning* + + Type: |String| + Default: `'--'` + + The sign for warnings in the sign gutter. + + +g:ale_sign_highlight_linenrs *g:ale_sign_highlight_linenrs* + + Type: |Number| + Default: `0` + + When set to `1`, this option enables highlighting problems on the 'number' + column in Vim versions that support `numhl` highlights. This option must be + configured before ALE is loaded. + + +g:ale_update_tagstack *g:ale_update_tagstack* + *b:ale_update_tagstack* + Type: |Number| + Default: `1` + + This option can be set to disable updating Vim's |tagstack| automatically. + + +g:ale_type_map *g:ale_type_map* + *b:ale_type_map* + Type: |Dictionary| + Default: `{}` + + This option can be set re-map problem types for linters. Each key in the + |Dictionary| should be the name of a linter, and each value must be a + |Dictionary| mapping problem types from one type to another. The following + types are supported: + + `'E'` - `{'type': 'E'}` + `'ES'` - `{'type': 'E', 'sub_type': 'style'}` + `'W'` - `{'type': 'W'}` + `'WS'` - `{'type': 'W', 'sub_type': 'style'}` + `'I'` - `{'type': 'I'}` + + For example, if you want to turn flake8 errors into warnings, you can write + the following: > + + let g:ale_type_map = {'flake8': {'ES': 'WS', 'E': 'W'}} +< + If you wanted to turn style errors and warnings into regular errors and + warnings, you can write the following: > + + let g:ale_type_map = {'flake8': {'ES': 'E', 'WS': 'W'}} +< + Type maps can be set per-buffer with `b:ale_type_map`. + + +g:ale_use_global_executables *g:ale_use_global_executables* + + Type: |Number| + Default: not set + + This option can be set to change the default for all `_use_global` options. + This option must be set before ALE is loaded, preferably in a vimrc file. + + See |ale-integrations-local-executables| for more information on those + options. + + +g:ale_virtualtext_cursor *g:ale_virtualtext_cursor* + + Type: |Number| + Default: `0` + + When this option is set to `1`, a message will be shown when a cursor is + near a warning or error. ALE will attempt to find the warning or error at a + column nearest to the cursor when the cursor is resting on a line which + contains a warning or error. This option can be set to `0` to disable this + behavior. + When this option is set to `2`, then all warnings will be shown for the + whole buffer, regardless of if the cursor is currently positioned in that + line. + + Messages are only displayed after a short delay. See |g:ale_virtualtext_delay|. + + Messages can be prefixed prefixed with a string. See |g:ale_virtualtext_prefix|. + + ALE will use the following highlight groups for problems: + + |ALEVirtualTextError| - Items with `'type': 'E'` + |ALEVirtualTextWarning| - Items with `'type': 'W'` + |ALEVirtualTextInfo| - Items with `'type': 'I'` + |ALEVirtualTextStyleError| - Items with `'type': 'E'` and `'sub_type': 'style'` + |ALEVirtualTextStyleWarning| - Items with `'type': 'W'` and `'sub_type': 'style'` + + +g:ale_virtualtext_delay *g:ale_virtualtext_delay* + *b:ale_virtualtext_delay* + + Type: |Number| + Default: `10` + + Given any integer, this option controls the number of milliseconds before + ALE will show a message for a problem near the cursor. + + The value can be increased to decrease the amount of processing ALE will do + for files displaying a large number of problems. + + +g:ale_virtualtext_prefix *g:ale_virtualtext_prefix* + + Type: |String| + Default: `'> '` + + Prefix to be used with |g:ale_virtualtext_cursor|. + +g:ale_virtualenv_dir_names *g:ale_virtualenv_dir_names* + *b:ale_virtualenv_dir_names* + + Type: |List| + Default: `['.env', '.venv', 'env', 've-py3', 've', 'virtualenv', 'venv']` + + A list of directory names to be used when searching upwards from Python + files to discover virtulenv directories with. + + For directory named `'foo'`, ALE will search for `'foo/bin/activate'` + (`foo\Scripts\activate\` on Windows) in all directories on and above the + directory containing the Python file to find virtualenv paths. + + +g:ale_warn_about_trailing_blank_lines *g:ale_warn_about_trailing_blank_lines* + *b:ale_warn_about_trailing_blank_lines* + + Type: |Number| + Default: `1` + + When this option is set to `1`, warnings about trailing blank lines will be + shown. + + This option behaves similarly to |g:ale_warn_about_trailing_whitespace|. + + +g:ale_warn_about_trailing_whitespace *g:ale_warn_about_trailing_whitespace* + *b:ale_warn_about_trailing_whitespace* + + Type: |Number| + Default: `1` + + When this option is set to `1`, warnings relating to trailing whitespace on + lines will be shown. If warnings are too irritating while editing buffers, + and you have configured Vim to automatically remove trailing whitespace, + you can disable these warnings by setting this option to `0`. + + Not all linters may respect this option. If a linter does not, please file a + bug report, and it may be possible to add such support. + + This option may be configured on a per buffer basis. + + +g:ale_windows_node_executable_path *g:ale_windows_node_executable_path* + *b:ale_windows_node_executable_path* + + Type: |String| + Default: `'node.exe'` + + This variable is used as the path to the executable to use for executing + scripts with Node.js on Windows. + + For Windows, any file with a `.js` file extension needs to be executed with + the node executable explicitly. Otherwise, Windows could try and open the + scripts with other applications, like a text editor. Therefore, these + scripts are executed with whatever executable is configured with this + setting. + + +------------------------------------------------------------------------------- +6.1. Highlights *ale-highlights* + +ALEError *ALEError* + + Default: `highlight link ALEError SpellBad` + + The highlight for highlighted errors. See |g:ale_set_highlights|. + + +ALEErrorLine *ALEErrorLine* + + Default: Undefined + + The highlight for an entire line where errors appear. Only the first + line for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. + + +ALEErrorSign *ALEErrorSign* + + Default: `highlight link ALEErrorSign error` + + The highlight for error signs. See |g:ale_set_signs|. + + +ALEErrorSignLineNr *ALEErrorSignLineNr* + + Default: `highlight link ALEErrorSignLineNr CursorLineNr` + + The highlight for error signs. See |g:ale_set_signs|. + + NOTE: This highlight is only available on Neovim 0.3.2 or higher. + + +ALEInfo *ALEInfo.* + *ALEInfo-highlight* + Default: `highlight link ALEInfo ALEWarning` + + The highlight for highlighted info messages. See |g:ale_set_highlights|. + + +ALEInfoSign *ALEInfoSign* + + Default: `highlight link ALEInfoSign ALEWarningSign` + + The highlight for info message signs. See |g:ale_set_signs|. + + +ALEInfoLine *ALEInfoLine* + + Default: Undefined + + The highlight for entire lines where info messages appear. Only the first + line for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. + + +ALEInfoSignLineNr *ALEInfoSignLineNr* + + Default: `highlight link ALEInfoSignLineNr CursorLineNr` + + The highlight for error signs. See |g:ale_set_signs|. + + NOTE: This highlight is only available on Neovim 0.3.2 or higher. + + +ALEStyleError *ALEStyleError* + + Default: `highlight link ALEStyleError ALEError` + + The highlight for highlighted style errors. See |g:ale_set_highlights|. + + +ALEStyleErrorSign *ALEStyleErrorSign* + + Default: `highlight link ALEStyleErrorSign ALEErrorSign` + + The highlight for style error signs. See |g:ale_set_signs|. + + +ALEStyleErrorSignLineNr *ALEStyleErrorSignLineNr* + + Default: `highlight link ALEStyleErrorSignLineNr CursorLineNr` + + The highlight for error signs. See |g:ale_set_signs|. + + NOTE: This highlight is only available on Neovim 0.3.2 or higher. + + +ALEStyleWarning *ALEStyleWarning* + + Default: `highlight link ALEStyleWarning ALEError` + + The highlight for highlighted style warnings. See |g:ale_set_highlights|. + + +ALEStyleWarningSign *ALEStyleWarningSign* + + Default: `highlight link ALEStyleWarningSign ALEWarningSign` + + The highlight for style warning signs. See |g:ale_set_signs|. + + +ALEStyleWarningSignLineNr *ALEStyleWarningSignLineNr* + + Default: `highlight link ALEStyleWarningSignLineNr CursorLineNr` + + The highlight for error signs. See |g:ale_set_signs|. + + NOTE: This highlight is only available on Neovim 0.3.2 or higher. + + +ALEVirtualTextError *ALEVirtualTextError* + + Default: `highlight link ALEVirtualTextError ALEError` + + The highlight for virtualtext errors. See |g:ale_virtualtext_cursor|. + + +ALEVirtualTextInfo *ALEVirtualTextInfo* + + Default: `highlight link ALEVirtualTextInfo ALEVirtualTextWarning` + + The highlight for virtualtext info. See |g:ale_virtualtext_cursor|. + + +ALEVirtualTextStyleError *ALEVirtualTextStyleError* + + Default: `highlight link ALEVirtualTextStyleError ALEVirtualTextError` + + The highlight for virtualtext style errors. See |g:ale_virtualtext_cursor|. + + +ALEVirtualTextStyleWarning *ALEVirtualTextStyleWarning* + + Default: `highlight link ALEVirtualTextStyleWarning ALEVirtualTextWarning` + + The highlight for virtualtext style warnings. See |g:ale_virtualtext_cursor|. + + +ALEVirtualTextWarning *ALEVirtualTextWarning* + + Default: `highlight link ALEVirtualTextWarning ALEWarning` + + The highlight for virtualtext errors. See |g:ale_virtualtext_cursor|. + + +ALEWarning *ALEWarning* + + Default: `highlight link ALEWarning SpellCap` + + The highlight for highlighted warnings. See |g:ale_set_highlights|. + + +ALEWarningLine *ALEWarningLine* + + Default: Undefined + + The highlight for entire lines where warnings appear. Only the first line + for a problem will be highlighted. + + See |g:ale_set_signs| and |g:ale_set_highlights|. + + +ALEWarningSign *ALEWarningSign* + + Default: `highlight link ALEWarningSign todo` + + The highlight for warning signs. See |g:ale_set_signs|. + + +ALEWarningSignLineNr *ALEWarningSignLineNr* + + Default: `highlight link ALEWarningSignLineNr CursorLineNr` + + The highlight for error signs. See |g:ale_set_signs|. + + NOTE: This highlight is only available on Neovim 0.3.2 or higher. + + +=============================================================================== +7. Linter/Fixer Options *ale-integration-options* + +Linter and fixer options are documented below and in individual help files. + +Every option for programs can be set globally, or individually for each +buffer. For example, `b:ale_python_flake8_executable` will override any +values set for `g:ale_python_flake8_executable`. + + *ale-integrations-local-executables* + +Some tools will prefer to search for locally-installed executables, unless +configured otherwise. For example, the `eslint` linter will search for +various executable paths in `node_modules`. The `flake8` linter will search +for virtualenv directories. + +If you prefer to use global executables for those tools, set the relevant +`_use_global` and `_executable` options for those linters. > + + " Use the global executable with a special name for eslint. + let g:ale_javascript_eslint_executable = 'special-eslint' + let g:ale_javascript_eslint_use_global = 1 + + " Use the global executable with a special name for flake8. + let g:ale_python_flake8_executable = '/foo/bar/flake8' + let g:ale_python_flake8_use_global = 1 +< +|g:ale_use_global_executables| can be set to `1` in your vimrc file to make +ALE use global executables for all linters by default. + +The option |g:ale_virtualenv_dir_names| controls the local virtualenv paths +ALE will use to search for Python executables. + + +------------------------------------------------------------------------------- +7.1. Options for alex *ale-alex-options* + +The options for `alex` are shared between all filetypes, so options can be +configured once. + +g:ale_alex_executable *g:ale_alex_executable* + *b:ale_alex_executable* + Type: |String| + Default: `'alex'` + + See |ale-integrations-local-executables| + + +g:ale_alex_use_global *g:ale_alex_use_global* + *b:ale_alex_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.2. Options for cspell *ale-cspell-options* + +The options for `cspell` are shared between all filetypes, so options can be +configured only once. + +g:ale_cspell_executable *g:ale_cspell_executable* + *b:ale_cspell_executable* + Type: |String| + Default: `'cspell'` + + See |ale-integrations-local-executables| + + +g:ale_cspell_options *g:ale_cspell_options* + *b:ale_cspell_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to `cspell`. + + +g:ale_cspell_use_global *g:ale_cspell_use_global* + *b:ale_cspell_use_global* + Type: |Number| + Default: `get(g: 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.3. Options for dprint *ale-dprint-options* + +`dprint` is a fixer for many file types, including: (java|type)script, +json(c?), markdown, and more. See https://dprint.dev/plugins for an up-to-date +list of supported plugins and their configuration options. + +g:ale_dprint_executable *g:ale_dprint_executable* + *b:ale_dprint_executable* + Type: |String| + Default: `'dprint'` + + See |ale-integrations-local-executables| + + +g:ale_dprint_config *g:ale_dprint_config* + *b:ale_dprint_config* + Type: |String| + Default: `'dprint.json'` + + This variable can be changed to provide a config file to `dprint`. The + default is the nearest `dprint.json` searching upward from the current + buffer. + + See https://dprint.dev/config and https://plugins.dprint.dev + + +g:ale_dprint_options *g:ale_dprint_options* + *b:ale_dprint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to `dprint`. + + +g:ale_dprint_use_global *g:ale_dprint_use_global* + *b:ale_dprint_use_global* + Type: |Number| + Default: `get(g: 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.4. Options for languagetool *ale-languagetool-options* + +g:ale_languagetool_executable *g:ale_languagetool_executable* + *b:ale_languagetool_executable* + + Type: |String| + Default: `'languagetool'` + + The executable to run for languagetool. + + +g:ale_languagetool_options *g:ale_languagetool_options* + *b:ale_languagetool_options* + Type: |String| + Default: `'--autoDetect'` + + This variable can be set to pass additional options to languagetool. + + +------------------------------------------------------------------------------- +7.5. Options for write-good *ale-write-good-options* + +The options for `write-good` are shared between all filetypes, so options can +be configured once. + +g:ale_writegood_executable *g:ale_writegood_executable* + *b:ale_writegood_executable* + Type: |String| + Default: `'writegood'` + + See |ale-integrations-local-executables| + + +g:ale_writegood_options *g:ale_writegood_options* + *b:ale_writegood_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to writegood. + + +g:ale_writegood_use_global *g:ale_writegood_use_global* + *b:ale_writegood_use_global* + Type: |Number| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +------------------------------------------------------------------------------- +7.6. Other Linter/Fixer Options *ale-other-integration-options* + +ALE supports a very wide variety of tools. Other linter or fixer options are +documented in additional help files. + + ada.....................................|ale-ada-options| + cspell................................|ale-ada-cspell| + gcc...................................|ale-ada-gcc| + gnatpp................................|ale-ada-gnatpp| + ada-language-server...................|ale-ada-language-server| + ansible.................................|ale-ansible-options| + ansible-lint..........................|ale-ansible-ansible-lint| + apkbuild................................|ale-apkbuild-options| + apkbuild-lint.........................|ale-apkbuild-apkbuild-lint| + secfixes-check........................|ale-apkbuild-secfixes-check| + asciidoc................................|ale-asciidoc-options| + cspell................................|ale-asciidoc-cspell| + write-good............................|ale-asciidoc-write-good| + textlint..............................|ale-asciidoc-textlint| + asm.....................................|ale-asm-options| + gcc...................................|ale-asm-gcc| + avra....................................|ale-avra-options| + avra..................................|ale-avra-avra| + awk.....................................|ale-awk-options| + gawk..................................|ale-awk-gawk| + bats....................................|ale-bats-options| + shellcheck............................|ale-bats-shellcheck| + bazel...................................|ale-bazel-options| + buildifier............................|ale-bazel-buildifier| + bib.....................................|ale-bib-options| + bibclean..............................|ale-bib-bibclean| + bicep...................................|ale-bicep-options| + bicep.................................|ale-bicep-bicep| + bitbake.................................|ale-bitbake-options| + oelint-adv............................|ale-bitbake-oelint_adv| + c.......................................|ale-c-options| + astyle................................|ale-c-astyle| + cc....................................|ale-c-cc| + ccls..................................|ale-c-ccls| + clangd................................|ale-c-clangd| + clang-format..........................|ale-c-clangformat| + clangtidy.............................|ale-c-clangtidy| + cppcheck..............................|ale-c-cppcheck| + cquery................................|ale-c-cquery| + cspell................................|ale-c-cspell| + flawfinder............................|ale-c-flawfinder| + uncrustify............................|ale-c-uncrustify| + cairo...................................|ale-cairo-options| + starknet..............................|ale-cairo-starknet| + chef....................................|ale-chef-options| + cookstyle.............................|ale-chef-cookstyle| + foodcritic............................|ale-chef-foodcritic| + clojure.................................|ale-clojure-options| + clj-kondo.............................|ale-clojure-clj-kondo| + joker.................................|ale-clojure-joker| + cloudformation..........................|ale-cloudformation-options| + cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| + cmake...................................|ale-cmake-options| + cmakelint.............................|ale-cmake-cmakelint| + cmake-lint............................|ale-cmake-cmake-lint| + cmake-format..........................|ale-cmake-cmakeformat| + cpp.....................................|ale-cpp-options| + astyle................................|ale-cpp-astyle| + cc....................................|ale-cpp-cc| + ccls..................................|ale-cpp-ccls| + clangcheck............................|ale-cpp-clangcheck| + clangd................................|ale-cpp-clangd| + clang-format..........................|ale-cpp-clangformat| + clangtidy.............................|ale-cpp-clangtidy| + clazy.................................|ale-cpp-clazy| + cppcheck..............................|ale-cpp-cppcheck| + cpplint...............................|ale-cpp-cpplint| + cquery................................|ale-cpp-cquery| + cspell................................|ale-cpp-cspell| + flawfinder............................|ale-cpp-flawfinder| + uncrustify............................|ale-cpp-uncrustify| + c#......................................|ale-cs-options| + csc...................................|ale-cs-csc| + cspell................................|ale-cs-cspell| + dotnet-format.........................|ale-cs-dotnet-format| + mcs...................................|ale-cs-mcs| + mcsc..................................|ale-cs-mcsc| + uncrustify............................|ale-cs-uncrustify| + css.....................................|ale-css-options| + cspell................................|ale-css-cspell| + css-beautify..........................|ale-css-css-beautify| + fecs..................................|ale-css-fecs| + prettier..............................|ale-css-prettier| + stylelint.............................|ale-css-stylelint| + vscodecss.............................|ale-css-vscode| + cuda....................................|ale-cuda-options| + nvcc..................................|ale-cuda-nvcc| + clangd................................|ale-cuda-clangd| + clang-format..........................|ale-cuda-clangformat| + d.......................................|ale-d-options| + dfmt..................................|ale-d-dfmt| + dls...................................|ale-d-dls| + uncrustify............................|ale-d-uncrustify| + dafny...................................|ale-dafny-options| + dafny.................................|ale-dafny-dafny| + dart....................................|ale-dart-options| + analysis_server.......................|ale-dart-analysis_server| + dart-analyze..........................|ale-dart-analyze| + dart-format...........................|ale-dart-format| + dartfmt...............................|ale-dart-dartfmt| + desktop.................................|ale-desktop-options| + desktop-file-validate.................|ale-desktop-desktop-file-validate| + dhall...................................|ale-dhall-options| + dhall-format..........................|ale-dhall-format| + dhall-freeze..........................|ale-dhall-freeze| + dhall-lint............................|ale-dhall-lint| + dockerfile..............................|ale-dockerfile-options| + dockerfile_lint.......................|ale-dockerfile-dockerfile_lint| + dprint................................|ale-dockerfile-dprint| + hadolint..............................|ale-dockerfile-hadolint| + elixir..................................|ale-elixir-options| + mix...................................|ale-elixir-mix| + mix_format............................|ale-elixir-mix-format| + dialyxir..............................|ale-elixir-dialyxir| + elixir-ls.............................|ale-elixir-elixir-ls| + credo.................................|ale-elixir-credo| + cspell................................|ale-elixir-cspell| + elm.....................................|ale-elm-options| + elm-format............................|ale-elm-elm-format| + elm-ls................................|ale-elm-elm-ls| + elm-make..............................|ale-elm-elm-make| + erlang..................................|ale-erlang-options| + dialyzer..............................|ale-erlang-dialyzer| + elvis.................................|ale-erlang-elvis| + erlang_ls.............................|ale-erlang-erlang_ls| + erlc..................................|ale-erlang-erlc| + erlfmt................................|ale-erlang-erlfmt| + syntaxerl.............................|ale-erlang-syntaxerl| + eruby...................................|ale-eruby-options| + erblint...............................|ale-eruby-erblint| + ruumba................................|ale-eruby-ruumba| + fish....................................|ale-fish-options| + fish_indent...........................|ale-fish-fish_indent| + fortran.................................|ale-fortran-options| + gcc...................................|ale-fortran-gcc| + language_server.......................|ale-fortran-language-server| + fountain................................|ale-fountain-options| + fusionscript............................|ale-fuse-options| + fusion-lint...........................|ale-fuse-fusionlint| + git commit..............................|ale-gitcommit-options| + gitlint...............................|ale-gitcommit-gitlint| + glsl....................................|ale-glsl-options| + glslang...............................|ale-glsl-glslang| + glslls................................|ale-glsl-glslls| + go......................................|ale-go-options| + bingo.................................|ale-go-bingo| + cspell................................|ale-go-cspell| + gobuild...............................|ale-go-gobuild| + gofmt.................................|ale-go-gofmt| + gofumpt...............................|ale-go-gofumpt| + golangci-lint.........................|ale-go-golangci-lint| + golangserver..........................|ale-go-golangserver| + golines...............................|ale-go-golines| + golint................................|ale-go-golint| + gometalinter..........................|ale-go-gometalinter| + gopls.................................|ale-go-gopls| + govet.................................|ale-go-govet| + revive................................|ale-go-revive| + staticcheck...........................|ale-go-staticcheck| + graphql.................................|ale-graphql-options| + eslint................................|ale-graphql-eslint| + gqlint................................|ale-graphql-gqlint| + prettier..............................|ale-graphql-prettier| + hack....................................|ale-hack-options| + hack..................................|ale-hack-hack| + hackfmt...............................|ale-hack-hackfmt| + hhast.................................|ale-hack-hhast| + handlebars..............................|ale-handlebars-options| + prettier..............................|ale-handlebars-prettier| + ember-template-lint...................|ale-handlebars-embertemplatelint| + haskell.................................|ale-haskell-options| + brittany..............................|ale-haskell-brittany| + cspell................................|ale-haskell-cspell| + floskell..............................|ale-haskell-floskell| + ghc...................................|ale-haskell-ghc| + ghc-mod...............................|ale-haskell-ghc-mod| + cabal-ghc.............................|ale-haskell-cabal-ghc| + hdevtools.............................|ale-haskell-hdevtools| + hfmt..................................|ale-haskell-hfmt| + hindent...............................|ale-haskell-hindent| + hlint.................................|ale-haskell-hlint| + hls...................................|ale-haskell-hls| + stack-build...........................|ale-haskell-stack-build| + stack-ghc.............................|ale-haskell-stack-ghc| + stylish-haskell.......................|ale-haskell-stylish-haskell| + hie...................................|ale-haskell-hie| + ormolu................................|ale-haskell-ormolu| + hcl.....................................|ale-hcl-options| + packer-fmt............................|ale-hcl-packer-fmt| + terraform-fmt.........................|ale-hcl-terraform-fmt| + help....................................|ale-help-options| + cspell................................|ale-help-cspell| + html....................................|ale-html-options| + angular...............................|ale-html-angular| + cspell................................|ale-html-cspell| + fecs..................................|ale-html-fecs| + html-beautify.........................|ale-html-beautify| + htmlhint..............................|ale-html-htmlhint| + prettier..............................|ale-html-prettier| + stylelint.............................|ale-html-stylelint| + tidy..................................|ale-html-tidy| + vscodehtml............................|ale-html-vscode| + write-good............................|ale-html-write-good| + idris...................................|ale-idris-options| + idris.................................|ale-idris-idris| + ink.....................................|ale-ink-options| + ink-language-server...................|ale-ink-language-server| + inko....................................|ale-inko-options| + inko..................................|ale-inko-inko| + ispc....................................|ale-ispc-options| + ispc..................................|ale-ispc-ispc| + java....................................|ale-java-options| + checkstyle............................|ale-java-checkstyle| + cspell................................|ale-java-cspell| + javac.................................|ale-java-javac| + google-java-format....................|ale-java-google-java-format| + pmd...................................|ale-java-pmd| + javalsp...............................|ale-java-javalsp| + eclipselsp............................|ale-java-eclipselsp| + uncrustify............................|ale-java-uncrustify| + javascript..............................|ale-javascript-options| + cspell................................|ale-javascript-cspell| + deno..................................|ale-javascript-deno| + dprint................................|ale-javascript-dprint| + eslint................................|ale-javascript-eslint| + fecs..................................|ale-javascript-fecs| + flow..................................|ale-javascript-flow| + importjs..............................|ale-javascript-importjs| + jscs..................................|ale-javascript-jscs| + jshint................................|ale-javascript-jshint| + prettier..............................|ale-javascript-prettier| + prettier-eslint.......................|ale-javascript-prettier-eslint| + prettier-standard.....................|ale-javascript-prettier-standard| + standard..............................|ale-javascript-standard| + xo....................................|ale-javascript-xo| + json....................................|ale-json-options| + cspell................................|ale-json-cspell| + dprint................................|ale-json-dprint| + eslint................................|ale-json-eslint| + fixjson...............................|ale-json-fixjson| + jsonlint..............................|ale-json-jsonlint| + jq....................................|ale-json-jq| + prettier..............................|ale-json-prettier| + spectral..............................|ale-json-spectral| + vscodejson............................|ale-json-vscode| + jsonc...................................|ale-jsonc-options| + eslint................................|ale-jsonc-eslint| + jsonnet.................................|ale-jsonnet-options| + jsonnetfmt............................|ale-jsonnet-jsonnetfmt| + jsonnet-lint..........................|ale-jsonnet-jsonnet-lint| + json5...................................|ale-json5-options| + eslint................................|ale-json5-eslint| + julia...................................|ale-julia-options| + languageserver........................|ale-julia-languageserver| + kotlin..................................|ale-kotlin-options| + kotlinc...............................|ale-kotlin-kotlinc| + ktlint................................|ale-kotlin-ktlint| + languageserver........................|ale-kotlin-languageserver| + latex...................................|ale-latex-options| + cspell................................|ale-latex-cspell| + write-good............................|ale-latex-write-good| + textlint..............................|ale-latex-textlint| + less....................................|ale-less-options| + lessc.................................|ale-less-lessc| + prettier..............................|ale-less-prettier| + stylelint.............................|ale-less-stylelint| + llvm....................................|ale-llvm-options| + llc...................................|ale-llvm-llc| + lua.....................................|ale-lua-options| + cspell................................|ale-lua-cspell| + lua-format............................|ale-lua-lua-format| + luac..................................|ale-lua-luac| + luacheck..............................|ale-lua-luacheck| + luafmt................................|ale-lua-luafmt| + selene................................|ale-lua-selene| + stylua................................|ale-lua-stylua| + make....................................|ale-make-options| + checkmake.............................|ale-make-checkmake| + markdown................................|ale-markdown-options| + cspell................................|ale-markdown-cspell| + dprint................................|ale-markdown-dprint| + markdownlint..........................|ale-markdown-markdownlint| + mdl...................................|ale-markdown-mdl| + pandoc................................|ale-markdown-pandoc| + prettier..............................|ale-markdown-prettier| + remark-lint...........................|ale-markdown-remark-lint| + textlint..............................|ale-markdown-textlint| + write-good............................|ale-markdown-write-good| + mercury.................................|ale-mercury-options| + mmc...................................|ale-mercury-mmc| + nasm....................................|ale-nasm-options| + nasm..................................|ale-nasm-nasm| + nim.....................................|ale-nim-options| + nimcheck..............................|ale-nim-nimcheck| + nimlsp................................|ale-nim-nimlsp| + nimpretty.............................|ale-nim-nimpretty| + nix.....................................|ale-nix-options| + nixfmt................................|ale-nix-nixfmt| + nixpkgs-fmt...........................|ale-nix-nixpkgs-fmt| + statix................................|ale-nix-statix| + nroff...................................|ale-nroff-options| + write-good............................|ale-nroff-write-good| + objc....................................|ale-objc-options| + clang.................................|ale-objc-clang| + clangd................................|ale-objc-clangd| + uncrustify............................|ale-objc-uncrustify| + ccls..................................|ale-objc-ccls| + objcpp..................................|ale-objcpp-options| + clang.................................|ale-objcpp-clang| + clangd................................|ale-objcpp-clangd| + uncrustify............................|ale-objcpp-uncrustify| + ocaml...................................|ale-ocaml-options| + dune..................................|ale-ocaml-dune| + merlin................................|ale-ocaml-merlin| + ocamllsp..............................|ale-ocaml-ocamllsp| + ols...................................|ale-ocaml-ols| + ocamlformat...........................|ale-ocaml-ocamlformat| + ocp-indent............................|ale-ocaml-ocp-indent| + openapi.................................|ale-openapi-options| + ibm_validator.........................|ale-openapi-ibm-validator| + prettier..............................|ale-openapi-prettier| + yamllint..............................|ale-openapi-yamllint| + openscad................................|ale-openscad-options| + sca2d.................................|ale-openscad-sca2d| + packer..................................|ale-packer-options| + packer-fmt-fixer......................|ale-packer-fmt-fixer| + pascal..................................|ale-pascal-options| + ptop..................................|ale-pascal-ptop| + pawn....................................|ale-pawn-options| + uncrustify............................|ale-pawn-uncrustify| + perl....................................|ale-perl-options| + perl..................................|ale-perl-perl| + perlcritic............................|ale-perl-perlcritic| + perltidy..............................|ale-perl-perltidy| + perl6...................................|ale-perl6-options| + perl6.................................|ale-perl6-perl6| + php.....................................|ale-php-options| + cspell................................|ale-php-cspell| + langserver............................|ale-php-langserver| + phan..................................|ale-php-phan| + phpcbf................................|ale-php-phpcbf| + phpcs.................................|ale-php-phpcs| + phpmd.................................|ale-php-phpmd| + phpstan...............................|ale-php-phpstan| + psalm.................................|ale-php-psalm| + php-cs-fixer..........................|ale-php-php-cs-fixer| + php...................................|ale-php-php| + pint..................................|ale-php-pint| + tlint.................................|ale-php-tlint| + intelephense..........................|ale-php-intelephense| + po......................................|ale-po-options| + write-good............................|ale-po-write-good| + pod.....................................|ale-pod-options| + write-good............................|ale-pod-write-good| + pony....................................|ale-pony-options| + ponyc.................................|ale-pony-ponyc| + powershell..............................|ale-powershell-options| + cspell................................|ale-powershell-cspell| + powershell............................|ale-powershell-powershell| + psscriptanalyzer......................|ale-powershell-psscriptanalyzer| + prolog..................................|ale-prolog-options| + swipl.................................|ale-prolog-swipl| + proto...................................|ale-proto-options| + buf-format............................|ale-proto-buf-format| + buf-lint..............................|ale-proto-buf-lint| + protoc-gen-lint.......................|ale-proto-protoc-gen-lint| + protolint.............................|ale-proto-protolint| + pug.....................................|ale-pug-options| + puglint...............................|ale-pug-puglint| + puppet..................................|ale-puppet-options| + puppet................................|ale-puppet-puppet| + puppetlint............................|ale-puppet-puppetlint| + puppet-languageserver.................|ale-puppet-languageserver| + purescript..............................|ale-purescript-options| + purescript-language-server............|ale-purescript-language-server| + purs-tidy.............................|ale-purescript-tidy| + purty.................................|ale-purescript-purty| + pyrex (cython)..........................|ale-pyrex-options| + cython................................|ale-pyrex-cython| + python..................................|ale-python-options| + autoflake.............................|ale-python-autoflake| + autoimport............................|ale-python-autoimport| + autopep8..............................|ale-python-autopep8| + bandit................................|ale-python-bandit| + black.................................|ale-python-black| + cspell................................|ale-python-cspell| + flake8................................|ale-python-flake8| + flakehell.............................|ale-python-flakehell| + isort.................................|ale-python-isort| + mypy..................................|ale-python-mypy| + prospector............................|ale-python-prospector| + pycodestyle...........................|ale-python-pycodestyle| + pydocstyle............................|ale-python-pydocstyle| + pyflakes..............................|ale-python-pyflakes| + pyflyby...............................|ale-python-pyflyby| + pylama................................|ale-python-pylama| + pylint................................|ale-python-pylint| + pylsp.................................|ale-python-pylsp| + pyre..................................|ale-python-pyre| + pyright...............................|ale-python-pyright| + reorder-python-imports................|ale-python-reorder_python_imports| + ruff..................................|ale-python-ruff| + unimport..............................|ale-python-unimport| + vulture...............................|ale-python-vulture| + yapf..................................|ale-python-yapf| + qml.....................................|ale-qml-options| + qmlfmt................................|ale-qml-qmlfmt| + r.......................................|ale-r-options| + languageserver........................|ale-r-languageserver| + lintr.................................|ale-r-lintr| + styler................................|ale-r-styler| + reasonml................................|ale-reasonml-options| + merlin................................|ale-reasonml-merlin| + ols...................................|ale-reasonml-ols| + reason-language-server................|ale-reasonml-language-server| + refmt.................................|ale-reasonml-refmt| + rego....................................|ale-rego-options| + cspell................................|ale-rego-cspell| + opacheck..............................|ale-rego-opa-check| + opafmt................................|ale-rego-opa-fmt-fixer| + restructuredtext........................|ale-restructuredtext-options| + cspell................................|ale-restructuredtext-cspell| + textlint..............................|ale-restructuredtext-textlint| + write-good............................|ale-restructuredtext-write-good| + robot...................................|ale-robot-options| + rflint................................|ale-robot-rflint| + ruby....................................|ale-ruby-options| + brakeman..............................|ale-ruby-brakeman| + cspell................................|ale-ruby-cspell| + debride...............................|ale-ruby-debride| + prettier..............................|ale-ruby-prettier| + rails_best_practices..................|ale-ruby-rails_best_practices| + reek..................................|ale-ruby-reek| + rubocop...............................|ale-ruby-rubocop| + ruby..................................|ale-ruby-ruby| + rufo..................................|ale-ruby-rufo| + solargraph............................|ale-ruby-solargraph| + sorbet................................|ale-ruby-sorbet| + standardrb............................|ale-ruby-standardrb| + syntax_tree...........................|ale-ruby-syntax_tree| + rust....................................|ale-rust-options| + analyzer..............................|ale-rust-analyzer| + cargo.................................|ale-rust-cargo| + cspell................................|ale-rust-cspell| + rls...................................|ale-rust-rls| + rustc.................................|ale-rust-rustc| + rustfmt...............................|ale-rust-rustfmt| + salt....................................|ale-salt-options| + salt-lint.............................|ale-salt-salt-lint| + sass....................................|ale-sass-options| + sasslint..............................|ale-sass-sasslint| + stylelint.............................|ale-sass-stylelint| + scala...................................|ale-scala-options| + cspell................................|ale-scala-cspell| + metals................................|ale-scala-metals| + sbtserver.............................|ale-scala-sbtserver| + scalafmt..............................|ale-scala-scalafmt| + scalastyle............................|ale-scala-scalastyle| + scss....................................|ale-scss-options| + prettier..............................|ale-scss-prettier| + sasslint..............................|ale-scss-sasslint| + stylelint.............................|ale-scss-stylelint| + sh......................................|ale-sh-options| + bashate...............................|ale-sh-bashate| + cspell................................|ale-sh-cspell| + sh-language-server....................|ale-sh-language-server| + shell.................................|ale-sh-shell| + shellcheck............................|ale-sh-shellcheck| + shfmt.................................|ale-sh-shfmt| + sml.....................................|ale-sml-options| + smlnj.................................|ale-sml-smlnj| + solidity................................|ale-solidity-options| + solc..................................|ale-solidity-solc| + solhint...............................|ale-solidity-solhint| + solium................................|ale-solidity-solium| + spec....................................|ale-spec-options| + rpmlint...............................|ale-spec-rpmlint| + sql.....................................|ale-sql-options| + dprint................................|ale-sql-dprint| + pgformatter...........................|ale-sql-pgformatter| + sqlfmt................................|ale-sql-sqlfmt| + sqlformat.............................|ale-sql-sqlformat| + stylus..................................|ale-stylus-options| + stylelint.............................|ale-stylus-stylelint| + sugarss.................................|ale-sugarss-options| + stylelint.............................|ale-sugarss-stylelint| + svelte..................................|ale-svelte-options| + prettier..............................|ale-svelte-prettier| + svelteserver..........................|ale-svelte-svelteserver| + swift...................................|ale-swift-options| + apple-swift-format....................|ale-swift-apple-swift-format| + cspell................................|ale-swift-cspell| + sourcekitlsp..........................|ale-swift-sourcekitlsp| + systemd.................................|ale-systemd-options| + systemd-analyze.......................|ale-systemd-analyze| + tcl.....................................|ale-tcl-options| + nagelfar..............................|ale-tcl-nagelfar| + terraform...............................|ale-terraform-options| + checkov...............................|ale-terraform-checkov| + terraform-fmt-fixer...................|ale-terraform-fmt-fixer| + terraform.............................|ale-terraform-terraform| + terraform-ls..........................|ale-terraform-terraform-ls| + terraform-lsp.........................|ale-terraform-terraform-lsp| + tflint................................|ale-terraform-tflint| + tfsec.................................|ale-terraform-tfsec| + tex.....................................|ale-tex-options| + chktex................................|ale-tex-chktex| + cspell................................|ale-tex-cspell| + lacheck...............................|ale-tex-lacheck| + latexindent...........................|ale-tex-latexindent| + texlab................................|ale-tex-texlab| + texinfo.................................|ale-texinfo-options| + cspell................................|ale-texinfo-cspell| + write-good............................|ale-texinfo-write-good| + text....................................|ale-text-options| + cspell................................|ale-text-cspell| + textlint..............................|ale-text-textlint| + write-good............................|ale-text-write-good| + thrift..................................|ale-thrift-options| + thrift................................|ale-thrift-thrift| + thriftcheck...........................|ale-thrift-thriftcheck| + toml....................................|ale-toml-options| + dprint................................|ale-toml-dprint| + typescript..............................|ale-typescript-options| + cspell................................|ale-typescript-cspell| + deno..................................|ale-typescript-deno| + dprint................................|ale-typescript-dprint| + eslint................................|ale-typescript-eslint| + prettier..............................|ale-typescript-prettier| + standard..............................|ale-typescript-standard| + tslint................................|ale-typescript-tslint| + tsserver..............................|ale-typescript-tsserver| + xo....................................|ale-typescript-xo| + v.......................................|ale-v-options| + v.....................................|ale-v-v| + vfmt..................................|ale-v-vfmt| + vala....................................|ale-vala-options| + uncrustify............................|ale-vala-uncrustify| + verilog/systemverilog...................|ale-verilog-options| + hdl-checker...........................|ale-verilog-hdl-checker| + iverilog..............................|ale-verilog-iverilog| + verilator.............................|ale-verilog-verilator| + vlog..................................|ale-verilog-vlog| + xvlog.................................|ale-verilog-xvlog| + yosys.................................|ale-verilog-yosys| + vhdl....................................|ale-vhdl-options| + ghdl..................................|ale-vhdl-ghdl| + hdl-checker...........................|ale-vhdl-hdl-checker| + vcom..................................|ale-vhdl-vcom| + xvhdl.................................|ale-vhdl-xvhdl| + vim help................................|ale-vim-help-options| + write-good............................|ale-vim-help-write-good| + vim.....................................|ale-vim-options| + vimls.................................|ale-vim-vimls| + vint..................................|ale-vim-vint| + vue.....................................|ale-vue-options| + cspell................................|ale-vue-cspell| + prettier..............................|ale-vue-prettier| + vls...................................|ale-vue-vls| + volar.................................|ale-vue-volar| + wgsl....................................|ale-wgsl-options| + naga..................................|ale-wgsl-naga| + xhtml...................................|ale-xhtml-options| + cspell................................|ale-xhtml-cspell| + write-good............................|ale-xhtml-write-good| + xml.....................................|ale-xml-options| + xmllint...............................|ale-xml-xmllint| + yaml....................................|ale-yaml-options| + actionlint............................|ale-yaml-actionlint| + circleci..............................|ale-yaml-circleci| + prettier..............................|ale-yaml-prettier| + spectral..............................|ale-yaml-spectral| + swaglint..............................|ale-yaml-swaglint| + yaml-language-server..................|ale-yaml-language-server| + yamlfix...............................|ale-yaml-yamlfix| + yamllint..............................|ale-yaml-yamllint| + gitlablint............................|ale-yaml-gitlablint| + yang....................................|ale-yang-options| + yang-lsp..............................|ale-yang-lsp| + zeek....................................|ale-zeek-options| + zeek..................................|ale-zeek-zeek| + zig.....................................|ale-zig-options| + zigfmt................................|ale-zig-zigfmt| + zls...................................|ale-zig-zls| + + +=============================================================================== +8. Commands/Keybinds *ale-commands* + +ALEComplete *ALEComplete* + + Manually trigger LSP autocomplete and show the menu. Works only when called + from insert mode. > + + inoremap :ALEComplete +< + A plug mapping `(ale_complete)` is defined for this command. > + + imap (ale_complete) +< +ALEDocumentation *ALEDocumentation* + + Similar to the |ALEHover| command, retrieve documentation information for + the symbol at the cursor. Documentation data will always be shown in a + preview window, no matter how small the documentation content is. + + NOTE: This command is only available for `tsserver`. + + A plug mapping `(ale_documentation)` is defined for this command. + + +ALEFindReferences *ALEFindReferences* + + Find references in the codebase for the symbol under the cursor using the + enabled LSP linters for the buffer. ALE will display a preview window + containing the results if some references are found. + + The window can be navigated using the usual Vim navigation commands. The + Enter key (``) can be used to jump to a referencing location, or the `t` + key can be used to jump to the location in a new tab. + + The locations opened in different ways using the following variations. + + `:ALEFindReferences -tab` - Open the location in a new tab. + `:ALEFindReferences -split` - Open the location in a horizontal split. + `:ALEFindReferences -vsplit` - Open the location in a vertical split. + `:ALEFindReferences -quickfix` - Put the locations into quickfix list. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. This option has no effect if `-quickfix` is used. + + The selection can be opened again with the |ALERepeatSelection| command. + + You can jump back to the position you were at before going to a reference of + something with jump motions like CTRL-O. See |jump-motions|. + + A plug mapping `(ale_find_references)` is defined for this command. + You can define additional plug mapping with any additional options you want + like so: > + + nnoremap (my_mapping) :ALEFindReferences -relative +< + +ALEFix *ALEFix* + + Fix problems with the current buffer. See |ale-fix| for more information. + + If the command is run with a bang (`:ALEFix!`), all warnings will be + suppressed, including warnings about no fixers being defined, and warnings + about not being able to apply fixes to a file because it has been changed. + + A plug mapping `(ale_fix)` is defined for this command. + + +ALEFixSuggest *ALEFixSuggest* + + Suggest tools that can be used to fix problems in the current buffer. + + See |ale-fix| for more information. + + +ALEGoToDefinition `` *ALEGoToDefinition* + + Jump to the definition of a symbol under the cursor using the enabled LSP + linters for the buffer. ALE will jump to a definition if an LSP server + provides a location to jump to. Otherwise, ALE will do nothing. + + The locations opened in different ways using the following variations. + + `:ALEGoToDefinition -tab` - Open the location in a new tab. + `:ALEGoToDefinition -split` - Open the location in a horizontal split. + `:ALEGoToDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can jump back to the position you were at before going to the definition + of something with jump motions like CTRL-O. See |jump-motions|. + + You should consider using the 'hidden' option in combination with this + command. Otherwise, Vim will refuse to leave the buffer you're jumping from + unless you have saved your edits. + + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_definition)` - `:ALEGoToDefinition` + `(ale_go_to_definition_in_tab)` - `:ALEGoToDefinition -tab` + `(ale_go_to_definition_in_split)` - `:ALEGoToDefinition -split` + `(ale_go_to_definition_in_vsplit)` - `:ALEGoToDefinition -vsplit` + + +ALEGoToTypeDefinition *ALEGoToTypeDefinition* + + This works similar to |ALEGoToDefinition| but instead jumps to the + definition of a type of a symbol under the cursor. ALE will jump to a + definition if an LSP server provides a location to jump to. Otherwise, ALE + will do nothing. + + The locations opened in different ways using the following variations. + + `:ALEGoToTypeDefinition -tab` - Open the location in a new tab. + `:ALEGoToTypeDefinition -split` - Open the location in a horizontal split. + `:ALEGoToTypeDefinition -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can jump back to the position you were at before going to the definition + of something with jump motions like CTRL-O. See |jump-motions|. + + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_type_definition)` - `:ALEGoToTypeDefinition` + `(ale_go_to_type_definition_in_tab)` - `:ALEGoToTypeDefinition -tab` + `(ale_go_to_type_definition_in_split)` - `:ALEGoToTypeDefinition -split` + `(ale_go_to_type_definition_in_vsplit)` - `:ALEGoToTypeDefinition -vsplit` + + +ALEGoToImplementation *ALEGoToImplementation* + + This works similar to |ALEGoToDefinition| but instead jumps to the + implementation of symbol under the cursor. ALE will jump to a definition if + an LSP server provides a location to jump to. Otherwise, ALE will do nothing. + + The locations opened in different ways using the following variations. + + `:ALEGoToImplementation -tab` - Open the location in a new tab. + `:ALEGoToImplementation -split` - Open the location in a horizontal split. + `:ALEGoToImplementation -vsplit` - Open the location in a vertical split. + + The default method used for navigating to a new location can be changed + by modifying |g:ale_default_navigation|. + + You can jump back to the position you were at before going to the definition + of something with jump motions like CTRL-O. See |jump-motions|. + + The following Plug mappings are defined for this command, which correspond + to the following commands. + + `(ale_go_to_implementation)` - `:ALEGoToImplementation` + `(ale_go_to_implementation_in_tab)` - `:ALEGoToImplementation -tab` + `(ale_go_to_implementation_in_split)` - `:ALEGoToImplementation -split` + `(ale_go_to_implementation_in_vsplit)` - `:ALEGoToImplementation -vsplit` + + +ALEHover *ALEHover* + + Print brief information about the symbol under the cursor, taken from any + available LSP linters. There may be a small non-blocking delay before + information is printed. + + NOTE: In Vim 8, long messages will be shown in a preview window, as Vim 8 + does not support showing a prompt to press enter to continue for long + messages from asynchronous callbacks. + + A plug mapping `(ale_hover)` is defined for this command. + + +ALEImport *ALEImport* + + Try to import a symbol using `tsserver` or a Language Server. + + ALE will look for completions for the word at the cursor which contain + additional text edits that possible insert lines to import the symbol. The + first match with additional text edits will be used, and may add other code + to the current buffer other than import lines. + + If linting is enabled, and |g:ale_lint_on_text_changed| is set to ever check + buffers when text is changed, the buffer will be checked again after changes + are made. + + A Plug mapping `(ale_import)` is defined for this command. This + mapping should only be bound for normal mode. + + +ALEOrganizeImports *ALEOrganizeImports* + + Organize imports using tsserver. Currently not implemented for LSPs. + + +ALERename *ALERename* + + Rename a symbol using `tsserver` or a Language Server. + + The symbol where the cursor is resting will be the symbol renamed, and a + prompt will open to request a new name. + + The rename operation will save all modified buffers when `set nohidden` is + set, because that disables leaving unsaved buffers in the background. See + `:help hidden` for more details. + +ALEFileRename *ALEFileRename* + + Rename a file and fix imports using `tsserver`. + +ALECodeAction *ALECodeAction* + + Apply a code action via LSP servers or `tsserver`. + + If there is an error present on a line that can be fixed, ALE will + automatically fix a line, unless there are multiple possible code fixes to + apply. + + This command can be run in visual mode apply actions, such as applicable + refactors. A menu will be shown to select code action to apply. + + +ALERepeatSelection *ALERepeatSelection* + + Repeat the last selection displayed in the preview window. + + +ALESymbolSearch `` *ALESymbolSearch* + + Search for symbols in the workspace, taken from any available LSP linters. + + The arguments provided to this command will be used as a search query for + finding symbols in the workspace, such as functions, types, etc. + + You can add `-relative` to the command to view results with relatives paths, + instead of absolute paths. + + *:ALELint* +ALELint *ALELint* + + Run ALE once for the current buffer. This command can be used to run ALE + manually, instead of automatically, if desired. + + This command will also run linters where `lint_file` is evaluates to `1`, + meaning linters which check the file instead of the Vim buffer. + + A plug mapping `(ale_lint)` is defined for this command. + + +ALELintStop *ALELintStop* + + Stop any currently running jobs for checking the current buffer. + + Any problems from previous linter results will continue to be shown. + + +ALEPopulateQuickfix *ALEPopulateQuickfix* +ALEPopulateLocList *ALEPopulateLocList* + + Manually populate the |quickfix| or |location-list| and show the + corresponding list. Useful when you have other uses for both the |quickfix| + and |location-list| and don't want them automatically populated. Be sure to + disable auto populating: > + + let g:ale_set_quickfix = 0 + let g:ale_set_loclist = 0 +< + With these settings, ALE will still run checking and display it with signs, + highlighting, and other output described in |ale-lint-file-linters|. + +ALEPrevious *ALEPrevious* +ALEPreviousWrap *ALEPreviousWrap* +ALENext *ALENext* +ALENextWrap *ALENextWrap* +ALEFirst *ALEFirst* +ALELast *ALELast* + *ale-navigation-commands* + + Move between warnings or errors in a buffer. ALE will only navigate between + the errors or warnings it generated, even if both |g:ale_set_quickfix| + and |g:ale_set_loclist| are set to `0`. + + `ALEPrevious` and `ALENext` will stop at the top and bottom of a file, while + `ALEPreviousWrap` and `ALENextWrap` will wrap around the file to find + the last or first warning or error in the file, respectively. + + `ALEPrevious` and `ALENext` take optional flags arguments to custom their + behavior : + `-wrap` enable wrapping around the file + `-error`, `-warning` and `-info` enable jumping to errors, warnings or infos + respectively, ignoring anything else. They are mutually exclusive and if + several are provided the priority is the following: error > warning > info. + `-style` and `-nostyle` allow you to jump respectively to style error or + warning and to not style error or warning. They also are mutually + exclusive and nostyle has priority over style. + + Flags can be combined to create create custom jumping. Thus you can use + ":ALENext -wrap -error -nosyle" to jump to the next error which is not a + style error while going back to the beginning of the file if needed. + + `ALEFirst` goes to the first error or warning in the buffer, while `ALELast` + goes to the last one. + + The following || mappings are defined for the commands: > + (ale_previous) - ALEPrevious + (ale_previous_wrap) - ALEPreviousWrap + (ale_previous_error) - ALEPrevious -error + (ale_previous_wrap_error) - ALEPrevious -wrap -error + (ale_previous_warning) - ALEPrevious -warning + (ale_previous_wrap_warning) - ALEPrevious -wrap -warning + (ale_next) - ALENext + (ale_next_wrap) - ALENextWrap + (ale_next_error) - ALENext -error + (ale_next_wrap_error) - ALENext -wrap -error + (ale_next_warning) - ALENext -warning + (ale_next_wrap_warning) - ALENext -wrap -warning + (ale_first) - ALEFirst + (ale_last) - ALELast +< + For example, these commands could be bound to the keys Ctrl + j + and Ctrl + k: > + + " Map movement through errors without wrapping. + nmap (ale_previous) + nmap (ale_next) + " OR map keys to use wrapping. + nmap (ale_previous_wrap) + nmap (ale_next_wrap) +< + +ALEToggle *ALEToggle* +ALEEnable *ALEEnable* +ALEDisable *ALEDisable* +ALEToggleBuffer *ALEToggleBuffer* +ALEEnableBuffer *ALEEnableBuffer* +ALEDisableBuffer *ALEDisableBuffer* + + `ALEToggle`, `ALEEnable`, and `ALEDisable` enable or disable ALE linting, + including all of its autocmd events, loclist items, quickfix items, signs, + current jobs, etc., globally. Executing any of these commands will change + the |g:ale_enabled| variable. + + ALE can be disabled or enabled for only a single buffer with + `ALEToggleBuffer`, `ALEEnableBuffer`, and `ALEDisableBuffer`. Disabling ALE + for a buffer will not remove autocmd events, but will prevent ALE from + checking for problems and reporting problems for whatever buffer the + `ALEDisableBuffer` or `ALEToggleBuffer` command is executed from. These + commands can be used for temporarily disabling ALE for a buffer. These + commands will modify the |b:ale_enabled| variable. + + ALE linting cannot be enabled for a single buffer when it is disabled + globally, as disabling ALE globally removes the autocmd events needed to + perform linting with. + + The following plug mappings are defined, for conveniently defining keybinds: + + |ALEToggle| - `(ale_toggle)` + |ALEEnable| - `(ale_enable)` + |ALEDisable| - `(ale_disable)` + |ALEToggleBuffer| - `(ale_toggle_buffer)` + |ALEEnableBuffer| - `(ale_enable_buffer)` + |ALEDisableBuffer| - `(ale_disable_buffer)` + + For removing problems reported by ALE, but leaving ALE enabled, see + |ALEReset| and |ALEResetBuffer|. + + *:ALEDetail* +ALEDetail *ALEDetail* + + Show the full linter message for the problem nearest to the cursor on the + given line in the preview window. The preview window can be easily closed + with the `q` key. If there is no message to show, the window will not be + opened. + + If a loclist item has a `detail` key set, the message for that key will be + preferred over `text`. See |ale-loclist-format|. + + A plug mapping `(ale_detail)` is defined for this command. + + + *:ALEInfo* +ALEInfo *ALEInfo* +ALEInfoToClipboard *ALEInfoToClipboard* + + Print runtime information about ALE, including the values of global and + buffer-local settings for ALE, the linters that are enabled, the commands + that have been run, and the output of commands. + + ALE will log the commands that are run by default. If you wish to disable + this, set |g:ale_history_enabled| to `0`. Because it could be expensive, ALE + does not remember the output of recent commands by default. Set + |g:ale_history_log_output| to `1` to enable logging of output for commands. + ALE will only log the output captured for parsing problems, etc. + + The command `:ALEInfoToClipboard` can be used to output ALEInfo directly to + your clipboard. This might not work on every machine. + + `:ALEInfoToFile` will write the ALE runtime information to a given filename. + The filename works just like |:w|. + + +ALEReset *ALEReset* +ALEResetBuffer *ALEResetBuffer* + + `ALEReset` will remove all problems reported by ALE for all buffers. + `ALEResetBuffer` will remove all problems reported for a single buffer. + + Either command will leave ALE linting enabled, so ALE will report problems + when linting is performed again. See |ale-lint| for more information. + + The following plug mappings are defined, for conveniently defining keybinds: + + |ALEReset| - `(ale_reset)` + |ALEResetBuffer| - `(ale_reset_buffer)` + + ALE can be disabled globally or for a buffer with |ALEDisable| or + |ALEDisableBuffer|. + + +ALEStopAllLSPs *ALEStopAllLSPs* + + `ALEStopAllLSPs` will close and stop all channels and jobs for all LSP-like + clients, including tsserver, remove all of the data stored for them, and + delete all of the problems found for them, updating every linted buffer. + + This command can be used when LSP clients mess up and need to be restarted. + + +=============================================================================== +9. API *ale-api* + +ALE offers a number of functions for running linters or fixers, or defining +them. The following functions are part of the publicly documented part of that +API, and should be expected to continue to work. + + +ale#Env(variable_name, value) *ale#Env()* + + Given a variable name and a string value, produce a string for including in + a command for setting environment variables. This function can be used for + building a command like so. > + + :echo string(ale#Env('VAR', 'some value') . 'command') + 'VAR=''some value'' command' # On Linux or Mac OSX + 'set VAR="some value" && command' # On Windows + + +ale#GetFilenameMappings(buffer, name) *ale#GetFilenameMappings()* + + Given a `buffer` and the `name` of either a linter for fixer, return a + |List| of two-item |List|s that describe mapping to and from the local and + foreign file systems for running a particular linter or fixer. + + See |g:ale_filename_mappings| for details on filename mapping. + + +ale#Has(feature) *ale#Has()* + + Return `1` if ALE supports a given feature, like |has()| for Vim features. + + ALE versions can be checked with version strings in the format + `ale#Has('ale-x.y.z')`, such as `ale#Has('ale-2.4.0')`. + + +ale#Pad(string) *ale#Pad()* + + Given a string or any |empty()| value, return either the string prefixed + with a single space, or an empty string. This function can be used to build + parts of a command from variables. + + +ale#Queue(delay, [linting_flag, buffer_number]) *ale#Queue()* + + Run linters for the current buffer, based on the filetype of the buffer, + with a given `delay`. A `delay` of `0` will run the linters immediately. + The linters will always be run in the background. Calling this function + again from the same buffer + + An optional `linting_flag` argument can be given. If `linting_flag` is + `'lint_file'`, then linters where the `lint_file` option evaluates to `1` + will be run. Otherwise, those linters will not be run. + + An optional `buffer_number` argument can be given for specifying the buffer + to check. The active buffer (`bufnr('')`) will be checked by default. + + *ale-cool-down* + If an exception is thrown when queuing/running ALE linters, ALE will enter + a cool down period where it will stop checking anything for a short period + of time. This is to prevent ALE from seriously annoying users if a linter + is broken, or when developing ALE itself. + + +ale#command#CreateDirectory(buffer) *ale#command#CreateDirectory()* + + Create a new temporary directory with a unique name, and manage that + directory with |ale#command#ManageDirectory()|, so it will be removed as soon + as possible. + + It is advised to only call this function from a callback function for + returning a linter command to run. + + +ale#command#CreateFile(buffer) *ale#command#CreateFile()* + + Create a new temporary file with a unique name, and manage that file with + |ale#command#ManageFile()|, so it will be removed as soon as possible. + + It is advised to only call this function from a callback function for + returning a linter command to run. + + +ale#command#Run(buffer, command, callback, [options]) *ale#command#Run()* + + Start running a job in the background, and pass the results to the given + callback later. + + This function can be used for computing the results of ALE linter or fixer + functions asynchronously with jobs. `buffer` must match the buffer being + linted or fixed, `command` must be a |String| for a shell command to + execute, `callback` must be defined as a |Funcref| to call later with the + results, and an optional |Dictionary| of `options` can be provided. + + The `callback` will receive the arguments `(buffer, output, metadata)`, + where the `buffer` will match the buffer given to the function, the `output` + will be a `List` of lines of output from the job that was run, and the + `metadata` will be a |Dictionary| with additional information about the job + that was run, including: + + `exit_code` - A |Number| with the exit code for the program that was run. + + The result of this function is either a special |Dictionary| ALE will use + for waiting for the command to finish, or `0` if the job is not started. The + The return value of the `callback` will be used as the eventual result for + whatever value is being given to ALE. For example: > + + function! s:GetCommand(buffer, output, meta) abort + " Do something with a:output here, from the foo command. + + " This is used as the command to run for linting. + return 'final command' + endfunction + + " ... + + 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} +< + The result of a callback can also be the result of another call to this + function, so that several commands can be arbitrarily chained together. For + example: > + + function! s:GetAnotherCommand(buffer, output, meta) abort + " We can finally return this command. + return 'last command' + endfunction + + function! s:GetCommand(buffer, output, meta) abort + " We can return another deferred result. + return ale#command#Run( + \ a:buffer, + \ 'second command', + \ function('s:GetAnotherCommand') + \) + endfunction + + " ... + + 'command': {b -> ale#command#Run(b, 'foo', function('s:GetCommand'))} +< + The following `options` can be provided. + + `cwd` - An optional |String| for setting the working directory + for the command, just as per |ale#linter#Define|. + + If not set, or `v:null`, the `cwd` of the last command + that spawned this one will be used. + + `output_stream` - Either `'stdout'`, `'stderr'`, `'both'`, or + `'none`' for selecting which output streams to read + lines from. + + The default is `'stdout'` + + `executable` - An executable for formatting into `%e` in the + command. If this option is not provided, formatting + commands with `%e` will not work. + + `read_buffer` - If set to `1`, the buffer will be piped into the + command. + + The default is `0`. + + `input` - When creating temporary files with `%t` or piping + text into a command `input` can be set to a |List| of + text to use instead of the buffer's text. + + `filename_mappings` - A |List| of two-item |List|s describing filename + mappings to apply for formatted filenames in the + command string, as per |g:ale_filename_mappings|. + + If the call to this function is being used for a + linter or fixer, the mappings should be provided with + this option, and can be retrieved easily with + |ale#GetFilenameMappings()|. + + The default is `[]`. + + + +ale#command#EscapeCommandPart(command_part) *ale#command#EscapeCommandPart()* + + Given a |String|, return a |String| with all `%` characters replaced with + `%%` instead. This function can be used to escape strings which are + dynamically generated for commands before handing them over to ALE, + so that ALE doesn't treat any strings with `%` formatting sequences + specially. + + +ale#command#ManageDirectory(buffer, directory) *ale#command#ManageDirectory()* + + Like |ale#command#ManageFile()|, but directories and all of their contents + will be deleted, akin to `rm -rf directory`, which could lead to loss of + data if mistakes are made. This command will also delete any temporary + filenames given to it. + + It is advised to use |ale#command#ManageFile()| instead for deleting single + files. + + +ale#command#ManageFile(buffer, filename) *ale#command#ManageFile()* + + Given a buffer number for a buffer currently running some linting or fixing + tasks and a filename, register a filename with ALE for automatic deletion + after linting or fixing is complete, or when Vim exits. + + If Vim exits suddenly, ALE will try its best to remove temporary files, but + ALE cannot guarantee with absolute certainty that the files will be removed. + It is advised to create temporary files in the operating system's managed + temporary file directory, such as with |tempname()|. + + Directory names should not be given to this function. ALE will only delete + files and symlinks given to this function. This is to prevent entire + directories from being accidentally deleted, say in cases of writing + `dir . '/' . filename` where `filename` is actually `''`, etc. ALE instead + manages directories separately with the |ale#command#ManageDirectory| function. + + +ale#completion#OmniFunc(findstart, base) *ale#completion#OmniFunc()* + + A completion function to use with 'omnifunc'. + + See |ale-completion|. + + +ale#engine#GetLoclist(buffer) *ale#engine#GetLoclist()* + + Given a buffer number, this function will return the list of problems + reported by ALE for a given buffer in the format accepted by |setqflist()|. + + A reference to the buffer's list of problems will be returned. The list must + be copied before applying |map()| or |filter()|. + + +ale#engine#IsCheckingBuffer(buffer) *ale#engine#IsCheckingBuffer()* + + Given a buffer number, returns `1` when ALE is busy checking that buffer. + + This function can be used for status lines, tab names, etc. + + +ale#fix#registry#Add(name, func, filetypes, desc, [aliases]) + *ale#fix#registry#Add()* + + Given a |String| `name` for a name to add to the registry, a |String| `func` + for a function name, a |List| `filetypes` for a list of filetypes to + set for suggestions, and a |String| `desc` for a short description of + the fixer, register a fixer in the registry. + + The `name` can then be used for |g:ale_fixers| in place of the function + name, and suggested for fixing files. + + An optional |List| of |String|s for aliases can be passed as the `aliases` + argument. These aliases can also be used for looking up a fixer function. + ALE will search for fixers in the registry first by `name`, then by their + `aliases`. + + For example to register a custom fixer for `luafmt`: > + + function! FormatLua(buffer) abort + return { + \ 'command': 'luafmt --stdin' + \} + endfunction + + execute ale#fix#registry#Add('luafmt', 'FormatLua', ['lua'], 'luafmt for lua') + + " You can now use it in g:ale_fixers + let g:ale_fixers = { + \ 'lua': ['luafmt'] + } +< + +ale#linter#Define(filetype, linter) *ale#linter#Define()* + + Given a |String| for a filetype and a |Dictionary| Describing a linter + configuration, add a linter for the given filetype. The dictionaries each + offer the following options: + + `name` The name of the linter. These names will be used by + |g:ale_linters| option for enabling/disabling + particular linters. + + This argument is required. + + `callback` A |String| or |Funcref| for a callback function + accepting two arguments (buffer, lines), for a + buffer number the output is for, and the lines of + output from a linter. + + This callback function should return a |List| of + |Dictionary| objects in the format accepted by + |setqflist()|. The |List| will be sorted by line and + then column order so it can be searched with a binary + search by in future before being passed on to the + |loclist|, etc. + + This argument is required, unless the linter is an + LSP linter. In which case, this argument must not be + defined, as LSP linters handle diagnostics + automatically. See |ale-lsp-linters|. + + If the function named does not exist, including if + the function is later deleted, ALE will behave as if + the callback returned an empty list. + + The keys for each item in the List will be handled in + the following manner: + *ale-loclist-format* + `text` - This error message is required. + `detail` - An optional, more descriptive message. + This message can be displayed with the |ALEDetail| + command instead of the message for `text`, if set. + `lnum` - The line number is required. Any strings + will be automatically converted to numbers by + using `str2nr()`. + + Line 0 will be moved to line 1, and lines beyond + the end of the file will be moved to the end. + `col` - The column number is optional and will + default to `0`. Any strings will be automatically + converted to number using `str2nr()`. + `end_col` - An optional end column number. + This key can be set to specify the column problems + end on, for improved highlighting. + `end_lnum` - An optional end line number. + This key can set along with `end_col` for + highlighting multi-line problems. + `bufnr` - This key represents the buffer number the + problems are for. This value will default to + the buffer number being checked. + + The `filename` key can be set instead of this key, + and then the eventual `bufnr` value in the final + list will either represent the number for an open + buffer or `-1` for a file not open in any buffer. + `filename` - An optional filename for the file the + problems are for. This should be an absolute path to + a file. + + Problems for files which have not yet been opened + will be set in those files after they are opened + and have been checked at least once. + + Temporary files in directories used for Vim + temporary files with `tempname()` will be assumed + to be the buffer being checked, unless the `bufnr` + key is also set with a valid number for some other + buffer. + `vcol` - Defaults to `0`. + + If set to `1`, ALE will convert virtual column + positions for `col` and `end_col` to byte column + positions. If the buffer is changed in-between + checking it and displaying the results, the + calculated byte column positions will probably be + wrong. + `type` - Defaults to `'E'`. + `nr` - Defaults to `-1`. + + Numeric error code. If `nr` is not `-1`, `code` + likely should contain the string representation of + the same value. + `code` - No default; may be unset. + + Human-readable |String| error code. + + `executable` A |String| naming the executable itself which + will be run, or a |Funcref| for a function to call + for computing the executable, accepting a buffer + number. + + The result can be computed with |ale#command#Run()|. + + This value will be used to check if the program + requested is installed or not. + + If an `executable` is not defined, the command will + be run without checking if a program is executable + first. Defining an executable path is recommended to + avoid starting too many processes. + + `command` A |String| for a command to run asynchronously, or a + |Funcref| for a function to call for computing the + command, accepting a buffer number. + + The result can be computed with |ale#command#Run()|. + + The command string can be formatted with format + markers. See |ale-command-format-strings|. + + This command will be fed the lines from the buffer to + check, and will produce the lines of output given to + the `callback`. + + `cwd` An optional |String| for setting the working + directory for the command, or a |Funcref| for a + function to call for computing the command, accepting + a buffer number. The working directory can be + specified as a format string for determining the path + dynamically. See |ale-command-format-strings|. + + To set the working directory to the directory + containing the file you're checking, you should + probably use `'%s:h'` as the option value. + + If this option is absent or the string is empty, the + `command` will be run with no determined working + directory in particular. + + The directory specified with this option will be used + as the default working directory for all commands run + in a chain with |ale#command#Run()|, unless otherwise + specified. + + `output_stream` A |String| for the output stream the lines of output + should be read from for the command which is run. The + accepted values are `'stdout'`, `'stderr'`, and + `'both'`. This argument defaults to `'stdout'`. This + argument can be set for linter programs which output + their errors and warnings to the stderr stream + instead of stdout. The option `'both'` will read + from both stder and stdout at the same time. + + `read_buffer` A |Number| (`0` or `1`) indicating whether a command + should read the Vim buffer as input via stdin. This + option is set to `1` by default, and can be disabled + if a command manually reads from a temporary file + instead, etc. + + This option behaves as if it was set to `0` when the + `lint_file` option evaluates to `1`. + + *ale-lint-file* + `lint_file` A |Number| (`0` or `1`), or a |Funcref| for a function + accepting a buffer number for computing either `0` or + `1`, indicating whether a command should read the file + instead of the Vim buffer. This option can be used + for linters which must check the file on disk, and + which cannot check a Vim buffer instead. + + The result can be computed with |ale#command#Run()|. + + Linters where the eventual value of this option + evaluates to `1` will not be run as a user types, per + |g:ale_lint_on_text_changed|. Linters will instead be + run only when events occur against the file on disk, + including |g:ale_lint_on_enter| and + |g:ale_lint_on_save|. Linters where this option + evaluates to `1` will also be run when the |ALELint| + command is run. + + When this option is evaluates to `1`, ALE will behave + as if `read_buffer` was set to `0`. + + *ale-lsp-linters* + `lsp` A |String| for defining LSP (Language Server Protocol) + linters. + + This argument may be omitted or `''` when a linter + does not represent an LSP linter. + + When this argument is set to `'stdio'`, then the + linter will be defined as an LSP linter which keeps a + process for a language server running, and + communicates with it directly via a |channel|. + `executable` and `command` must be set. + + When this argument is set to `'socket'`, then the + linter will be defined as an LSP linter via a TCP + or named pipe socket connection. `address` must be set. + + ALE will not start a server automatically. + + When this argument is not empty `project_root` must + be defined. + + `language` can be defined to describe the language + for a file. The filetype will be used as the language + by default. + + LSP linters handle diagnostics automatically, so + the `callback` argument must not be defined. + + An optional `completion_filter` callback may be + defined for filtering completion results. + + `initialization_options` may be defined to pass + initialization options to the LSP. + + `lsp_config` may be defined to pass configuration + settings to the LSP. + + `address` A |String| representing an address to connect to, + or a |Funcref| accepting a buffer number and + returning the |String|. If the value contains a + colon, it is interpreted as referring to a TCP + socket; otherwise it is interpreted as the path of a + named pipe. + + The result can be computed with |ale#command#Run()|. + + This argument must only be set if the `lsp` argument + is set to `'socket'`. + + `project_root` A |String| representing a path to the project for + the file being checked with the language server, or + a |Funcref| accepting a buffer number and returning + the |String|. + + If an empty string is returned, the file will not be + checked at all. + + This argument must only be set if the `lsp` argument + is also set to a non-empty string. + + `language` A |String| representing the name of the language + being checked, or a |Funcref| accepting a buffer + number and returning the |String|. This string will + be sent to the LSP to tell it what type of language + is being checked. + + If a language isn't provided, the language will + default to the value of the filetype given to + |ale#linter#Define|. + + `completion_filter` A |String| or |Funcref| for a callback function + accepting a buffer number and a completion item. + + The completion item will be a |Dictionary| following + the Language Server Protocol `CompletionItem` + interface as described in the specification, + available online here: + https://microsoft.github.io/language-server-protocol + + `aliases` A |List| of aliases for the linter name. + + This argument can be set with alternative names for + selecting the linter with |g:ale_linters|. This + setting can make it easier to guess the linter name + by offering a few alternatives. + + `initialization_options` A |Dictionary| of initialization options for LSPs, + or a |Funcref| for a callback function accepting + a buffer number and returning the |Dictionary|. + + This will be fed (as JSON) to the LSP in the + initialize command. + + `lsp_config` A |Dictionary| for configuring a language server, + or a |Funcref| for a callback function accepting + a buffer number and returning the |Dictionary|. + + This will be fed (as JSON) to the LSP in the + workspace/didChangeConfiguration command. + + If temporary files or directories are created for commands run with + `command`, then these temporary files or directories can be managed by ALE, + for automatic deletion. See |ale#command#ManageFile()| and + |ale#command#ManageDirectory| for more information. + + *ale-command-format-strings* + + All command strings will be formatted for special character sequences. + Any substring `%s` will be replaced with the full path to the current file + being edited. This format option can be used to pass the exact filename + being edited to a program. + + For example: > + 'command': 'eslint -f unix --stdin --stdin-filename %s' +< + Any substring `%t` will be replaced with a path to a temporary file. Merely + adding `%t` will cause ALE to create a temporary file containing the + contents of the buffer being checked. All occurrences of `%t` in command + strings will reference the one temporary file. The temporary file will be + created inside a temporary directory, and the entire temporary directory + will be automatically deleted, following the behavior of + |ale#command#ManageDirectory|. This option can be used for some linters which + do not support reading from stdin. + + For example: > + 'command': 'ghc -fno-code -v0 %t', +< + Any substring `%e` will be replaced with the escaped executable supplied + with `executable`. This provides a convenient way to define a command string + which needs to include a dynamic executable name, but which is otherwise + static. + + For example: > + 'command': '%e --some-argument', +< + The character sequence `%%` can be used to emit a literal `%` into a + command, so literal character sequences `%s` and `%t` can be escaped by + using `%%s` and `%%t` instead, etc. + + Some |filename-modifiers| can be applied to `%s` and `%t`. Only `:h`, `:t`, + `:r`, and `:e` may be applied, other modifiers will be ignored. Filename + modifiers can be applied to the format markers by placing them after them. + + For example: > + 'command': '%s:h %s:e %s:h:t', +< + Given a path `/foo/baz/bar.txt`, the above command string will generate + something akin to `'/foo/baz' 'txt' 'baz'` + + If a callback for a command generates part of a command string which might + possibly contain `%%`, `%s`, `%t`, or `%e`, where the special formatting + behavior is not desired, the |ale#command#EscapeCommandPart()| function can + be used to replace those characters to avoid formatting issues. + + *ale-linter-loading-behavior* + + Linters for ALE will be loaded by searching |runtimepath| in the following + format: > + + ale_linters//.vim +< + Any linters which exist anywhere in |runtimepath| with that directory + structure will be automatically loaded for the matching |filetype|. Filetypes + containing `.` characters will be split into individual parts, and files + will be loaded for each filetype between the `.` characters. + + Linters can be defined from vimrc and other files as long as this function + is loaded first. For example, the following code will define a Hello World + linter in vimrc in Vim 8: > + + " Plugins have to be loaded first. + " If you are using a plugin manager, run that first. + packloadall + + call ale#linter#Define('vim', { + \ 'name': 'echo-test', + \ 'executable': 'echo', + \ 'command': 'echo hello world', + \ 'callback': {buffer, lines -> map(lines, '{"text": v:val, "lnum": 1}')}, + \}) +< + +ale#linter#Get(filetype) *ale#linter#Get()* + + Return all of linters configured for a given filetype as a |List| of + |Dictionary| values in the format specified by |ale#linter#Define()|. + + Filetypes may be dot-separated to invoke linters for multiple filetypes: + for instance, the filetype `javascript.jsx` will return linters for both the + `javascript` and `jsx` filetype. + + Aliases may be defined in as described in |g:ale_linter_aliases|. Aliases + are applied after dot-separated filetypes are broken up into their + components. + + +ale#linter#PreventLoading(filetype) *ale#linter#PreventLoading()* + + Given a `filetype`, prevent any more linters from being loaded from + |runtimepath| for that filetype. This function can be called from vimrc or + similar to prevent ALE from loading linters. + + +ale#lsp_linter#SendRequest(buffer, linter_name, message, [Handler]) + *ale#lsp_linter#SendRequest()* + + Send a custom request to an LSP linter. The arguments are defined as + follows: + + `buffer` A valid buffer number. + + `linter_name` A |String| identifying an LSP linter that is available and + enabled for the |filetype| of `buffer`. + + `message` A |List| in the form `[is_notification, method, parameters]`, + containing three elements: + `is_notification` - an |Integer| that has value 1 if the + request is a notification, 0 otherwise; + `method` - a |String|, identifying an LSP method supported + by `linter`; + `parameters` - a |dictionary| of LSP parameters that are + applicable to `method`. + + `Handler` Optional argument, meaningful only when `message[0]` is 0. + A |Funcref| that is called when a response to the request is + received, and takes as unique argument a dictionary + representing the response obtained from the server. + + +ale#other_source#ShowResults(buffer, linter_name, loclist) + *ale#other_source#ShowResults()* + + Show results from another source of information. + + `buffer` must be a valid buffer number, and `linter_name` must be a unique + name for identifying another source of information. The `loclist` given + where the problems in a buffer are, and should be provided in the format ALE + uses for regular linter results. See |ale-loclist-format|. + + +ale#other_source#StartChecking(buffer, linter_name) + *ale#other_source#StartChecking()* + + Tell ALE that another source of information has started checking a buffer. + + `buffer` must be a valid buffer number, and `linter_name` must be a unique + name for identifying another source of information. + + +ale#statusline#Count(buffer) *ale#statusline#Count()* + + Given the number of a buffer which may have problems, return a |Dictionary| + containing information about the number of problems detected by ALE. The + following keys are supported: + + `error` -> The number of problems with type `E` and `sub_type != 'style'` + `warning` -> The number of problems with type `W` and `sub_type != 'style'` + `info` -> The number of problems with type `I` + `style_error` -> The number of problems with type `E` and `sub_type == 'style'` + `style_warning` -> The number of problems with type `W` and `sub_type == 'style'` + `total` -> The total number of problems. + + +ale#statusline#FirstProblem(buffer, type) *ale#statusline#FirstProblem()* + + Returns a copy of the first entry in the `loclist` that matches the supplied + buffer number and problem type. If there is no such entry, an empty dictionary + is returned. + Problem type should be one of the strings listed below: + + `error` -> Returns the first `loclist` item with type `E` and + `sub_type != 'style'` + `warning` -> First item with type `W` and `sub_type != 'style'` + `info` -> First item with type `I` + `style_error` -> First item with type `E` and `sub_type == 'style'` + `style_warning` -> First item with type `W` and `sub_type == 'style'` + + +b:ale_linted *b:ale_linted* + + `b:ale_linted` is set to the number of times a buffer has been checked by + ALE after all linters for one lint cycle have finished checking a buffer. + This variable may not be defined until ALE first checks a buffer, so it + should be accessed with |get()| or |getbufvar()|. For example: > + + " Print a message indicating how many times ALE has checked this buffer. + echo 'ALE has checked this buffer ' . get(b:, 'ale_linted') . ' time(s).' + " Print 'checked' using getbufvar() if a buffer has been checked. + echo getbufvar(bufnr(''), 'ale_linted', 0) > 0 ? 'checked' : 'not checked' +< + +g:ale_want_results_buffer *g:ale_want_results_buffer* + + `g:ale_want_results_buffer` is set to the number of the buffer being checked + when the |ALEWantResults| event is signaled. This variable should be read to + figure out which buffer other sources should lint. + + +ALECompletePost *ALECompletePost-autocmd* + *ALECompletePost* + + This |User| autocmd is triggered after ALE inserts an item on + |CompleteDone|. This event can be used to run commands after a buffer + is changed by ALE as the result of completion. For example, |ALEFix| can + be configured to run automatically when completion is done: > + + augroup FixAfterComplete + autocmd! + " Run ALEFix when completion items are added. + autocmd User ALECompletePost ALEFix! + " If ALE starts fixing a file, stop linters running for now. + autocmd User ALEFixPre ALELintStop + augroup END +< + +ALELintPre *ALELintPre-autocmd* + *ALELintPre* +ALELintPost *ALELintPost-autocmd* + *ALELintPost* +ALEFixPre *ALEFixPre-autocmd* + *ALEFixPre* +ALEFixPost *ALEFixPost-autocmd* + *ALEFixPost* + + These |User| autocommands are triggered before and after every lint or fix + cycle. They can be used to update statuslines, send notifications, etc. + The autocmd commands are run with |:silent|, so |:unsilent| is required for + echoing messages. + + For example to change the color of the statusline while the linter is + running: +> + augroup ALEProgress + autocmd! + autocmd User ALELintPre hi Statusline ctermfg=darkgrey + autocmd User ALELintPost hi Statusline ctermfg=NONE + augroup END +< + Or to display the progress in the statusline: +> + let s:ale_running = 0 + let l:stl .= '%{s:ale_running ? "[linting]" : ""}' + augroup ALEProgress + autocmd! + autocmd User ALELintPre let s:ale_running = 1 | redrawstatus + autocmd User ALELintPost let s:ale_running = 0 | redrawstatus + augroup END + +< +ALEJobStarted *ALEJobStarted-autocmd* + *ALEJobStarted* + + This |User| autocommand is triggered immediately after a job is successfully + run. This provides better accuracy for checking linter status with + |ale#engine#IsCheckingBuffer()| over |ALELintPre-autocmd|, which is actually + triggered before any linters are executed. + +ALELSPStarted *ALELSPStarted-autocmd* + *ALELSPStarted* + + This |User| autocommand is triggered immediately after an LSP connection is + successfully initialized. This provides a way to perform any additional + initialization work, such as setting up buffer-level mappings. + + +ALEWantResults *ALEWantResults-autocmd* + *ALEWantResults* + + This |User| autocommand is triggered before ALE begins a lint cycle. Another + source can respond by calling |ale#other_source#StartChecking()|, and + |ALELintPre| will be signaled thereafter, to allow other plugins to know + that another source is checking the buffer. + + |g:ale_want_results_buffer| will be set to the number for a buffer being + checked when the event is signaled, and deleted after the event is done. + This variable should be read to know which buffer to check. + + Other plugins can use this event to start checking buffers when ALE events + for checking buffers are triggered. + + +=============================================================================== +10. Special Thanks *ale-special-thanks* + +Special thanks to Mark Grealish (https://www.bhalash.com/) for providing ALE's +snazzy looking ale glass logo. Cheers, Mark! + +=============================================================================== +11. Contact *ale-contact* + +If you like this plugin, and wish to get in touch, check out the GitHub +page for issues and more at https://github.com/dense-analysis/ale + +If you wish to contact the author of this plugin directly, please feel +free to send an email to devw0rp@gmail.com. + +Please drink responsibly, or not at all, which is ironically the preference +of w0rp, who is teetotal. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim b/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim new file mode 100644 index 00000000..189a4dc2 --- /dev/null +++ b/sources_non_forked/ale/ftplugin/ale-fix-suggest.vim @@ -0,0 +1,2 @@ +" Close the ALEFixSuggest window with the q key. +noremap q :q! diff --git a/sources_non_forked/ale/ftplugin/ale-preview-selection.vim b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim new file mode 100644 index 00000000..7ec84068 --- /dev/null +++ b/sources_non_forked/ale/ftplugin/ale-preview-selection.vim @@ -0,0 +1,16 @@ +" Close the ALEPreviewWindow window with the q key. +noremap q :q! +" Disable some keybinds for the selection window. +noremap v +noremap i +noremap I +noremap +noremap +noremap +noremap a +noremap A +noremap o +noremap O +" Keybinds for opening selection items. +noremap :call ale#preview#OpenSelection() +noremap t :call ale#preview#OpenSelectionInTab() diff --git a/sources_non_forked/ale/ftplugin/ale-preview.vim b/sources_non_forked/ale/ftplugin/ale-preview.vim new file mode 100644 index 00000000..ffbffbd5 --- /dev/null +++ b/sources_non_forked/ale/ftplugin/ale-preview.vim @@ -0,0 +1,2 @@ +" Close the ALEPreviewWindow window with the q key. +noremap q :q! diff --git a/sources_non_forked/ale/plugin/ale.vim b/sources_non_forked/ale/plugin/ale.vim new file mode 100644 index 00000000..4ba24c1d --- /dev/null +++ b/sources_non_forked/ale/plugin/ale.vim @@ -0,0 +1,353 @@ +" Author: w0rp +" Description: Main entry point for the plugin: sets up prefs and autocommands +" Preferences can be set in vimrc files and so on to configure ale + +" Sanity Checks + +if exists('g:loaded_ale_dont_use_this_in_other_plugins_please') + finish +endif + +" Set a special flag used only by this plugin for preventing doubly +" loading the script. +let g:loaded_ale_dont_use_this_in_other_plugins_please = 1 + +" A flag for detecting if the required features are set. +if has('nvim') + let s:has_features = has('timers') && has('nvim-0.2.0') +else + " Check if Job and Channel functions are available, instead of the + " features. This works better on old MacVim versions. + let s:has_features = has('timers') && exists('*job_start') && exists('*ch_close_in') +endif + +if !s:has_features + " Only output a warning if editing some special files. + if index(['', 'gitcommit'], &filetype) == -1 + " no-custom-checks + echoerr 'ALE requires NeoVim >= 0.2.0 or Vim 8 with +timers +job +channel' + " no-custom-checks + echoerr 'Please update your editor appropriately.' + endif + + " Stop here, as it won't work. + finish +endif + +" Set this flag so that other plugins can use it, like airline. +let g:loaded_ale = 1 + +" This global variable is used internally by ALE for tracking information for +" each buffer which linters are being run against. +let g:ale_buffer_info = {} +" This global Dictionary tracks data for fixing code. Don't mess with it. +let g:ale_fix_buffer_data = {} + +" User Configuration + +" This option prevents ALE autocmd commands from being run for particular +" filetypes which can cause issues. +let g:ale_filetype_blacklist = [ +\ 'dirvish', +\ 'nerdtree', +\ 'qf', +\ 'tags', +\ 'unite', +\] + +" This Dictionary configures which linters are enabled for which languages. +let g:ale_linters = get(g:, 'ale_linters', {}) +" This option can be changed to only enable explicitly selected linters. +let g:ale_linters_explicit = get(g:, 'ale_linters_explicit', 0) + +" This Dictionary configures which functions will be used for fixing problems. +let g:ale_fixers = get(g:, 'ale_fixers', {}) + +" This Dictionary allows users to set up filetype aliases for new filetypes. +let g:ale_linter_aliases = get(g:, 'ale_linter_aliases', {}) + +" This flag can be set with a number of milliseconds for delaying the +" execution of a linter when text is changed. The timeout will be set and +" cleared each time text is changed, so repeated edits won't trigger the +" jobs for linting until enough time has passed after editing is done. +let g:ale_lint_delay = get(g:, 'ale_lint_delay', 200) + +" This flag can be set to 'never' to disable linting when text is changed. +" This flag can also be set to 'always' or 'insert' to lint when text is +" changed in both normal and insert mode, or only in insert mode respectively. +let g:ale_lint_on_text_changed = get(g:, 'ale_lint_on_text_changed', 'normal') + +" This flag can be set to 1 to enable linting when leaving insert mode. +let g:ale_lint_on_insert_leave = get(g:, 'ale_lint_on_insert_leave', 1) + +" This flag can be set to 0 to disable linting when the buffer is entered. +let g:ale_lint_on_enter = get(g:, 'ale_lint_on_enter', 1) + +" This flag can be set to 1 to enable linting when a buffer is written. +let g:ale_lint_on_save = get(g:, 'ale_lint_on_save', 1) + +" This flag can be set to 1 to enable linting when the filetype is changed. +let g:ale_lint_on_filetype_changed = get(g:, 'ale_lint_on_filetype_changed', 1) + +" If set to 1, hints and suggestion from LSP servers and tsserver will be shown. +let g:ale_lsp_suggestions = get(g:, 'ale_lsp_suggestions', 0) + +" This flag can be set to 1 to enable automatically fixing files on save. +let g:ale_fix_on_save = get(g:, 'ale_fix_on_save', 0) + +" This flag may be set to 0 to disable ale. After ale is loaded, :ALEToggle +" should be used instead. +let g:ale_enabled = get(g:, 'ale_enabled', 1) + +" A Dictionary mapping linter or fixer names to Arrays of two-item Arrays +" mapping filename paths from one system to another. +let g:ale_filename_mappings = get(g:, 'ale_filename_mappings', {}) + +" This Dictionary configures the default project roots for various linters. +let g:ale_root = get(g:, 'ale_root', {}) + +" These flags dictates if ale uses the quickfix or the loclist (loclist is the +" default, quickfix overrides loclist). +let g:ale_set_loclist = get(g:, 'ale_set_loclist', 1) +let g:ale_set_quickfix = get(g:, 'ale_set_quickfix', 0) + +" This flag can be set to 0 to disable setting signs. +" This is enabled by default only if the 'signs' feature exists. +let g:ale_set_signs = get(g:, 'ale_set_signs', has('signs')) + +" This flag can be set to 0 to disable setting error highlights. +let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax')) + +" This List can be configured to exclude particular highlights. +let g:ale_exclude_highlights = get(g:, 'ale_exclude_highlights', []) + +" This flag can be set to 0 to disable echoing when the cursor moves. +let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1) + +" This flag can be set to 1 to automatically show errors in the preview window. +let g:ale_cursor_detail = get(g:, 'ale_cursor_detail', 0) + +" This flag can be set to 1 to enable virtual text when the cursor moves. +let g:ale_virtualtext_cursor = get(g:, 'ale_virtualtext_cursor', 0) + +" This flag can be set to 1 to enable LSP hover messages at the cursor. +let g:ale_hover_cursor = get(g:, 'ale_hover_cursor', 1) + +" This flag can be set to 1 to automatically close the preview window upon +" entering Insert Mode. +let g:ale_close_preview_on_insert = get(g:, 'ale_close_preview_on_insert', 0) + +" This flag can be set to 0 to disable balloon support. +let g:ale_set_balloons = get(g:, 'ale_set_balloons', has('balloon_eval') && has('gui_running')) + +" Use preview window for hover messages. +let g:ale_hover_to_preview = get(g:, 'ale_hover_to_preview', 0) + +" Float preview windows in Neovim +let g:ale_floating_preview = get(g:, 'ale_floating_preview', 0) + +" Hovers use floating windows in Neovim +let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0) + +" Detail uses floating windows in Neovim +let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0) + +" Border setting for floating preview windows +" The elements in the list set the characters for the left, top, top-left, +" top-right, bottom-right, bottom-left, right, and bottom of the border +" respectively +let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+', '|', '-']) + +" This flag can be set to 0 to disable warnings for trailing whitespace +let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1) +" This flag can be set to 0 to disable warnings for trailing blank lines +let g:ale_warn_about_trailing_blank_lines = get(g:, 'ale_warn_about_trailing_blank_lines', 1) + +" A flag for enabling or disabling the command history. +let g:ale_history_enabled = get(g:, 'ale_history_enabled', 1) + +" A flag for storing the full output of commands in the history. +let g:ale_history_log_output = get(g:, 'ale_history_log_output', 1) + +" Enable automatic completion with LSP servers and tsserver +let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0) + +" Enable automatic detection of pipenv for Python linters. +let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0) + +" Enable automatic detection of poetry for Python linters. +let g:ale_python_auto_poetry = get(g:, 'ale_python_auto_poetry', 0) + +" This variable can be overridden to set the GO111MODULE environment variable. +let g:ale_go_go111module = get(g:, 'ale_go_go111module', '') + +" Default executable for deno, needed set before plugin start +let g:ale_deno_executable = get(g:, 'ale_deno_executable', 'deno') + +" If 1, enable a popup menu for commands. +let g:ale_popup_menu_enabled = get(g:, 'ale_popup_menu_enabled', has('gui_running')) + +if g:ale_set_balloons is 1 || g:ale_set_balloons is# 'hover' + call ale#balloon#Enable() +endif + +if g:ale_completion_enabled + call ale#completion#Enable() +endif + +if g:ale_popup_menu_enabled + call ale#code_action#EnablePopUpMenu() +endif + +" Define commands for moving through warnings and errors. +command! -bar -nargs=* ALEPrevious +\ :call ale#loclist_jumping#WrapJump('before', ) +command! -bar -nargs=* ALENext +\ :call ale#loclist_jumping#WrapJump('after', ) + +command! -bar ALEPreviousWrap :call ale#loclist_jumping#Jump('before', 1) +command! -bar ALENextWrap :call ale#loclist_jumping#Jump('after', 1) +command! -bar ALEFirst :call ale#loclist_jumping#JumpToIndex(0) +command! -bar ALELast :call ale#loclist_jumping#JumpToIndex(-1) + +" A command for showing error details. +command! -bar ALEDetail :call ale#cursor#ShowCursorDetail() + +" Define commands for turning ALE on or off. +command! -bar ALEToggle :call ale#toggle#Toggle() +command! -bar ALEEnable :call ale#toggle#Enable() +command! -bar ALEDisable :call ale#toggle#Disable() +command! -bar ALEReset :call ale#toggle#Reset() +" Commands for turning ALE on or off for a buffer. +command! -bar ALEToggleBuffer :call ale#toggle#ToggleBuffer(bufnr('')) +command! -bar ALEEnableBuffer :call ale#toggle#EnableBuffer(bufnr('')) +command! -bar ALEDisableBuffer :call ale#toggle#DisableBuffer(bufnr('')) +command! -bar ALEResetBuffer :call ale#toggle#ResetBuffer(bufnr('')) +" A command to stop all LSP-like clients, including tsserver. +command! -bar ALEStopAllLSPs :call ale#lsp#reset#StopAllLSPs() + +" A command for linting manually. +command! -bar ALELint :call ale#Queue(0, 'lint_file') +" Stop current jobs when linting. +command! -bar ALELintStop :call ale#engine#Stop(bufnr('')) + +" Commands to manually populate the quickfixes. +command! -bar ALEPopulateQuickfix :call ale#list#ForcePopulateErrorList(1) +command! -bar ALEPopulateLocList :call ale#list#ForcePopulateErrorList(0) + +" Define a command to get information about current filetype. +command! -bar ALEInfo :call ale#debugging#Info() +" The same, but copy output to your clipboard. +command! -bar ALEInfoToClipboard :call ale#debugging#InfoToClipboard() +" Copy ALE information to a file. +command! -bar -nargs=1 ALEInfoToFile :call ale#debugging#InfoToFile() + +" Fix problems in files. +command! -bar -bang -nargs=* -complete=customlist,ale#fix#registry#CompleteFixers ALEFix :call ale#fix#Fix(bufnr(''), '', ) +" Suggest registered functions to use for fixing problems. +command! -bar ALEFixSuggest :call ale#fix#registry#Suggest(&filetype) + +" Go to definition for tsserver and LSP +command! -bar -nargs=* ALEGoToDefinition :call ale#definition#GoToCommandHandler('', ) + +" Go to type definition for tsserver and LSP +command! -bar -nargs=* ALEGoToTypeDefinition :call ale#definition#GoToCommandHandler('type', ) + +" Go to implementation for tsserver and LSP +command! -bar -nargs=* ALEGoToImplementation :call ale#definition#GoToCommandHandler('implementation', ) + +" Repeat a previous selection in the preview window +command! -bar ALERepeatSelection :call ale#preview#RepeatSelection() + +" Find references for tsserver and LSP +command! -bar -nargs=* ALEFindReferences :call ale#references#Find() + +" Show summary information for the cursor. +command! -bar ALEHover :call ale#hover#ShowAtCursor() + +" Show documentation for the cursor. +command! -bar ALEDocumentation :call ale#hover#ShowDocumentationAtCursor() + +" Search for appearances of a symbol, such as a type name or function name. +command! -nargs=1 ALESymbolSearch :call ale#symbol#Search() + +" Complete text with tsserver and LSP +command! -bar ALEComplete :call ale#completion#GetCompletions('ale-manual') + +" Try to find completions for the current symbol that add additional text. +command! -bar ALEImport :call ale#completion#Import() + +" Rename symbols using tsserver and LSP +command! -bar -bang ALERename :call ale#rename#Execute() + +" Rename file using tsserver +command! -bar -bang ALEFileRename :call ale#filerename#Execute() + +" Apply code actions to a range. +command! -bar -range ALECodeAction :call ale#codefix#Execute() + +" Organize import statements using tsserver +command! -bar ALEOrganizeImports :call ale#organize_imports#Execute() + +" mappings for commands +nnoremap (ale_previous) :ALEPrevious +nnoremap (ale_previous_wrap) :ALEPreviousWrap +nnoremap (ale_previous_error) :ALEPrevious -error +nnoremap (ale_previous_wrap_error) :ALEPrevious -wrap -error +nnoremap (ale_previous_warning) :ALEPrevious -warning +nnoremap (ale_previous_wrap_warning) :ALEPrevious -wrap -warning +nnoremap (ale_next) :ALENext +nnoremap (ale_next_wrap) :ALENextWrap +nnoremap (ale_next_error) :ALENext -error +nnoremap (ale_next_wrap_error) :ALENext -wrap -error +nnoremap (ale_next_warning) :ALENext -warning +nnoremap (ale_next_wrap_warning) :ALENext -wrap -warning +nnoremap (ale_first) :ALEFirst +nnoremap (ale_last) :ALELast +nnoremap (ale_toggle) :ALEToggle +nnoremap (ale_enable) :ALEEnable +nnoremap (ale_disable) :ALEDisable +nnoremap (ale_reset) :ALEReset +nnoremap (ale_toggle_buffer) :ALEToggleBuffer +nnoremap (ale_enable_buffer) :ALEEnableBuffer +nnoremap (ale_disable_buffer) :ALEDisableBuffer +nnoremap (ale_reset_buffer) :ALEResetBuffer +nnoremap (ale_lint) :ALELint +nnoremap (ale_detail) :ALEDetail +nnoremap (ale_fix) :ALEFix +nnoremap (ale_go_to_definition) :ALEGoToDefinition +nnoremap (ale_go_to_definition_in_tab) :ALEGoToDefinition -tab +nnoremap (ale_go_to_definition_in_split) :ALEGoToDefinition -split +nnoremap (ale_go_to_definition_in_vsplit) :ALEGoToDefinition -vsplit +nnoremap (ale_go_to_type_definition) :ALEGoToTypeDefinition +nnoremap (ale_go_to_type_definition_in_tab) :ALEGoToTypeDefinition -tab +nnoremap (ale_go_to_type_definition_in_split) :ALEGoToTypeDefinition -split +nnoremap (ale_go_to_type_definition_in_vsplit) :ALEGoToTypeDefinition -vsplit +nnoremap (ale_go_to_implementation_in_tab) :ALEGoToImplementation -tab +nnoremap (ale_go_to_implementation_in_split) :ALEGoToImplementation -split +nnoremap (ale_go_to_implementation_in_vsplit) :ALEGoToImplementation -vsplit +nnoremap (ale_find_references) :ALEFindReferences +nnoremap (ale_hover) :ALEHover +nnoremap (ale_documentation) :ALEDocumentation +inoremap (ale_complete) :ALEComplete +nnoremap (ale_import) :ALEImport +nnoremap (ale_rename) :ALERename +nnoremap (ale_filerename) :ALEFileRename +nnoremap (ale_code_action) :ALECodeAction +nnoremap (ale_repeat_selection) :ALERepeatSelection + +" Set up autocmd groups now. +call ale#events#Init() + +" Housekeeping + +augroup ALECleanupGroup + autocmd! + " Clean up buffers automatically when they are unloaded. + autocmd BufDelete * if exists('*ale#engine#Cleanup') | call ale#engine#Cleanup(str2nr(expand(''))) | endif + autocmd QuitPre * call ale#events#QuitEvent(str2nr(expand(''))) + + if exists('##VimSuspend') + autocmd VimSuspend * if exists('*ale#engine#CleanupEveryBuffer') | call ale#engine#CleanupEveryBuffer() | endif + endif +augroup END diff --git a/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py new file mode 100644 index 00000000..a692dc31 --- /dev/null +++ b/sources_non_forked/ale/rplugin/python3/deoplete/sources/ale.py @@ -0,0 +1,62 @@ +""" +A Deoplete source for ALE completion via tsserver and LSP. +""" +__author__ = 'Joao Paulo, w0rp' + +try: + from deoplete.source.base import Base +except ImportError: + # Mock the Base class if deoplete isn't available, as mock isn't available + # in the Docker image. + class Base(object): + def __init__(self, vim): + pass + + +# Make sure this code is valid in Python 2, used for running unit tests. +class Source(Base): + + def __init__(self, vim): + super(Source, self).__init__(vim) + + self.name = 'ale' + self.mark = '[L]' + self.rank = 1000 + self.is_bytepos = True + self.min_pattern_length = 1 + self.is_volatile = True + # Do not forget to update s:trigger_character_map in completion.vim in + # updating entries in this map. + self.input_patterns = { + '_': r'\.\w*$', + 'rust': r'(\.|::)\w*$', + 'typescript': r'(\.|\'|")\w*$', + 'cpp': r'(\.|::|->)\w*$', + 'c': r'(\.|->)\w*$', + } + + # Returns an integer for the start position, as with omnifunc. + def get_complete_position(self, context): + return self.vim.call( + 'ale#completion#GetCompletionPositionForDeoplete', context['input'] + ) + + def gather_candidates(self, context): + # Stop early if ALE can't provide completion data for this buffer. + if not self.vim.call('ale#completion#CanProvideCompletions'): + return None + + event = context.get('event') + + if event == 'Async': + result = self.vim.call('ale#completion#GetCompletionResult') + + return result or [] + + if context.get('is_refresh'): + self.vim.command( + "call ale#completion#GetCompletions('ale-callback', " + + "{'callback': {completions -> deoplete#auto_complete() }})" + ) + + return [] diff --git a/sources_non_forked/ale/supported-tools.md b/sources_non_forked/ale/supported-tools.md new file mode 100644 index 00000000..2989bfbc --- /dev/null +++ b/sources_non_forked/ale/supported-tools.md @@ -0,0 +1,697 @@ +# ALE Supported Languages and Tools + +This plugin supports the following languages and tools. All available +tools will be run in combination, so they can be complementary. + + + +**Legend** + +| Key | Definition | +| ------------- | ----------------------------------------------------------------- | +| :floppy_disk: | May only run on files on disk (see: `help ale-lint-file-linters` | +| :warning: | Disabled by default | + +--- + +* Ada + * [ada_language_server](https://github.com/AdaCore/ada_language_server) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [gcc](https://gcc.gnu.org) + * [gnatpp](https://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/gnat_utility_programs.html#the-gnat-pretty-printer-gnatpp) :floppy_disk: +* Ansible + * [ansible-lint](https://github.com/willthames/ansible-lint) :floppy_disk: +* API Blueprint + * [drafter](https://github.com/apiaryio/drafter) +* APKBUILD + * [apkbuild-lint](https://gitlab.alpinelinux.org/Leo/atools) + * [secfixes-check](https://gitlab.alpinelinux.org/Leo/atools) +* AsciiDoc + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [languagetool](https://languagetool.org/) :floppy_disk: + * [proselint](http://proselint.com/) + * [redpen](http://redpen.cc/) + * [textlint](https://textlint.github.io/) + * [vale](https://github.com/ValeLint/vale) + * [write-good](https://github.com/btford/write-good) +* ASM + * [gcc](https://gcc.gnu.org) +* AVRA + * [avra](https://github.com/Ro5bert/avra) +* Awk + * [gawk](https://www.gnu.org/software/gawk/) +* Bash + * [bashate](https://github.com/openstack/bashate) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [language-server](https://github.com/mads-hartmann/bash-language-server) + * shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) + * [shellcheck](https://www.shellcheck.net/) + * [shfmt](https://github.com/mvdan/sh) +* Bats + * [shellcheck](https://www.shellcheck.net/) +* Bazel + * [buildifier](https://github.com/bazelbuild/buildtools) +* BibTeX + * [bibclean](http://ftp.math.utah.edu/pub/bibclean/) +* Bicep + * [bicep](https://github.com/Azure/bicep) :floppy_disk: +* BitBake + * [oelint-adv](https://github.com/priv-kweihmann/oelint-adv) +* Bourne Shell + * shell [-n flag](http://linux.die.net/man/1/sh) + * [shellcheck](https://www.shellcheck.net/) + * [shfmt](https://github.com/mvdan/sh) +* C + * [astyle](http://astyle.sourceforge.net/) + * [ccls](https://github.com/MaskRay/ccls) + * [clang](http://clang.llvm.org/) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: + * [cppcheck](http://cppcheck.sourceforge.net) + * [cpplint](https://github.com/cpplint/cpplint) + * [cquery](https://github.com/cquery-project/cquery) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [flawfinder](https://www.dwheeler.com/flawfinder/) + * [gcc](https://gcc.gnu.org/) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* C# + * [csc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-csc` for details and configuration + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [dotnet-format](https://github.com/dotnet/format) + * [mcs](http://www.mono-project.com/docs/about-mono/languages/csharp/) see:`help ale-cs-mcs` for details + * [mcsc](http://www.mono-project.com/docs/about-mono/languages/csharp/) :floppy_disk: see:`help ale-cs-mcsc` for details and configuration + * [uncrustify](https://github.com/uncrustify/uncrustify) +* C++ (filetype cpp) + * [astyle](http://astyle.sourceforge.net/) + * [ccls](https://github.com/MaskRay/ccls) + * [clang](http://clang.llvm.org/) + * [clang-format](https://clang.llvm.org/docs/ClangFormat.html) + * [clangcheck](http://clang.llvm.org/docs/ClangCheck.html) :floppy_disk: + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [clangtidy](http://clang.llvm.org/extra/clang-tidy/) :floppy_disk: + * [clazy](https://github.com/KDE/clazy) :floppy_disk: + * [cppcheck](http://cppcheck.sourceforge.net) + * [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) :floppy_disk: + * [cquery](https://github.com/cquery-project/cquery) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [flawfinder](https://www.dwheeler.com/flawfinder/) + * [gcc](https://gcc.gnu.org/) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* Cairo + * [starknet](https://starknet.io/docs) +* Chef + * [cookstyle](https://docs.chef.io/cookstyle.html) + * [foodcritic](http://www.foodcritic.io/) :floppy_disk: +* Clojure + * [clj-kondo](https://github.com/borkdude/clj-kondo) + * [joker](https://github.com/candid82/joker) +* CloudFormation + * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) +* CMake + * [cmake-format](https://github.com/cheshirekow/cmake_format) + * [cmake-lint](https://github.com/cheshirekow/cmake_format) + * [cmakelint](https://github.com/cmake-lint/cmake-lint) +* CoffeeScript + * [coffee](http://coffeescript.org/) + * [coffeelint](https://www.npmjs.com/package/coffeelint) +* Crystal + * [ameba](https://github.com/veelenga/ameba) :floppy_disk: + * [crystal](https://crystal-lang.org/) :floppy_disk: +* CSS + * [VSCode CSS language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [css-beautify](https://github.com/beautify-web/js-beautify) + * [csslint](http://csslint.net/) + * [fecs](http://fecs.baidu.com/) + * [prettier](https://github.com/prettier/prettier) + * [stylelint](https://github.com/stylelint/stylelint) +* Cucumber + * [cucumber](https://cucumber.io/) +* CUDA + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [nvcc](http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html) :floppy_disk: +* Cypher + * [cypher-lint](https://github.com/cleishm/libcypher-parser) +* Cython (pyrex filetype) + * [cython](http://cython.org/) +* D + * [dfmt](https://github.com/dlang-community/dfmt) + * [dls](https://github.com/d-language-server/dls) + * [dmd](https://dlang.org/dmd-linux.html) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* Dafny + * [dafny](https://rise4fun.com/Dafny) :floppy_disk: +* Dart + * [analysis_server](https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server) + * [dart-analyze](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) :floppy_disk: + * [dart-format](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) + * [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) + * [language_server](https://github.com/natebosch/dart_language_server) +* desktop + * [desktop-file-validate](https://www.freedesktop.org/wiki/Software/desktop-file-utils/) +* Dhall + * [dhall-format](https://github.com/dhall-lang/dhall-lang) + * [dhall-freeze](https://github.com/dhall-lang/dhall-lang) + * [dhall-lint](https://github.com/dhall-lang/dhall-lang) +* Dockerfile + * [dockerfile_lint](https://github.com/projectatomic/dockerfile_lint) + * [dprint](https://dprint.dev) + * [hadolint](https://github.com/hadolint/hadolint) +* Elixir + * [credo](https://github.com/rrrene/credo) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: + * [dialyxir](https://github.com/jeremyjh/dialyxir) + * [dogma](https://github.com/lpil/dogma) :floppy_disk: + * [elixir-ls](https://github.com/elixir-lsp/elixir-ls) :warning: + * [mix](https://hexdocs.pm/mix/Mix.html) :warning: :floppy_disk: +* Elm + * [elm-format](https://github.com/avh4/elm-format) + * [elm-ls](https://github.com/elm-tooling/elm-language-server) + * [elm-make](https://github.com/elm/compiler) +* Erb + * [erb](https://apidock.com/ruby/ERB) + * [erblint](https://github.com/Shopify/erb-lint) + * [erubi](https://github.com/jeremyevans/erubi) + * [erubis](https://github.com/kwatch/erubis) + * [ruumba](https://github.com/ericqweinstein/ruumba) +* Erlang + * [SyntaxErl](https://github.com/ten0s/syntaxerl) + * [dialyzer](http://erlang.org/doc/man/dialyzer.html) :floppy_disk: + * [elvis](https://github.com/inaka/elvis) :floppy_disk: + * [erlang_ls](https://github.com/erlang-ls/erlang_ls) + * [erlc](http://erlang.org/doc/man/erlc.html) + * [erlfmt](https://github.com/WhatsApp/erlfmt) +* Fish + * fish [-n flag](https://linux.die.net/man/1/fish) + * [fish_indent](https://fishshell.com/docs/current/cmds/fish_indent.html) +* Fortran + * [gcc](https://gcc.gnu.org/) + * [language_server](https://github.com/hansec/fortran-language-server) +* Fountain + * [proselint](http://proselint.com/) +* FusionScript + * [fusion-lint](https://github.com/RyanSquared/fusionscript) +* Git Commit Messages + * [gitlint](https://github.com/jorisroovers/gitlint) +* GLSL + * [glslang](https://github.com/KhronosGroup/glslang) + * [glslls](https://github.com/svenstaro/glsl-language-server) +* Go + * [bingo](https://github.com/saibing/bingo) :warning: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: + * [go build](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go mod](https://golang.org/cmd/go/) :warning: :floppy_disk: + * [go vet](https://golang.org/cmd/vet/) :floppy_disk: + * [gofmt](https://golang.org/cmd/gofmt/) + * [gofumpt](https://github.com/mvdan/gofumpt) + * [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports) :warning: + * [golangci-lint](https://github.com/golangci/golangci-lint) :warning: :floppy_disk: + * [golangserver](https://github.com/sourcegraph/go-langserver) :warning: + * [golines](https://github.com/segmentio/golines) + * [golint](https://godoc.org/github.com/golang/lint) + * [gometalinter](https://github.com/alecthomas/gometalinter) :warning: :floppy_disk: + * [gopls](https://github.com/golang/go/wiki/gopls) + * [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) :warning: :floppy_disk: + * [gotype](https://godoc.org/golang.org/x/tools/cmd/gotype) :warning: :floppy_disk: + * [revive](https://github.com/mgechev/revive) :warning: :floppy_disk: + * [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) :warning: :floppy_disk: +* GraphQL + * [eslint](http://eslint.org/) + * [gqlint](https://github.com/happylinks/gqlint) + * [prettier](https://github.com/prettier/prettier) +* Hack + * [hack](http://hacklang.org/) + * [hackfmt](https://github.com/facebook/hhvm/tree/master/hphp/hack/hackfmt) + * [hhast](https://github.com/hhvm/hhast) :warning: (see `:help ale-integration-hack`) +* Haml + * [haml-lint](https://github.com/brigade/haml-lint) +* Handlebars + * [ember-template-lint](https://github.com/rwjblue/ember-template-lint) +* Haskell + * [brittany](https://github.com/lspitzner/brittany) + * [cabal-ghc](https://www.haskell.org/cabal/) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [floskell](https://github.com/ennocramer/floskell) + * [ghc](https://www.haskell.org/ghc/) + * [ghc-mod](https://github.com/DanielG/ghc-mod) + * [hdevtools](https://hackage.haskell.org/package/hdevtools) + * [hfmt](https://github.com/danstiner/hfmt) + * [hie](https://github.com/haskell/haskell-ide-engine) + * [hindent](https://hackage.haskell.org/package/hindent) + * [hlint](https://hackage.haskell.org/package/hlint) + * [hls](https://github.com/haskell/haskell-language-server) + * [ormolu](https://github.com/tweag/ormolu) + * [stack-build](https://haskellstack.org/) :floppy_disk: + * [stack-ghc](https://haskellstack.org/) + * [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) +* HCL + * [packer-fmt](https://github.com/hashicorp/packer) + * [terraform-fmt](https://github.com/hashicorp/terraform) +* HTML + * [VSCode HTML language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [alex](https://github.com/get-alex/alex) + * [angular](https://www.npmjs.com/package/@angular/language-server) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [fecs](http://fecs.baidu.com/) + * [html-beautify](https://beautifier.io/) + * [htmlhint](http://htmlhint.com/) + * [prettier](https://github.com/prettier/prettier) + * [proselint](http://proselint.com/) + * [tidy](http://www.html-tidy.org/) + * [write-good](https://github.com/btford/write-good) +* Idris + * [idris](http://www.idris-lang.org/) +* Ink + * [ink-language-server](https://github.com/ephread/ink-language-server) +* Inko + * [inko](https://inko-lang.org/) :floppy_disk: +* ISPC + * [ispc](https://ispc.github.io/) :floppy_disk: +* Java + * [PMD](https://pmd.github.io/) + * [checkstyle](http://checkstyle.sourceforge.net) :floppy_disk: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [eclipselsp](https://github.com/eclipse/eclipse.jdt.ls) + * [google-java-format](https://github.com/google/google-java-format) + * [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) + * [javalsp](https://github.com/georgewfraser/vscode-javac) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* JavaScript + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [deno](https://deno.land/) + * [dprint](https://dprint.dev/) + * [eslint](http://eslint.org/) + * [fecs](http://fecs.baidu.com/) + * [flow](https://flowtype.org/) + * [jscs](https://jscs-dev.github.io/) + * [jshint](http://jshint.com/) + * [prettier](https://github.com/prettier/prettier) + * [prettier-eslint](https://github.com/prettier/prettier-eslint-cli) + * [prettier-standard](https://github.com/sheerun/prettier-standard) + * [standard](http://standardjs.com/) + * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) + * [xo](https://github.com/sindresorhus/xo) +* JSON + * [VSCode JSON language server](https://github.com/hrsh7th/vscode-langservers-extracted) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) :warning: + * [dprint](https://dprint.dev) + * [eslint](http://eslint.org/) :warning: + * [fixjson](https://github.com/rhysd/fixjson) + * [jq](https://stedolan.github.io/jq/) :warning: + * [jsonlint](https://github.com/zaach/jsonlint) + * [prettier](https://github.com/prettier/prettier) + * [spectral](https://github.com/stoplightio/spectral) +* JSON5 + * [eslint](http://eslint.org/) :warning: +* JSONC + * [eslint](http://eslint.org/) :warning: +* Jsonnet + * [jsonnet-lint](https://jsonnet.org/learning/tools.html) + * [jsonnetfmt](https://jsonnet.org/learning/tools.html) +* Julia + * [languageserver](https://github.com/JuliaEditorSupport/LanguageServer.jl) +* Kotlin + * [kotlinc](https://kotlinlang.org) :floppy_disk: + * [ktlint](https://ktlint.github.io) + * [languageserver](https://github.com/fwcd/KotlinLanguageServer) see `:help ale-integration-kotlin` for configuration instructions +* LaTeX + * [alex](https://github.com/get-alex/alex) + * [chktex](http://www.nongnu.org/chktex/) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [lacheck](https://www.ctan.org/pkg/lacheck) + * [proselint](http://proselint.com/) + * [redpen](http://redpen.cc/) + * [texlab](https://texlab.netlify.com) + * [textlint](https://textlint.github.io/) + * [vale](https://github.com/ValeLint/vale) + * [write-good](https://github.com/btford/write-good) +* Less + * [lessc](https://www.npmjs.com/package/less) + * [prettier](https://github.com/prettier/prettier) + * [stylelint](https://github.com/stylelint/stylelint) +* LLVM + * [llc](https://llvm.org/docs/CommandGuide/llc.html) +* Lua + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [lua-format](https://github.com/Koihik/LuaFormatter) + * [luac](https://www.lua.org/manual/5.1/luac.html) + * [luacheck](https://github.com/mpeterv/luacheck) + * [luafmt](https://github.com/trixnz/lua-fmt) + * [selene](https://github.com/Kampfkarren/selene) + * [stylua](https://github.com/johnnymorganz/stylua) +* Mail + * [alex](https://github.com/get-alex/alex) + * [languagetool](https://languagetool.org/) :floppy_disk: + * [proselint](http://proselint.com/) + * [vale](https://github.com/ValeLint/vale) +* Make + * [checkmake](https://github.com/mrtazz/checkmake) +* Markdown + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [languagetool](https://languagetool.org/) :floppy_disk: + * [markdownlint](https://github.com/DavidAnson/markdownlint) :floppy_disk: + * [mdl](https://github.com/mivok/markdownlint) + * [pandoc](https://pandoc.org) + * [prettier](https://github.com/prettier/prettier) + * [proselint](http://proselint.com/) + * [redpen](http://redpen.cc/) + * [remark-lint](https://github.com/wooorm/remark-lint) + * [textlint](https://textlint.github.io/) + * [vale](https://github.com/ValeLint/vale) + * [write-good](https://github.com/btford/write-good) +* MATLAB + * [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) +* Mercury + * [mmc](http://mercurylang.org) :floppy_disk: +* NASM + * [nasm](https://www.nasm.us/) :floppy_disk: +* Nim + * [nim check](https://nim-lang.org/docs/nimc.html) :floppy_disk: + * [nimlsp](https://github.com/PMunch/nimlsp) + * nimpretty +* nix + * [nix-instantiate](http://nixos.org/nix/manual/#sec-nix-instantiate) + * [nixfmt](https://github.com/serokell/nixfmt) + * [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) + * [rnix-lsp](https://github.com/nix-community/rnix-lsp) + * [statix](https://github.com/nerdypepper/statix) +* nroff + * [alex](https://github.com/get-alex/alex) + * [proselint](http://proselint.com/) + * [write-good](https://github.com/btford/write-good) +* Objective-C + * [ccls](https://github.com/MaskRay/ccls) + * [clang](http://clang.llvm.org/) + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* Objective-C++ + * [clang](http://clang.llvm.org/) + * [clangd](https://clang.llvm.org/extra/clangd.html) + * [uncrustify](https://github.com/uncrustify/uncrustify) +* OCaml + * [dune](https://dune.build/) + * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions + * [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) + * [ocamllsp](https://github.com/ocaml/ocaml-lsp) + * [ocp-indent](https://github.com/OCamlPro/ocp-indent) + * [ols](https://github.com/freebroccolo/ocaml-language-server) +* OpenApi + * [ibm_validator](https://github.com/IBM/openapi-validator) + * [prettier](https://github.com/prettier/prettier) + * [yamllint](https://yamllint.readthedocs.io/) +* OpenSCAD + * [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk: +* Packer (HCL) + * [packer-fmt-fixer](https://github.com/hashicorp/packer) +* Pascal + * [ptop](https://www.freepascal.org/tools/ptop.var) +* Pawn + * [uncrustify](https://github.com/uncrustify/uncrustify) +* Perl + * [perl -c](https://perl.org/) :warning: + * [perl-critic](https://metacpan.org/pod/Perl::Critic) + * [perltidy](https://metacpan.org/pod/distribution/Perl-Tidy/bin/perltidy) +* Perl6 + * [perl6 -c](https://perl6.org) :warning: +* PHP + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [intelephense](https://github.com/bmewburn/intelephense-docs) + * [langserver](https://github.com/felixfbecker/php-language-server) + * [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions + * [php -l](https://secure.php.net/) + * [php-cs-fixer](https://cs.symfony.com) + * [phpactor](https://github.com/phpactor/phpactor) + * [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) + * [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) + * [phpmd](https://phpmd.org) + * [phpstan](https://github.com/phpstan/phpstan) + * [pint](https://github.com/laravel/pint) :beer: + * [psalm](https://getpsalm.org) :floppy_disk: + * [tlint](https://github.com/tightenco/tlint) +* PO + * [alex](https://github.com/get-alex/alex) + * [msgfmt](https://www.gnu.org/software/gettext/manual/html_node/msgfmt-Invocation.html) + * [proselint](http://proselint.com/) + * [write-good](https://github.com/btford/write-good) +* Pod + * [alex](https://github.com/get-alex/alex) + * [proselint](http://proselint.com/) + * [write-good](https://github.com/btford/write-good) +* Pony + * [ponyc](https://github.com/ponylang/ponyc) +* PowerShell + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [powershell](https://github.com/PowerShell/PowerShell) + * [psscriptanalyzer](https://github.com/PowerShell/PSScriptAnalyzer) +* Prolog + * [swipl](https://github.com/SWI-Prolog/swipl-devel) +* proto + * [buf-format](https://github.com/bufbuild/buf) :floppy_disk: + * [buf-lint](https://github.com/bufbuild/buf) :floppy_disk: + * [protoc-gen-lint](https://github.com/ckaznocha/protoc-gen-lint) :floppy_disk: + * [protolint](https://github.com/yoheimuta/protolint) :floppy_disk: +* Pug + * [pug-lint](https://github.com/pugjs/pug-lint) +* Puppet + * [languageserver](https://github.com/lingua-pupuli/puppet-editor-services) + * [puppet](https://puppet.com) + * [puppet-lint](https://puppet-lint.com) +* PureScript + * [purescript-language-server](https://github.com/nwolverson/purescript-language-server) + * [purs-tidy](https://github.com/natefaubion/purescript-tidy) + * [purty](https://gitlab.com/joneshf/purty) +* Python + * [autoflake](https://github.com/myint/autoflake) :floppy_disk: + * [autoimport](https://lyz-code.github.io/autoimport/) + * [autopep8](https://github.com/hhatto/autopep8) + * [bandit](https://github.com/PyCQA/bandit) :warning: + * [black](https://github.com/psf/black) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [flake8](http://flake8.pycqa.org/en/latest/) + * [flakehell](https://github.com/flakehell/flakehell) + * [isort](https://github.com/timothycrosley/isort) + * [mypy](http://mypy-lang.org/) + * [prospector](https://github.com/PyCQA/prospector) :warning: :floppy_disk: + * [pycodestyle](https://github.com/PyCQA/pycodestyle) :warning: + * [pydocstyle](https://www.pydocstyle.org/) :warning: + * [pyflakes](https://github.com/PyCQA/pyflakes) + * [pyflyby](https://github.com/deshaw/pyflyby) :warning: + * [pylama](https://github.com/klen/pylama) :floppy_disk: + * [pylint](https://www.pylint.org/) :floppy_disk: + * [pylsp](https://github.com/python-lsp/python-lsp-server) :warning: + * [pyre](https://github.com/facebook/pyre-check) :warning: + * [pyright](https://github.com/microsoft/pyright) + * [reorder-python-imports](https://github.com/asottile/reorder_python_imports) + * [ruff](https://github.com/charliermarsh/ruff) + * [unimport](https://github.com/hakancelik96/unimport) + * [vulture](https://github.com/jendrikseipp/vulture) :warning: :floppy_disk: + * [yapf](https://github.com/google/yapf) +* QML + * [qmlfmt](https://github.com/jesperhh/qmlfmt) + * [qmllint](https://github.com/qt/qtdeclarative/tree/5.11/tools/qmllint) +* R + * [languageserver](https://github.com/REditorSupport/languageserver) + * [lintr](https://github.com/jimhester/lintr) + * [styler](https://github.com/r-lib/styler) +* Racket + * [racket-langserver](https://github.com/jeapostrophe/racket-langserver/tree/master) + * [raco](https://docs.racket-lang.org/raco/) + * [raco_fmt](https://docs.racket-lang.org/fmt/) +* Re:VIEW + * [redpen](http://redpen.cc/) +* ReasonML + * [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-reasonml-ols` for configuration instructions + * [ols](https://github.com/freebroccolo/ocaml-language-server) + * [reason-language-server](https://github.com/jaredly/reason-language-server) + * [refmt](https://github.com/reasonml/reason-cli) +* Rego + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [opacheck](https://www.openpolicyagent.org/docs/latest/cli/#opa-check) + * [opafmt](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) +* reStructuredText + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [proselint](http://proselint.com/) + * [redpen](http://redpen.cc/) + * [rstcheck](https://github.com/myint/rstcheck) + * [textlint](https://textlint.github.io/) + * [vale](https://github.com/ValeLint/vale) + * [write-good](https://github.com/btford/write-good) +* Robot + * [rflint](https://github.com/boakley/robotframework-lint) +* RPM spec + * [rpmlint](https://github.com/rpm-software-management/rpmlint) :warning: (see `:help ale-integration-spec`) +* Ruby + * [brakeman](http://brakemanscanner.org/) :floppy_disk: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [debride](https://github.com/seattlerb/debride) + * [prettier](https://github.com/prettier/plugin-ruby) + * [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) :floppy_disk: + * [reek](https://github.com/troessner/reek) + * [rubocop](https://github.com/bbatsov/rubocop) + * [ruby](https://www.ruby-lang.org) + * [rufo](https://github.com/ruby-formatter/rufo) + * [solargraph](https://solargraph.org) + * [sorbet](https://github.com/sorbet/sorbet) + * [standardrb](https://github.com/testdouble/standard) + * [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) +* Rust + * [cargo](https://github.com/rust-lang/cargo) :floppy_disk: (see `:help ale-integration-rust` for configuration instructions) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [rls](https://github.com/rust-lang-nursery/rls) :warning: + * [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning: + * [rustc](https://www.rust-lang.org/) :warning: + * [rustfmt](https://github.com/rust-lang-nursery/rustfmt) +* Salt + * [salt-lint](https://github.com/warpnet/salt-lint) +* Sass + * [sass-lint](https://www.npmjs.com/package/sass-lint) + * [stylelint](https://github.com/stylelint/stylelint) +* Scala + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html) + * [metals](https://scalameta.org/metals/) + * [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html) + * [scalac](http://scala-lang.org) + * [scalafmt](https://scalameta.org/scalafmt/) + * [scalastyle](http://www.scalastyle.org) +* SCSS + * [prettier](https://github.com/prettier/prettier) + * [sass-lint](https://www.npmjs.com/package/sass-lint) + * [scss-lint](https://github.com/brigade/scss-lint) + * [stylelint](https://github.com/stylelint/stylelint) +* Slim + * [slim-lint](https://github.com/sds/slim-lint) +* SML + * [smlnj](http://www.smlnj.org/) +* Solidity + * [solc](https://solidity.readthedocs.io/) + * [solhint](https://github.com/protofire/solhint) + * [solium](https://github.com/duaraghav8/Solium) +* SQL + * [dprint](https://dprint.dev) + * [pgformatter](https://github.com/darold/pgFormatter) + * [sql-lint](https://github.com/joereynolds/sql-lint) + * [sqlfmt](https://github.com/jackc/sqlfmt) + * [sqlformat](https://github.com/andialbrecht/sqlparse) + * [sqlint](https://github.com/purcell/sqlint) +* Stylus + * [stylelint](https://github.com/stylelint/stylelint) +* SugarSS + * [stylelint](https://github.com/stylelint/stylelint) +* Svelte + * [prettier](https://github.com/prettier/prettier) + * [svelteserver](https://github.com/sveltejs/language-tools/tree/master/packages/language-server) +* Swift + * [Apple swift-format](https://github.com/apple/swift-format) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [sourcekit-lsp](https://github.com/apple/sourcekit-lsp) + * [swiftformat](https://github.com/nicklockwood/SwiftFormat) + * [swiftlint](https://github.com/realm/SwiftLint) +* systemd + * [systemd-analyze](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html) :floppy_disk: +* Tcl + * [nagelfar](http://nagelfar.sourceforge.net) :floppy_disk: +* Terraform + * [checkov](https://github.com/bridgecrewio/checkov) + * [terraform](https://github.com/hashicorp/terraform) + * [terraform-fmt-fixer](https://github.com/hashicorp/terraform) + * [terraform-ls](https://github.com/hashicorp/terraform-ls) + * [terraform-lsp](https://github.com/juliosueiras/terraform-lsp) + * [tflint](https://github.com/wata727/tflint) + * [tfsec](https://github.com/aquasecurity/tfsec) +* Texinfo + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [proselint](http://proselint.com/) + * [write-good](https://github.com/btford/write-good) +* Text + * [alex](https://github.com/get-alex/alex) :warning: + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [languagetool](https://languagetool.org/) :floppy_disk: + * [proselint](http://proselint.com/) :warning: + * [redpen](http://redpen.cc/) :warning: + * [textlint](https://textlint.github.io/) :warning: + * [vale](https://github.com/ValeLint/vale) :warning: + * [write-good](https://github.com/btford/write-good) :warning: +* Thrift + * [thrift](http://thrift.apache.org/) + * [thriftcheck](https://github.com/pinterest/thriftcheck) +* TOML + * [dprint](https://dprint.dev) +* TypeScript + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [deno](https://deno.land/) + * [dprint](https://dprint.dev/) + * [eslint](http://eslint.org/) + * [fecs](http://fecs.baidu.com/) + * [prettier](https://github.com/prettier/prettier) + * [standard](http://standardjs.com/) + * [tslint](https://github.com/palantir/tslint) + * [tsserver](https://github.com/Microsoft/TypeScript/wiki/Standalone-Server-%28tsserver%29) + * typecheck +* V + * [v](https://github.com/vlang/v/) :floppy_disk: + * [vfmt](https://github.com/vlang/v/) +* VALA + * [uncrustify](https://github.com/uncrustify/uncrustify) + * [vala_lint](https://github.com/vala-lang/vala-lint) :floppy_disk: +* Verilog + * [hdl-checker](https://pypi.org/project/hdl-checker) + * [iverilog](https://github.com/steveicarus/iverilog) + * [verilator](http://www.veripool.org/projects/verilator/wiki/Intro) + * [vlog](https://www.mentor.com/products/fv/questa/) + * [xvlog](https://www.xilinx.com/products/design-tools/vivado.html) + * [yosys](http://www.clifford.at/yosys/) :floppy_disk: +* VHDL + * [ghdl](https://github.com/ghdl/ghdl) + * [vcom](https://www.mentor.com/products/fv/questa/) + * [xvhdl](https://www.xilinx.com/products/design-tools/vivado.html) +* Vim + * [vimls](https://github.com/iamcco/vim-language-server) + * [vint](https://github.com/Kuniwak/vint) +* Vim help + * [alex](https://github.com/get-alex/alex) :warning: + * [proselint](http://proselint.com/) :warning: + * [write-good](https://github.com/btford/write-good) :warning: +* Vue + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [prettier](https://github.com/prettier/prettier) + * [vls](https://github.com/vuejs/vetur/tree/master/server) + * [volar](https://github.com/johnsoncodehk/volar) +* WGSL + * [naga](https://github.com/gfx-rs/naga) +* XHTML + * [alex](https://github.com/get-alex/alex) + * [cspell](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) + * [proselint](http://proselint.com/) + * [write-good](https://github.com/btford/write-good) +* XML + * [xmllint](http://xmlsoft.org/xmllint.html) +* YAML + * [actionlint](https://github.com/rhysd/actionlint) :warning: + * [circleci](https://circleci.com/docs/2.0/local-cli) :floppy_disk: :warning: + * [gitlablint](https://github.com/elijah-roberts/gitlab-lint) + * [prettier](https://github.com/prettier/prettier) + * [spectral](https://github.com/stoplightio/spectral) + * [swaglint](https://github.com/byCedric/swaglint) :warning: + * [yaml-language-server](https://github.com/redhat-developer/yaml-language-server) + * [yamlfix](https://lyz-code.github.io/yamlfix) + * [yamllint](https://yamllint.readthedocs.io/) +* YANG + * [yang-lsp](https://github.com/theia-ide/yang-lsp) +* Zeek + * [zeek](http://zeek.org) :floppy_disk: +* Zig + * [zigfmt](https://github.com/ziglang/zig) + * [zls](https://github.com/zigtools/zls) diff --git a/sources_non_forked/ale/syntax/ale-fix-suggest.vim b/sources_non_forked/ale/syntax/ale-fix-suggest.vim new file mode 100644 index 00000000..b112f5b5 --- /dev/null +++ b/sources_non_forked/ale/syntax/ale-fix-suggest.vim @@ -0,0 +1,13 @@ +if exists('b:current_syntax') + finish +endif + +syn match aleFixerComment /^.*$/ +syn match aleFixerName /\(^\|, \)'[^']*'/ +syn match aleFixerHelp /^See :help ale-fix-configuration/ + +hi def link aleFixerComment Comment +hi def link aleFixerName String +hi def link aleFixerHelp Statement + +let b:current_syntax = 'ale-fix-suggest' diff --git a/sources_non_forked/ale/syntax/ale-preview-selection.vim b/sources_non_forked/ale/syntax/ale-preview-selection.vim new file mode 100644 index 00000000..879ba096 --- /dev/null +++ b/sources_non_forked/ale/syntax/ale-preview-selection.vim @@ -0,0 +1,11 @@ +if exists('b:current_syntax') + finish +endif + +syn match alePreviewSelectionFilename /\v^([a-zA-Z]?:?[^:]+)/ +syn match alPreviewNumber /\v:\d+:\d+$/ + +hi def link alePreviewSelectionFilename String +hi def link alePreviewNumber Number + +let b:current_syntax = 'ale-preview-selection' diff --git a/sources_non_forked/auto-pairs/.gitignore b/sources_non_forked/auto-pairs/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/auto-pairs/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/auto-pairs/README.md b/sources_non_forked/auto-pairs/README.md new file mode 100644 index 00000000..8d079ba6 --- /dev/null +++ b/sources_non_forked/auto-pairs/README.md @@ -0,0 +1,411 @@ +Auto Pairs +========== +Insert or delete brackets, parens, quotes in pair. + +Installation +------------ + +* Manual + * Copy `plugin/auto-pairs.vim` to `~/.vim/plugin` +* [Pathogen](https://github.com/tpope/vim-pathogen) + * `git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs` +* [Vundle](https://github.com/VundleVim/Vundle.vim) + * `Plugin 'jiangmiao/auto-pairs'` + +Features +-------- +* Insert in pair + + input: [ + output: [|] + +* Delete in pair + + input: foo[] + output: foo + +* Insert new indented line after Return + + input: {|} (press at |) + output: { + | + } (press } to close the pair) + output: { + }| (the inserted blank line will be deleted) + + +* Insert spaces before closing characters, only for [], (), {} + + input: {|} (press at |) + output: { | } + + input: {|} (press foo} at |) + output: { foo }| + + input: '|' (press at |) + output: ' |' + +* Skip ' when inside a word + + input: foo| (press ' at |) + output: foo' + +* Skip closed bracket. + + input: [] + output: [] + +* Ignore auto pair when previous character is \ + + input: "\' + output: "\'" + +* Fast Wrap + + input: |[foo, bar()] (press ( at |) + output: ([foo, bar()]) + +* Quick move char to closed pair + + input: (|){["foo"]} (press at |) + output: ({["foo"]}|) + + input: |[foo, bar()] (press ( at |) + output: ([foo, bar()]|) + +* Quick jump to closed pair. + + input: + { + something;| + } + + (press } at |) + + output: + { + + }| + +* Fly Mode + + input: if(a[3) + output: if(a[3])| (In Fly Mode) + output: if(a[3)]) (Without Fly Mode) + + input: + { + hello();| + world(); + } + + (press } at |) + + output: + { + hello(); + world(); + }| + + (then press at | to do backinsert) + output: + { + hello();}| + world(); + } + + See Fly Mode section for details + +* Multibyte Pairs + + Support any multibyte pairs such as , <% %>, """ """ + See multibyte pairs section for details + +Fly Mode +-------- +Fly Mode will always force closed-pair jumping instead of inserting. only for ")", "}", "]" + +If jumps in mistake, could use AutoPairsBackInsert(Default Key: ``) to jump back and insert closed pair. + +the most situation maybe want to insert single closed pair in the string, eg ")" + +Fly Mode is DISABLED by default. + +add **let g:AutoPairsFlyMode = 1** .vimrc to turn it on + +Default Options: + + let g:AutoPairsFlyMode = 0 + let g:AutoPairsShortcutBackInsert = '' + +Shortcuts +--------- + + System Shortcuts: + : Insert new indented line after return if cursor in blank brackets or quotes. + : Delete brackets in pair + : Toggle Autopairs (g:AutoPairsShortcutToggle) + : Fast Wrap (g:AutoPairsShortcutFastWrap) + : Jump to next closed pair (g:AutoPairsShortcutJump) + : BackInsert (g:AutoPairsShortcutBackInsert) + + If or conflict with another keys or want to bind to another keys, add + + let g:AutoPairsShortcutToggle = '' + + to .vimrc, if the key is empty string '', then the shortcut will be disabled. + +Options +------- +* g:AutoPairs + + Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''"} + +* b:AutoPairs + + Default: g:AutoPairs + + Buffer level pairs set. + +* g:AutoPairsShortcutToggle + + Default: '' + + The shortcut to toggle autopairs. + +* g:AutoPairsShortcutFastWrap + + Default: '' + + Fast wrap the word. all pairs will be consider as a block (include <>). + (|)'hello' after fast wrap at |, the word will be ('hello') + (|) after fast wrap at |, the word will be () + +* g:AutoPairsShortcutJump + + Default: '' + + Jump to the next closed pair + +* g:AutoPairsMapBS + + Default : 1 + + Map to delete brackets, quotes in pair + execute 'inoremap =AutoPairsDelete()' + +* g:AutoPairsMapCh + + Default : 1 + + Map to delete brackets, quotes in pair + +* g:AutoPairsMapCR + + Default : 1 + + Map to insert a new indented line if cursor in (|), {|} [|], '|', "|" + execute 'inoremap =AutoPairsReturn()' + +* g:AutoPairsCenterLine + + Default : 1 + + When g:AutoPairsMapCR is on, center current line after return if the line is at the bottom 1/3 of the window. + +* g:AutoPairsMapSpace + + Default : 1 + + Map to insert a space after the opening character and before the closing one. + execute 'inoremap =AutoPairsSpace()' + +* g:AutoPairsFlyMode + + Default : 0 + + set it to 1 to enable FlyMode. + see FlyMode section for details. + +* g:AutoPairsMultilineClose + + Default : 1 + + When you press the key for the closing pair (e.g. `)`) it jumps past it. + If set to 1, then it'll jump to the next line, if there is only whitespace. + If set to 0, then it'll only jump to a closing pair on the same line. + +* g:AutoPairsShortcutBackInsert + + Default : + + Work with FlyMode, insert the key at the Fly Mode jumped postion + +* g:AutoPairsMoveCharacter + + Default: "()[]{}\"'" + + Map to + move character under the cursor to the pair. + +Buffer Level Pairs Setting +-------------------------- + +Set b:AutoPairs before BufEnter + +eg: + + " When the filetype is FILETYPE then make AutoPairs only match for parenthesis + au Filetype FILETYPE let b:AutoPairs = {"(": ")"} + au FileType php let b:AutoPairs = AutoPairsDefine({'', ''}) + +Multibyte Pairs +--------------- + + The default pairs is {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + You could also define multibyte pairs such as , <% %> and so on + +* Function AutoPairsDefine(addPairs:dict[, removeOpenPairList:list]) + + add or delete pairs base on g:AutoPairs + + eg: + au FileType html let b:AutoPairs = AutoPairsDefine({''}, ['{']) + add pair and remove '{' for html file + + the pair implict start with \V, so if want to match start of line ^ should be write in \^ vim comment {'\^"': ''} + +* General usage + + au FileType php let b:AutoPairs = AutoPairsDefine({'', ''}) + + the first key of closed pair ? will be mapped + + pairs: '', '' + input: + + input: + + input: he (press at|) + output: he| + + input: (press ? at|) + output: | + + pair: '[[':']]' + input: [[|]] (press ) + output: | ([[ and ]] will be deleted the [['s priority is higher than [ for it's longer) + +* Modifier + + The text after // in close pair is modifiers + + n - do not map the first charactor of closed pair to close key + m - close key jumps through multi line + s - close key jumps only in the same line + k[KEY] - map the close key to [KEY] + + by default if open key equals close key the multi line is turn off + + "" ? jumps only in the same line + "//m" force ? jumping through multi line + "" ? will jump through multi line + "//s" force ? only jumping in the same line + "//n" do not jump totally + "//k]" use key ] to jump through ?> + + for 'begin' 'end' pair, e is a charactor, if map e to jump will be annoy, so use modifier 'n' to skip key map + + au FileType ruby let b:AutoPairs = AutoPairsDefine({'begin': 'end//n]'}) + + + input: begin + output: begin|end + + input: begin|end (press on |) + output: | + + input: begin|end (press e on |) + output: begineend (will not jump for e is not mapped) + +* Advanced usage + + au FileType rust let b:AutoPairs = AutoPairsDefine({'\w\zs<': '>'}) + + if press < after a word will generate the pair + + when use regexp MUST use \zs to prevent catching + if use '\w<' without \zs, for text hello<|> press on | will output 'hell', the 'o' has been deleted + + pair: '\w\zs<': '>' + input: h < + output: h < + + input: h< + output: h<|> + + input: h<|> press + output: h| + + pair: '\w<': '>' (WRONG pair which missed \zs) + input: h<|> press + output: | (charactor 'h' is deleted) + + + the 'begin' 'end' pair write in + + au FileType ruby let b:AutoPairs = AutoPairsDefine({'\v(^|\W)\zsbegin': 'end//n'}) + + will be better, only auto pair when at start of line or follow non-word text + +TroubleShooting +--------------- + The script will remap keys ([{'"}]) , + If auto pairs cannot work, use :imap ( to check if the map is corrected. + The correct map should be =AutoPairsInsert("\(") + Or the plugin conflict with some other plugins. + use command :call AutoPairsInit() to remap the keys. + + +* How to insert parens purely + + There are 3 ways + + 1. use Ctrl-V ) to insert paren without trigger the plugin. + + 2. use Alt-P to turn off the plugin. + + 3. use DEL or x to delete the character insert by plugin. + +* Swedish Character Conflict + + Because AutoPairs uses Meta(Alt) key as shortcut, it is conflict with some Swedish character such as å. + To fix the issue, you need remap or disable the related shortcut. + +Known Issues +------------ +Breaks '.' - [issue #3](https://github.com/jiangmiao/auto-pairs/issues/3) + + Description: After entering insert mode and inputing `[hello` then leave insert + mode by ``. press '.' will insert 'hello' instead of '[hello]'. + Reason: `[` actually equals `[]\` and \ will break '.'. + After version 7.4.849, Vim implements new keyword U to avoid the break + Solution: Update Vim to 7.4.849+ + +Contributors +------------ +* [camthompson](https://github.com/camthompson) + + +License +------- + +Copyright (C) 2011-2013 Miao Jiang + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/sources_non_forked/auto-pairs/doc/AutoPairs.txt b/sources_non_forked/auto-pairs/doc/AutoPairs.txt new file mode 100644 index 00000000..afe589ef --- /dev/null +++ b/sources_non_forked/auto-pairs/doc/AutoPairs.txt @@ -0,0 +1,356 @@ +*AutoPairs.txt* Insert or delete brackets, parens, quotes in pair + +Author: jiangmiao +License: MIT +URL: https://github.com/jiangmiao/auto-pairs + +============================================================================== +CONTENTS *autopairs-contents* + + 1. Installation ............................. |autopairs-installation| + 2. Features ..................................... |autopairs-features| + 3. Fly Mode ..................................... |autopairs-fly-mode| + 4. Shortcuts ................................... |autopairs-shortcuts| + 5. Options ....................................... |autopairs-options| + 6. Troubleshooting ...................... |autopairs-troubleshooting| + +============================================================================== +1. Introduction *autopairs-installation* + +Copy `plugin/auto-pairs.vim` to `~/.vim/plugin`. + +Or if you are using `pathogen`: > + + git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs + +============================================================================== +2. Features *autopairs-features* + +Insert in pair: > + + input: [ + output: [|] + +Delete in pair: > + + input: foo[] + output: foo + +Insert new indented line after Return: > + + input: {|} (press at |) + output: { + | + } + +Insert spaces before closing characters, only for [], (), {}: > + + input: {|} (press at |) + output: { | } + + input: {|} (press foo} at |) + output: { foo }| + + input: '|' (press at |) + output: ' |' + +Skip ' when inside a word: > + + input: foo| (press ' at |) + output: foo' + +Skip closed bracket: > + + input: [] + output: [] + +Ignore auto pair when previous character is '\': > + + input: "\' + output: "\'" + +Fast Wrap: > + + input: |'hello' (press ( at |) + output: ('hello') + + Wrap string, only support c style string. + input: |'h\\el\'lo' (press ( at |) + output ('h\\ello\'') + + input: |[foo, bar()] (press ( at |) + output: ([foo, bar()]) + +Quick jump to closed pair: > + + input: + { + something;| + } + + (press } at |) + + output: + { + + }| + +Support ```, ''' and """: > + + input: + ''' + + output: + '''|''' + +Delete Repeated Pairs in one time: > + + input: """|""" (press at |) + output: | + + input: {{|}} (press at |) + output: | + + input: [[[[[[|]]]]]] (press at |) + output: | + +Fly Mode (|autopairs-flymode|): > + + input: if(a[3) + output: if(a[3])| (In Fly Mode) + output: if(a[3)]) (Without Fly Mode) + + input: + { + hello();| + world(); + } + + (press } at |) + + output: + { + hello(); + world(); + }| + + (then press at | to do backinsert) + output: + { + hello();}| + world(); + } + + See |Fly Mode| section for details + +============================================================================== +3. Fly Mode *autopairs-flymode* + +Fly Mode will always force closed-pair jumping instead of inserting. Only for +")", "}", "]". If jumps in mistake, you can use |g:AutoPairsBackInsert| (default +Key: ) to jump back and insert closed pair. + +The most situation maybe you want to insert single closed pair in the string, +eg: > + + ")" + +Fly Mode is DISABLED by default. To enable Fly Mode add following to your +'.vimrc': > + + let g:AutoPairsFlyMode = 1 + +Default Options: > + + let g:AutoPairsFlyMode = 0 + let g:AutoPairsShortcutBackInsert = '' + +============================================================================== +4. Shortcuts *autopairs-shortcuts* + +System Shortcuts: + : Insert new indented line after return if cursor in blank brackets + or quotes. + : Delete brackets in pair + : Toggle Autopairs (|g:AutoPairsShortcutToggle|) + : Fast Wrap (|g:AutoPairsShortcutFastWrap|) + : Jump to next closed pair (|g:AutoPairsShortcutJump|) + : BackInsert (|g:AutoPairsShortcutBackInsert|) + + + To rebind keys , or or in case of conflicts with + another keys: + + let g:AutoPairsShortcutToggle = '' + + If the key is empty string '', then the shortcut will be disabled. + +============================================================================== +5. Options *autopairs-options* + + *g:AutoPairs* +|g:AutoPairs| dict + +Default: > + {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '`':'`'} + +Specifies which symbols should be automatically paired. + +To append new pairs without overwriting defaults, add values in your `.vimrc`.: + + let g:AutoPairs['<']='>' + +This example will enable matching of `<` with `>`. + + + *b:AutoPairs* +|b:AutoPairs| dict + +Default: |g:AutoPairs| + +Buffer level pairs set. + +You can set |b:AutoPairs| before |BufEnter|: > + + au Filetype FILETYPE let b:AutoPairs = {"(": ")"} + +This sets |AutoPairs| to only match for parenthesis for 'FILETYPE'. + + + + *g:AutoPairsShortcutToggle* +|g:AutoPairsShortcutToggle| string + +Default: + +The shortcut to toggle autopairs. + + + + *g:AutoPairsShortcutFastWrap* +|g:AutoPairsShortcutFastWrap| string + +Default: + +Fast wrap the word. All pairs will be considered as a block (including <>). + + (|)'hello' after fast wrap at |, the word will be ('hello') + (|) after fast wrap at |, the word will be () + + + + *g:AutoPairsShortcutJump* +|g:AutoPairsShortcutJump| string + +Default: + +Jump to the next closed pair. + + + *g:AutoPairsShortcutBackInsert* +|g:AutoPairsShortcutBackInsert| string + +Default: + +Work with |autopairs-flymode|, insert the key at the Fly Mode jumped position. + + + + *g:AutoPairsMapBS* +|g:AutoPairsMapBS| int + +Default: 1 + +Map to delete brackets and quotes in pair, executes: + + inoremap =AutoPairsDelete() + + + *g:AutoPairsMapCh* +|g:AutoPairsMapCh| int + +Default: 1 + +Map to delete brackets and quotes in pair. + + + *g:AutoPairsMapCR* +|g:AutoPairsMapCR| int + +Default: 1 + +Map to insert a new indented line if cursor in (|), {|} [|], '|', "|". +Executes: + + inoremap =AutoPairsReturn() + + + *g:AutoPairsCenterLine* +|g:AutoPairsCenterLine| int + +Default: 1 + +When |g:AutoPairsMapCR| is on, center current line after return if the line +is at the bottom 1/3 of the window. + + + *g:AutoPairsMapSpace* +|g:AutoPairsMapSpace| int + +Default: 1 + +Map to insert a space after the opening character and before the +closing one. + +Executes: + + inoremap =AutoPairsSpace() + + + *g:AutoPairsFlyMode* +|g:AutoPairsFlyMode| int + +Default: 0 + +Set it to 1 to enable |autopairs-flymode|. + + + *g:AutoPairsMultilineClose* +|g:AutoPairsMultilineClose| int + +Default: 1 + +When you press the key for the closing pair (e.g. `)`) it jumps past it. +If set to 1, then it'll jump to the next line, if there is only 'whitespace'. +If set to 0, then it'll only jump to a closing pair on the same line. + +============================================================================== +6. Troubleshooting *autopairs-troubleshooting* + +This plugin remaps keys `([{'"}]) ` + +If auto pairs cannot work, use |:imap| to check if the map is corrected. + +The correct map should be: > + + =AutoPairsInsert("\(") + +Or the plugin conflicts with some other plugins. Use command: > + + :call AutoPairsInit() to remap the keys. + +--- How to insert parens purely? --- + +There are 3 ways: + + 1. Use Ctrl-V ) to insert paren without trigger the plugin. + + 2. Use Alt-P to turn off the plugin. + + 3. Use DEL or x to delete the character insert by plugin. + +--- Swedish Character Conflict --- + +Because AutoPairs uses Meta(Alt) key as a shortcut, it conflicts with some +Swedish character such as å. To fix the issue, you need remap or disable the +related shortcut. diff --git a/sources_non_forked/auto-pairs/plugin/auto-pairs.vim b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim new file mode 100644 index 00000000..af5eb32a --- /dev/null +++ b/sources_non_forked/auto-pairs/plugin/auto-pairs.vim @@ -0,0 +1,673 @@ +" Insert or delete brackets, parens, quotes in pairs. +" Maintainer: JiangMiao +" Contributor: camthompson +" Last Change: 2019-02-02 +" Version: 2.0.0 +" Homepage: http://www.vim.org/scripts/script.php?script_id=3599 +" Repository: https://github.com/jiangmiao/auto-pairs +" License: MIT + +if exists('g:AutoPairsLoaded') || &cp + finish +end +let g:AutoPairsLoaded = 1 + +if !exists('g:AutoPairs') + let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"} +end + +" default pairs base on filetype +func! AutoPairsDefaultPairs() + if exists('b:autopairs_defaultpairs') + return b:autopairs_defaultpairs + end + let r = copy(g:AutoPairs) + let allPairs = { + \ 'vim': {'\v^\s*\zs"': ''}, + \ 'rust': {'\w\zs<': '>', '&\zs''': ''}, + \ 'php': {'//k]', '//k]'} + \ } + for [filetype, pairs] in items(allPairs) + if &filetype == filetype + for [open, close] in items(pairs) + let r[open] = close + endfor + end + endfor + let b:autopairs_defaultpairs = r + return r +endf + +if !exists('g:AutoPairsMapBS') + let g:AutoPairsMapBS = 1 +end + +" Map as the same BS +if !exists('g:AutoPairsMapCh') + let g:AutoPairsMapCh = 1 +end + +if !exists('g:AutoPairsMapCR') + let g:AutoPairsMapCR = 1 +end + +if !exists('g:AutoPairsWildClosedPair') + let g:AutoPairsWildClosedPair = '' +end + +if !exists('g:AutoPairsMapSpace') + let g:AutoPairsMapSpace = 1 +end + +if !exists('g:AutoPairsCenterLine') + let g:AutoPairsCenterLine = 1 +end + +if !exists('g:AutoPairsShortcutToggle') + let g:AutoPairsShortcutToggle = '' +end + +if !exists('g:AutoPairsShortcutFastWrap') + let g:AutoPairsShortcutFastWrap = '' +end + +if !exists('g:AutoPairsMoveCharacter') + let g:AutoPairsMoveCharacter = "()[]{}\"'" +end + +if !exists('g:AutoPairsShortcutJump') + let g:AutoPairsShortcutJump = '' +endif + +" Fly mode will for closed pair to jump to closed pair instead of insert. +" also support AutoPairsBackInsert to insert pairs where jumped. +if !exists('g:AutoPairsFlyMode') + let g:AutoPairsFlyMode = 0 +endif + +" When skipping the closed pair, look at the current and +" next line as well. +if !exists('g:AutoPairsMultilineClose') + let g:AutoPairsMultilineClose = 1 +endif + +" Work with Fly Mode, insert pair where jumped +if !exists('g:AutoPairsShortcutBackInsert') + let g:AutoPairsShortcutBackInsert = '' +endif + +if !exists('g:AutoPairsSmartQuotes') + let g:AutoPairsSmartQuotes = 1 +endif + +" 7.4.849 support U to avoid breaking '.' +" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3 +" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849 +if v:version > 704 || v:version == 704 && has("patch849") + let s:Go = "\U" +else + let s:Go = "" +endif + +let s:Left = s:Go."\" +let s:Right = s:Go."\" + + + + +" unicode len +func! s:ulen(s) + return len(split(a:s, '\zs')) +endf + +func! s:left(s) + return repeat(s:Left, s:ulen(a:s)) +endf + +func! s:right(s) + return repeat(s:Right, s:ulen(a:s)) +endf + +func! s:delete(s) + return repeat("\", s:ulen(a:s)) +endf + +func! s:backspace(s) + return repeat("\", s:ulen(a:s)) +endf + +func! s:getline() + let line = getline('.') + let pos = col('.') - 1 + let before = strpart(line, 0, pos) + let after = strpart(line, pos) + let afterline = after + if g:AutoPairsMultilineClose + let n = line('$') + let i = line('.')+1 + while i <= n + let line = getline(i) + let after = after.' '.line + if !(line =~ '\v^\s*$') + break + end + let i = i+1 + endwhile + end + return [before, after, afterline] +endf + +" split text to two part +" returns [orig, text_before_open, open] +func! s:matchend(text, open) + let m = matchstr(a:text, '\V'.a:open.'\v$') + if m == "" + return [] + end + return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m] +endf + +" returns [orig, close, text_after_close] +func! s:matchbegin(text, close) + let m = matchstr(a:text, '^\V'.a:close) + if m == "" + return [] + end + return [a:text, m, strpart(a:text, len(m), len(a:text)-len(m))] +endf + +" add or delete pairs base on g:AutoPairs +" AutoPairsDefine(addPairs:dict[, removeOpenPairList:list]) +" +" eg: +" au FileType html let b:AutoPairs = AutoPairsDefine({''}, ['{']) +" add pair and remove '{' for html file +func! AutoPairsDefine(pairs, ...) + let r = AutoPairsDefaultPairs() + if a:0 > 0 + for open in a:1 + unlet r[open] + endfor + end + for [open, close] in items(a:pairs) + let r[open] = close + endfor + return r +endf + +func! AutoPairsInsert(key) + if !b:autopairs_enabled + return a:key + end + + let b:autopairs_saved_pair = [a:key, getpos('.')] + + let [before, after, afterline] = s:getline() + + " Ignore auto close if prev character is \ + if before[-1:-1] == '\' + return a:key + end + + " check open pairs + for [open, close, opt] in b:AutoPairsList + let ms = s:matchend(before.a:key, open) + let m = matchstr(afterline, '^\v\s*\zs\V'.close) + if len(ms) > 0 + " process the open pair + + " remove inserted pair + " eg: if the pairs include < > and + " when + +### What happened + +### What I expected to happen + +### Screenshot + +### Machine Info + +- **Vim type (`vim`/`gvim`/`neovim`)**: +- **Vim version**: +- **OS**: +- **Terminal/Terminal Emulator/VTE**: +- **`TERM` environment variable**: + +### Additional Info + + diff --git a/sources_non_forked/dracula/.github/pull_request_template.md b/sources_non_forked/dracula/.github/pull_request_template.md new file mode 100644 index 00000000..b2a1becd --- /dev/null +++ b/sources_non_forked/dracula/.github/pull_request_template.md @@ -0,0 +1,5 @@ + + diff --git a/sources_non_forked/dracula/.gitignore b/sources_non_forked/dracula/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/dracula/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/dracula/INSTALL.md b/sources_non_forked/dracula/INSTALL.md new file mode 100644 index 00000000..0868adcc --- /dev/null +++ b/sources_non_forked/dracula/INSTALL.md @@ -0,0 +1,97 @@ +### [Vim](http://www.vim.org/) + +#### Install + +These are the default instructions using Vim 8's `|packages|` feature. See +sections below, if you use other plugin managers. + +1. Create theme folder (in case you don't have yet): + + +- \*nix: +``` +mkdir -p ~/.vim/pack/themes/start +``` + +- Windows: create directory `$HOME\vimfiles\pack\themes\start` + +If you use vim 8.0 (and not 8.2), you may need to use `~/.vim/pack/themes/opt` +or `$HOME\vimfiles\pack\themes\opt` instead. + +2. Navigate to the folder above: + + +- \*nix: +``` +cd ~/.vim/pack/themes/start +``` + +- Windows: navigate to `$HOME\vimfiles\pack\themes\start` + +3. Clone the repository using the "dracula" name: + +``` +git clone https://github.com/dracula/vim.git dracula +``` +(Or use your favorite GUI client, or download the ZIP) + +4. Edit your `vimrc` file with the following content: + +``` +packadd! dracula +syntax enable +colorscheme dracula +``` + +The location of the `vimrc` varies between platforms: +- \*nix: `~/.vim/vimrc` or `~/.vimrc` +- Windows: `$HOME\vimfiles\vimrc` or `$HOME\_vimrc` + +#### Install using other plugin managers + +- If you [use vim + pathogen + submodules](http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/): + +Navigate to your vim directory (\*nix: `~/.vim`; Windows: `$HOME\vimfiles`) + + git submodule add git@github.com:dracula/vim.git bundle/dracula + +Place `colorscheme dracula` after `execute pathogen#infect()`. + +- If you [use vim + vundle](https://github.com/VundleVim/Vundle): + +```vim +Plugin 'dracula/vim', { 'name': 'dracula' } +:PluginInstall +``` + +Place `colorscheme dracula` after `call vundle#end()`. + +- If you [use vim-plug](https://github.com/junegunn/vim-plug) (\`as\` will install +the plugin in a directory called 'dracula' instead of just 'vim'): + +```vim +Plug 'dracula/vim', { 'as': 'dracula' } +:PlugInstall +``` + +Place `colorscheme dracula` after `call plug#end()`. + +- If you [use spacevim](https://spacevim.org), put the +following in `~/.SpaceVim.d/init.toml`: + +```toml +[options] + colorscheme = "dracula" + colorscheme_bg = "dark" +[[custom_plugins]] + repo = "dracula/vim" + name = "dracula" + merged = false +``` + +--- + +Note that dracula must be in your `'runtimepath'` to load properly: Version 2.0 +introduced autoload functionality for part of the plugin, which doesn't work +without `'runtimepath'` properly set. Consult your plugin-managers documentation +to make sure you put dracula on the `'runtimepath'` before loading it. diff --git a/sources_non_forked/dracula/LICENSE b/sources_non_forked/dracula/LICENSE new file mode 100644 index 00000000..dcaf6d7f --- /dev/null +++ b/sources_non_forked/dracula/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Dracula Theme + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sources_non_forked/dracula/README.md b/sources_non_forked/dracula/README.md new file mode 100644 index 00000000..d84d6db8 --- /dev/null +++ b/sources_non_forked/dracula/README.md @@ -0,0 +1,31 @@ +# Dracula for [Vim](http://www.vim.org/) + +> A dark theme for [Vim](http://www.vim.org/). + +![Screenshot](./screenshot.png) + +Screenshot taken with the [pangloss/vim-javascript](https://github.com/pangloss/vim-javascript) +syntax plugin for javascript. + +## Install + +All instructions can be found at [draculatheme.com/vim](https://draculatheme.com/vim). + +## Team + +This theme is maintained by the following person(s) and a bunch of +[awesome contributors](https://github.com/dracula/vim/graphs/contributors). + +| [![Derek S.](https://avatars3.githubusercontent.com/u/5240018?v=3&s=70)](https://github.com/dsifford) | [![David Knoble](https://avatars0.githubusercontent.com/u/22802209?v=4&s=70)](https://github.com/benknoble) | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| [Derek S.](https://github.com/dsifford) | [David Knoble](https://github.com/benknoble) | + +## Community + +- [Twitter](https://twitter.com/draculatheme) - Best for getting updates about themes and new stuff. +- [GitHub](https://github.com/dracula/dracula-theme/discussions) - Best for asking questions and discussing issues. +- [Discord](https://draculatheme.com/discord-invite) - Best for hanging out with the community. + +## License + +[MIT License](./LICENSE) diff --git a/sources_non_forked/dracula/after/plugin/dracula.vim b/sources_non_forked/dracula/after/plugin/dracula.vim new file mode 100644 index 00000000..6f1d12f7 --- /dev/null +++ b/sources_non_forked/dracula/after/plugin/dracula.vim @@ -0,0 +1,190 @@ +if dracula#should_abort() + finish +endif + +" Fzf: {{{ +if exists('g:loaded_fzf') && ! exists('g:fzf_colors') + let g:fzf_colors = { + \ 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Search'], + \ 'fg+': ['fg', 'Normal'], + \ 'bg+': ['bg', 'Normal'], + \ 'hl+': ['fg', 'DraculaOrange'], + \ 'info': ['fg', 'DraculaPurple'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'DraculaGreen'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'], + \} +endif +"}}} +" ALE: {{{ +if exists('g:ale_enabled') + hi! link ALEError DraculaErrorLine + hi! link ALEWarning DraculaWarnLine + hi! link ALEInfo DraculaInfoLine + + hi! link ALEErrorSign DraculaRed + hi! link ALEWarningSign DraculaOrange + hi! link ALEInfoSign DraculaCyan + + hi! link ALEVirtualTextError Comment + hi! link ALEVirtualTextWarning Comment +endif +" }}} +" CtrlP: {{{ +if exists('g:loaded_ctrlp') + hi! link CtrlPMatch IncSearch + hi! link CtrlPBufferHid Normal +endif +" }}} +" GitGutter / gitsigns: {{{ +if exists('g:loaded_gitgutter') + hi! link GitGutterAdd DiffAdd + hi! link GitGutterChange DiffChange + hi! link GitGutterDelete DiffDelete +endif +if has('nvim-0.5') && luaeval("pcall(require, 'gitsigns')") + " https://github.com/lewis6991/gitsigns.nvim requires nvim > 0.5 + " has('nvim-0.5') checks >= 0.5, so this should be future-proof. + hi! link GitSignsAdd DiffAdd + hi! link GitSignsAddLn DiffAdd + hi! link GitSignsAddNr DiffAdd + hi! link GitSignsChange DiffChange + hi! link GitSignsChangeLn DiffChange + hi! link GitSignsChangeNr DiffChange + hi! link GitSignsDelete DiffDelete + hi! link GitSignsDeleteLn DiffDelete + hi! link GitSignsDeleteNr DiffDelete +endif +" }}} +" Tree-sitter: {{{ +" The nvim-treesitter library defines many global highlight groups that are +" linked to the regular vim syntax highlight groups. We only need to redefine +" those highlight groups when the defaults do not match the dracula +" specification. +" https://github.com/nvim-treesitter/nvim-treesitter/blob/master/plugin/nvim-treesitter.vim +if exists('g:loaded_nvim_treesitter') + " deprecated TS* highlight groups + " see https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 + " # Misc + hi! link TSPunctSpecial Special + " # Constants + hi! link TSConstMacro Macro + hi! link TSStringEscape Character + hi! link TSSymbol DraculaPurple + hi! link TSAnnotation DraculaYellow + hi! link TSAttribute DraculaGreenItalic + " # Functions + hi! link TSFuncBuiltin DraculaCyan + hi! link TSFuncMacro Function + hi! link TSParameter DraculaOrangeItalic + hi! link TSParameterReference DraculaOrange + hi! link TSField DraculaOrange + hi! link TSConstructor DraculaCyan + " # Keywords + hi! link TSLabel DraculaPurpleItalic + " # Variable + hi! link TSVariableBuiltin DraculaPurpleItalic + " # Text + hi! link TSStrong DraculaFgBold + hi! link TSEmphasis DraculaFg + hi! link TSUnderline Underlined + hi! link TSTitle DraculaYellow + hi! link TSLiteral DraculaYellow + hi! link TSURI DraculaYellow + " HTML and JSX tag attributes. By default, this group is linked to TSProperty, + " which in turn links to Identifer (white). + hi! link TSTagAttribute DraculaGreenItalic + + if has('nvim-0.8') + " # Misc + hi! link @punctuation.delimiter Delimiter + hi! link @punctuation.bracket Normal + hi! link @punctuation.special Special + " # Constants + hi! link @constant Constant + hi! link @constant.builtin Constant + hi! link @constant.macro Macro + hi! link @string.regex String + hi! link @string.escape Character + hi! link @symbol DraculaPurple + hi! link @annotation DraculaYellow + hi! link @attribute DraculaGreenItalic + hi! link @namespace Structure + " # Functions + hi! link @function.builtin DraculaCyan + hi! link @funcion.macro Function + hi! link @parameter DraculaOrangeItalic + hi! link @parameter.reference DraculaOrange + hi! link @field DraculaOrange + hi! link @property Normal + hi! link @constructor DraculaCyan + " # Keywords + hi! link @label DraculaPurpleItalic + hi! link @keyword.function DraculaPink + hi! link @keyword.operator Operator + hi! link @exception DraculaPurple + " # Variable + hi! link @variable Normal + hi! link @variable.builtin DraculaPurpleItalic + " # Text + hi! link @text Normal + hi! link @text.strong DraculaFgBold + hi! link @text.emphasis DraculaFg + hi! link @text.underline Underlined + hi! link @text.title DraculaYellow + hi! link @text.literal DraculaYellow + hi! link @text.uri DraculaYellow + " # Tags + hi! link @tag DraculaCyan + hi! link @tag.delimiter Normal + " HTML and JSX tag attributes. By default, this group is linked to TSProperty, + " which in turn links to Identifer (white). + hi! link @tag.attribute DraculaGreenItalic + endif +endif +" }}} +" nvim-cmp: {{{ +" A completion engine plugin for neovim written in Lua. +" https://github.com/hrsh7th/nvim-cmp +if exists('g:loaded_cmp') + hi! link CmpItemAbbrDeprecated DraculaError + + hi! link CmpItemAbbrMatch DraculaCyan + hi! link CmpItemAbbrMatchFuzzy DraculaCyan + + hi! link CmpItemKindText DraculaFg + hi! link CmpItemKindMethod Function + hi! link CmpItemKindFunction Function + hi! link CmpItemKindConstructor DraculaCyan + hi! link CmpItemKindField DraculaOrange + hi! link CmpItemKindVariable DraculaPurpleItalic + hi! link CmpItemKindClass DraculaCyan + hi! link CmpItemKindInterface DraculaCyan + hi! link CmpItemKindModule DraculaYellow + hi! link CmpItemKindProperty DraculaPink + hi! link CmpItemKindUnit DraculaFg + hi! link CmpItemKindValue DraculaYellow + hi! link CmpItemKindEnum DraculaPink + hi! link CmpItemKindKeyword DraculaPink + hi! link CmpItemKindSnippet DraculaFg + hi! link CmpItemKindColor DraculaYellow + hi! link CmpItemKindFile DraculaYellow + hi! link CmpItemKindReference DraculaOrange + hi! link CmpItemKindFolder DraculaYellow + hi! link CmpItemKindEnumMember DraculaPurple + hi! link CmpItemKindConstant DraculaPurple + hi! link CmpItemKindStruct DraculaPink + hi! link CmpItemKindEvent DraculaFg + hi! link CmpItemKindOperator DraculaPink + hi! link CmpItemKindTypeParameter DraculaCyan + + hi! link CmpItemMenu Comment +endif +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/css.vim b/sources_non_forked/dracula/after/syntax/css.vim new file mode 100644 index 00000000..764e0afc --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/css.vim @@ -0,0 +1,15 @@ +if dracula#should_abort('css') + finish +endif + +hi! link cssAttrComma Delimiter +hi! link cssAttrRegion DraculaPink +hi! link cssAttributeSelector DraculaGreenItalic +hi! link cssBraces Delimiter +hi! link cssFunctionComma Delimiter +hi! link cssNoise DraculaPink +hi! link cssProp DraculaCyan +hi! link cssPseudoClass DraculaPink +hi! link cssPseudoClassId DraculaGreenItalic +hi! link cssUnitDecorators DraculaPink +hi! link cssVendor DraculaGreenItalic diff --git a/sources_non_forked/dracula/after/syntax/gitcommit.vim b/sources_non_forked/dracula/after/syntax/gitcommit.vim new file mode 100644 index 00000000..08099e50 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/gitcommit.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('gitcommit') + finish +endif + +" The following two are misnomers. Colors are correct. +hi! link diffFile DraculaGreen +hi! link diffNewFile DraculaRed + +hi! link diffAdded DraculaGreen +hi! link diffLine DraculaCyanItalic +hi! link diffRemoved DraculaRed + diff --git a/sources_non_forked/dracula/after/syntax/html.vim b/sources_non_forked/dracula/after/syntax/html.vim new file mode 100644 index 00000000..243aef63 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/html.vim @@ -0,0 +1,9 @@ +if dracula#should_abort('html') + finish +endif + +hi! link htmlTag DraculaFg +hi! link htmlArg DraculaGreenItalic +hi! link htmlTitle DraculaFg +hi! link htmlH1 DraculaFg +hi! link htmlSpecialChar DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/javascript.vim b/sources_non_forked/dracula/after/syntax/javascript.vim new file mode 100644 index 00000000..e5754aec --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/javascript.vim @@ -0,0 +1,45 @@ +if dracula#should_abort('javascript', 'javascriptreact', 'javascript.jsx') + finish +endif + +hi! link javaScriptBraces Delimiter +hi! link javaScriptNumber Constant +hi! link javaScriptNull Constant +hi! link javaScriptFunction Keyword + +" pangloss/vim-javascript {{{ + +hi! link jsArrowFunction Operator +hi! link jsBuiltins DraculaCyan +hi! link jsClassDefinition DraculaCyan +hi! link jsClassMethodType Keyword +hi! link jsDestructuringAssignment DraculaOrangeItalic +hi! link jsDocParam DraculaOrangeItalic +hi! link jsDocTags Keyword +hi! link jsDocType Type +hi! link jsDocTypeBrackets DraculaCyan +hi! link jsFuncArgOperator Operator +hi! link jsFuncArgs DraculaOrangeItalic +hi! link jsFunction Keyword +hi! link jsNull Constant +hi! link jsObjectColon DraculaPink +hi! link jsSuper DraculaPurpleItalic +hi! link jsTemplateBraces Special +hi! link jsThis DraculaPurpleItalic +hi! link jsUndefined Constant + +"}}} + +" maxmellon/vim-jsx-pretty {{{ + +hi! link jsxTag Keyword +hi! link jsxTagName Keyword +hi! link jsxComponentName Type +hi! link jsxCloseTag Type +hi! link jsxAttrib DraculaGreenItalic +hi! link jsxCloseString Identifier +hi! link jsxOpenPunct Identifier + +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/javascriptreact.vim b/sources_non_forked/dracula/after/syntax/javascriptreact.vim new file mode 100644 index 00000000..b5b557c0 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/javascriptreact.vim @@ -0,0 +1 @@ +runtime! syntax/javascript.vim diff --git a/sources_non_forked/dracula/after/syntax/json.vim b/sources_non_forked/dracula/after/syntax/json.vim new file mode 100644 index 00000000..a45d135d --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/json.vim @@ -0,0 +1,6 @@ +if dracula#should_abort('json') + finish +endif + +hi! link jsonKeyword DraculaCyan +hi! link jsonKeywordMatch DraculaPink diff --git a/sources_non_forked/dracula/after/syntax/lua.vim b/sources_non_forked/dracula/after/syntax/lua.vim new file mode 100644 index 00000000..664848df --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/lua.vim @@ -0,0 +1,22 @@ +if dracula#should_abort('lua') + finish +endif + +hi! link luaFunc DraculaCyan +hi! link luaTable DraculaFg + +" tbastos/vim-lua {{{ + +hi! link luaBraces DraculaFg +hi! link luaBuiltIn Constant +hi! link luaDocTag Keyword +hi! link luaErrHand DraculaCyan +hi! link luaFuncArgName DraculaOrangeItalic +hi! link luaFuncCall Function +hi! link luaLocal Keyword +hi! link luaSpecialTable Constant +hi! link luaSpecialValue DraculaCyan + +" }}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/markdown.vim b/sources_non_forked/dracula/after/syntax/markdown.vim new file mode 100644 index 00000000..0283a86d --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/markdown.vim @@ -0,0 +1,50 @@ +if dracula#should_abort('markdown', 'mkd') + finish +endif + +if b:current_syntax ==# 'mkd' +" plasticboy/vim-markdown {{{1 + hi! link htmlBold DraculaOrangeBold + hi! link htmlBoldItalic DraculaOrangeBoldItalic + hi! link htmlH1 DraculaPurpleBold + hi! link htmlItalic DraculaYellowItalic + hi! link mkdBlockquote DraculaYellowItalic + hi! link mkdBold DraculaOrangeBold + hi! link mkdBoldItalic DraculaOrangeBoldItalic + hi! link mkdCode DraculaGreen + hi! link mkdCodeEnd DraculaGreen + hi! link mkdCodeStart DraculaGreen + hi! link mkdHeading DraculaPurpleBold + hi! link mkdInlineUrl DraculaLink + hi! link mkdItalic DraculaYellowItalic + hi! link mkdLink DraculaPink + hi! link mkdListItem DraculaCyan + hi! link mkdRule DraculaComment + hi! link mkdUrl DraculaLink +"}}}1 +elseif b:current_syntax ==# 'markdown' +" Builtin: {{{1 + hi! link markdownBlockquote DraculaCyan + hi! link markdownBold DraculaOrangeBold + hi! link markdownBoldItalic DraculaOrangeBoldItalic + hi! link markdownCodeBlock DraculaGreen + hi! link markdownCode DraculaGreen + hi! link markdownCodeDelimiter DraculaGreen + hi! link markdownH1 DraculaPurpleBold + hi! link markdownH2 markdownH1 + hi! link markdownH3 markdownH1 + hi! link markdownH4 markdownH1 + hi! link markdownH5 markdownH1 + hi! link markdownH6 markdownH1 + hi! link markdownHeadingDelimiter markdownH1 + hi! link markdownHeadingRule markdownH1 + hi! link markdownItalic DraculaYellowItalic + hi! link markdownLinkText DraculaPink + hi! link markdownListMarker DraculaCyan + hi! link markdownOrderedListMarker DraculaCyan + hi! link markdownRule DraculaComment + hi! link markdownUrl DraculaLink +"}}} +endif + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/after/syntax/ocaml.vim b/sources_non_forked/dracula/after/syntax/ocaml.vim new file mode 100644 index 00000000..60c76c96 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/ocaml.vim @@ -0,0 +1,7 @@ +if dracula#should_abort('ocaml') + finish +endif + +hi! link ocamlModule Type +hi! link ocamlModPath Normal +hi! link ocamlLabel DraculaOrangeItalic diff --git a/sources_non_forked/dracula/after/syntax/perl.vim b/sources_non_forked/dracula/after/syntax/perl.vim new file mode 100644 index 00000000..67f39231 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/perl.vim @@ -0,0 +1,38 @@ +if dracula#should_abort('perl') + finish +endif + +" Regex +hi! link perlMatchStartEnd DraculaRed + +" Builtin functions +hi! link perlOperator DraculaCyan +hi! link perlStatementFiledesc DraculaCyan +hi! link perlStatementFiles DraculaCyan +hi! link perlStatementFlow DraculaCyan +hi! link perlStatementHash DraculaCyan +hi! link perlStatementIOfunc DraculaCyan +hi! link perlStatementIPC DraculaCyan +hi! link perlStatementList DraculaCyan +hi! link perlStatementMisc DraculaCyan +hi! link perlStatementNetwork DraculaCyan +hi! link perlStatementNumeric DraculaCyan +hi! link perlStatementProc DraculaCyan +hi! link perlStatementPword DraculaCyan +hi! link perlStatementRegexp DraculaCyan +hi! link perlStatementScalar DraculaCyan +hi! link perlStatementSocket DraculaCyan +hi! link perlStatementTime DraculaCyan +hi! link perlStatementVector DraculaCyan + +" Highlighting for quoting constructs, tied to existing option in vim-perl +if get(g:, 'perl_string_as_statement', 0) + hi! link perlStringStartEnd DraculaRed +endif + +" Signatures +hi! link perlSignature DraculaOrangeItalic +hi! link perlSubPrototype DraculaOrangeItalic + +" Hash keys +hi! link perlVarSimpleMemberName DraculaPurple diff --git a/sources_non_forked/dracula/after/syntax/php.vim b/sources_non_forked/dracula/after/syntax/php.vim new file mode 100644 index 00000000..1475b018 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/php.vim @@ -0,0 +1,10 @@ +if dracula#should_abort('php') + finish +endif + +hi! link phpClass Type +hi! link phpClasses Type +hi! link phpDocTags DraculaCyanItalic +hi! link phpFunction Function +hi! link phpParent Normal +hi! link phpSpecialFunction DraculaCyan diff --git a/sources_non_forked/dracula/after/syntax/plantuml.vim b/sources_non_forked/dracula/after/syntax/plantuml.vim new file mode 100644 index 00000000..b9bf3651 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/plantuml.vim @@ -0,0 +1,13 @@ +if dracula#should_abort('plantuml') + finish +endif + +hi! link plantumlClassPrivate SpecialKey +hi! link plantumlClassProtected DraculaOrange +hi! link plantumlClassPublic Function +hi! link plantumlColonLine String +hi! link plantumlDirectedOrVerticalArrowLR Constant +hi! link plantumlDirectedOrVerticalArrowRL Constant +hi! link plantumlHorizontalArrow Constant +hi! link plantumlSkinParamKeyword DraculaCyan +hi! link plantumlTypeKeyword Keyword diff --git a/sources_non_forked/dracula/after/syntax/purescript.vim b/sources_non_forked/dracula/after/syntax/purescript.vim new file mode 100644 index 00000000..ca328181 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/purescript.vim @@ -0,0 +1,9 @@ +if dracula#should_abort('purescript') + finish +endif + +hi! link purescriptModule Type +hi! link purescriptImport DraculaCyan +hi! link purescriptImportAs DraculaCyan +hi! link purescriptOperator Operator +hi! link purescriptBacktick Operator diff --git a/sources_non_forked/dracula/after/syntax/python.vim b/sources_non_forked/dracula/after/syntax/python.vim new file mode 100644 index 00000000..171eddde --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/python.vim @@ -0,0 +1,11 @@ +if dracula#should_abort('python') + finish +endif + +hi! link pythonBuiltinObj Type +hi! link pythonBuiltinObject Type +hi! link pythonBuiltinType Type +hi! link pythonClassVar DraculaPurpleItalic +hi! link pythonExClass Type +hi! link pythonNone Type +hi! link pythonRun Comment diff --git a/sources_non_forked/dracula/after/syntax/rst.vim b/sources_non_forked/dracula/after/syntax/rst.vim new file mode 100644 index 00000000..8cb69240 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/rst.vim @@ -0,0 +1,26 @@ +if dracula#should_abort('rst') + finish +endif + +hi! link rstComment Comment +hi! link rstTransition Comment +hi! link rstCodeBlock DraculaGreen +hi! link rstInlineLiteral DraculaGreen +hi! link rstLiteralBlock DraculaGreen +hi! link rstQuotedLiteralBlock DraculaGreen +hi! link rstStandaloneHyperlink DraculaLink +hi! link rstStrongEmphasis DraculaOrangeBold +hi! link rstSections DraculaPurpleBold +hi! link rstEmphasis DraculaYellowItalic +hi! link rstDirective Keyword +hi! link rstSubstitutionDefinition Keyword +hi! link rstCitation String +hi! link rstExDirective String +hi! link rstFootnote String +hi! link rstCitationReference Tag +hi! link rstFootnoteReference Tag +hi! link rstHyperLinkReference Tag +hi! link rstHyperlinkTarget Tag +hi! link rstInlineInternalTargets Tag +hi! link rstInterpretedTextOrHyperlinkReference Tag +hi! link rstTodo Todo diff --git a/sources_non_forked/dracula/after/syntax/ruby.vim b/sources_non_forked/dracula/after/syntax/ruby.vim new file mode 100644 index 00000000..fec00584 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/ruby.vim @@ -0,0 +1,16 @@ +if dracula#should_abort('ruby') + finish +endif + +if ! exists('g:ruby_operators') + let g:ruby_operators=1 +endif + +hi! link rubyBlockArgument DraculaOrangeItalic +hi! link rubyBlockParameter DraculaOrangeItalic +hi! link rubyCurlyBlock DraculaPink +hi! link rubyGlobalVariable DraculaPurple +hi! link rubyInstanceVariable DraculaPurpleItalic +hi! link rubyInterpolationDelimiter DraculaPink +hi! link rubyRegexpDelimiter DraculaRed +hi! link rubyStringDelimiter DraculaYellow diff --git a/sources_non_forked/dracula/after/syntax/rust.vim b/sources_non_forked/dracula/after/syntax/rust.vim new file mode 100644 index 00000000..410334b2 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/rust.vim @@ -0,0 +1,5 @@ +if dracula#should_abort('rust') + finish +endif + +hi! link rustCommentLineDoc Comment diff --git a/sources_non_forked/dracula/after/syntax/sass.vim b/sources_non_forked/dracula/after/syntax/sass.vim new file mode 100644 index 00000000..35a810f9 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/sass.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('sass') + finish +endif + +hi! link sassClass cssClassName +hi! link sassClassChar cssClassNameDot +hi! link sassId cssIdentifier +hi! link sassIdChar cssIdentifier +hi! link sassInterpolationDelimiter DraculaPink +hi! link sassMixinName Function +hi! link sassProperty cssProp +hi! link sassVariableAssignment Operator diff --git a/sources_non_forked/dracula/after/syntax/sh.vim b/sources_non_forked/dracula/after/syntax/sh.vim new file mode 100644 index 00000000..8d471ef7 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/sh.vim @@ -0,0 +1,8 @@ +if dracula#should_abort('bash', 'ksh', 'posix', 'sh') + finish +endif + +hi! link shCommandSub NONE +hi! link shEscape DraculaRed +hi! link shParen NONE +hi! link shParenError NONE diff --git a/sources_non_forked/dracula/after/syntax/tex.vim b/sources_non_forked/dracula/after/syntax/tex.vim new file mode 100644 index 00000000..a46132c8 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/tex.vim @@ -0,0 +1,16 @@ +if dracula#should_abort('tex') + finish +endif + +hi! link texBeginEndName DraculaOrangeItalic +hi! link texBoldItalStyle DraculaOrangeBoldItalic +hi! link texBoldStyle DraculaOrangeBold +hi! link texInputFile DraculaOrangeItalic +hi! link texItalStyle DraculaYellowItalic +hi! link texLigature DraculaPurple +hi! link texMath DraculaPurple +hi! link texMathMatcher DraculaPurple +hi! link texMathSymbol DraculaPurple +hi! link texSpecialChar DraculaPurple +hi! link texSubscripts DraculaPurple +hi! link texTitle DraculaFgBold diff --git a/sources_non_forked/dracula/after/syntax/typescript.vim b/sources_non_forked/dracula/after/syntax/typescript.vim new file mode 100644 index 00000000..c368fb57 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/typescript.vim @@ -0,0 +1,57 @@ +if dracula#should_abort('typescript', 'typescriptreact', 'typescript.tsx') + finish +endif + +" HerringtonDarkholme/yats.vim {{{ + +hi! link typescriptAliasDeclaration Type +hi! link typescriptArrayMethod Function +hi! link typescriptArrowFunc Operator +hi! link typescriptArrowFuncArg DraculaOrangeItalic +hi! link typescriptAssign Operator +hi! link typescriptBOMWindowProp Constant +hi! link typescriptBinaryOp Operator +hi! link typescriptBraces Delimiter +hi! link typescriptCall typescriptArrowFuncArg +hi! link typescriptClassHeritage Type +hi! link typescriptClassName Type +hi! link typescriptDateMethod DraculaCyan +hi! link typescriptDateStaticMethod Function +hi! link typescriptDecorator DraculaGreenItalic +hi! link typescriptDefaultParam Operator +hi! link typescriptES6SetMethod DraculaCyan +hi! link typescriptEndColons Delimiter +hi! link typescriptEnum Type +hi! link typescriptEnumKeyword Keyword +hi! link typescriptFuncComma Delimiter +hi! link typescriptFuncKeyword Keyword +hi! link typescriptFuncType DraculaOrangeItalic +hi! link typescriptFuncTypeArrow Operator +hi! link typescriptGlobal Type +hi! link typescriptGlobalMethod DraculaCyan +hi! link typescriptGlobalObjects Type +hi! link typescriptIdentifier DraculaPurpleItalic +hi! link typescriptInterfaceHeritage Type +hi! link typescriptInterfaceName Type +hi! link typescriptInterpolationDelimiter Keyword +hi! link typescriptKeywordOp Keyword +hi! link typescriptLogicSymbols Operator +hi! link typescriptMember Identifier +hi! link typescriptMemberOptionality Special +hi! link typescriptObjectColon Special +hi! link typescriptObjectLabel Identifier +hi! link typescriptObjectSpread Operator +hi! link typescriptOperator Operator +hi! link typescriptParamImpl DraculaOrangeItalic +hi! link typescriptParens Delimiter +hi! link typescriptPredefinedType Type +hi! link typescriptRestOrSpread Operator +hi! link typescriptTernaryOp Operator +hi! link typescriptTypeAnnotation Special +hi! link typescriptTypeCast Operator +hi! link typescriptTypeParameter DraculaOrangeItalic +hi! link typescriptTypeReference Type +hi! link typescriptUnaryOp Operator +hi! link typescriptVariable Keyword + +" }}} diff --git a/sources_non_forked/dracula/after/syntax/typescriptreact.vim b/sources_non_forked/dracula/after/syntax/typescriptreact.vim new file mode 100644 index 00000000..ec8062e9 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/typescriptreact.vim @@ -0,0 +1,22 @@ +if dracula#should_abort('typescriptreact', 'typescript.tsx') + finish +endif + +runtime! syntax/typescript.vim + +hi! link tsxAttrib DraculaGreenItalic +hi! link tsxEqual Operator +hi! link tsxIntrinsicTagName Keyword +hi! link tsxTagName Type + +" maxmellon/vim-jsx-pretty {{{ + +hi! link jsxTag Keyword +hi! link jsxTagName Keyword +hi! link jsxComponentName Type +hi! link jsxCloseTag Type +hi! link jsxAttrib DraculaGreenItalic +hi! link jsxCloseString Identifier +hi! link jsxOpenPunct Identifier + +" }}} diff --git a/sources_non_forked/dracula/after/syntax/vim.vim b/sources_non_forked/dracula/after/syntax/vim.vim new file mode 100644 index 00000000..a49a93a6 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/vim.vim @@ -0,0 +1,14 @@ +if dracula#should_abort('vim') + finish +endif + +hi! link vimAutoCmdSfxList Type +hi! link vimAutoEventList Type +hi! link vimEnvVar Constant +hi! link vimFunction Function +hi! link vimHiBang Keyword +hi! link vimOption Type +hi! link vimSetMod Keyword +hi! link vimSetSep Delimiter +hi! link vimUserAttrbCmpltFunc Function +hi! link vimUserFunc Function diff --git a/sources_non_forked/dracula/after/syntax/xml.vim b/sources_non_forked/dracula/after/syntax/xml.vim new file mode 100644 index 00000000..4b826983 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/xml.vim @@ -0,0 +1,13 @@ +if dracula#should_abort('xml') + finish +endif + +hi! link xmlAttrib DraculaGreenItalic +hi! link xmlEqual Operator +hi! link xmlTag Delimiter +hi! link xmlTagName Statement + +" Fixes missing highlight over end tags +syn region xmlTagName + \ matchgroup=xmlTag start=+"']\@=+ + \ matchgroup=xmlTag end=+>+ diff --git a/sources_non_forked/dracula/after/syntax/yaml.vim b/sources_non_forked/dracula/after/syntax/yaml.vim new file mode 100644 index 00000000..fedc41f5 --- /dev/null +++ b/sources_non_forked/dracula/after/syntax/yaml.vim @@ -0,0 +1,12 @@ +if dracula#should_abort('yaml') + finish +endif + +hi! link yamlAlias DraculaGreenItalicUnderline +hi! link yamlAnchor DraculaPinkItalic +hi! link yamlBlockMappingKey DraculaCyan +hi! link yamlFlowCollection DraculaPink +hi! link yamlFlowIndicator Delimiter +hi! link yamlNodeTag DraculaPink +hi! link yamlPlainScalar DraculaYellow + diff --git a/sources_non_forked/dracula/autoload/airline/themes/dracula.vim b/sources_non_forked/dracula/autoload/airline/themes/dracula.vim new file mode 100644 index 00000000..42172cad --- /dev/null +++ b/sources_non_forked/dracula/autoload/airline/themes/dracula.vim @@ -0,0 +1,160 @@ +" Dracula Airline Theme: {{{ +" +" Copyright 2016, All rights reserved +" +" Code licensed under the MIT license +" http://zenorocha.mit-license.org +" +" @author Extrante +" @author Zeno Rocha +"}}} +" Helpers: {{{ + +" Takes a foreground color name, background color name, and optionally one or +" more attr-list items as input, transforms it to the format accepted by +" airline#themes#generate_color_map and returns that value +func! s:clr(fg, bg, ...) + let l:fg = g:dracula#palette[a:fg] + let l:bg = g:dracula#palette[a:bg] + return [ l:fg[0], l:bg[0], l:fg[1], l:bg[1] ] + + \ filter(copy(a:000), 'type(v:val) == 1 && len(v:val) > 0') +endfunc + +" Takes three ['fg', 'bg'] color lists and optionally a dictionary of extra +" key-value pairs and returns the value generated by +" airline#themes#generate_color_map after optionally merging the dictionary of +" extra key-value pairs. +" +" a:a -> airline_a, airline_x +" a:b -> airline_b, airline_y +" a:c -> airline_c, airline_z +func! s:color_map(a, b, c, ...) + if a:0 == 0 + return call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) + else + return call('extend', [ call('airline#themes#generate_color_map', [call('s:clr', a:a), call('s:clr', a:b), call('s:clr', a:c)]) ] + a:000) + endif +endfunc + +"}}} + +let g:airline#themes#dracula#palette = { +\ 'normal': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'normal_modified': s:color_map( +\ ['bg', 'purple'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'insert': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'insert_modified': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'replace': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'replace_modified': s:color_map( +\ ['bg', 'orange'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'visual': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'visual_modified': s:color_map( +\ ['bg', 'yellow'], +\ ['fg', 'comment'], +\ ['fg', 'bgdark'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'inactive': s:color_map( +\ ['bg', 'comment'], +\ ['fg', 'bgdark'], +\ ['fg', 'selection'], +\ { +\ 'airline_warning': s:clr('bg', 'orange'), +\ 'airline_error': s:clr('bg', 'red'), +\ }, +\ ), +\ 'terminal': s:color_map( +\ ['bg', 'green'], +\ ['fg', 'comment'], +\ ['fg', 'selection'], +\ { +\ 'airline_term': s:clr('fg', 'selection'), +\ }, +\ ), +\} + +" Extensions: {{{ +" Tabline: {{{ +if get(g:, 'airline#extensions#tabline#enabled', 0) + let g:airline#themes#dracula#palette.tabline = { + \ 'airline_tabfill': s:clr('bg', 'bglight'), + \ + \ 'airline_tab': s:clr('comment', 'bg'), + \ 'airline_tabsel': s:clr('bg', 'purple'), + \ 'airline_tabmod': s:clr('green', 'bg'), + \ + \ 'airline_tab_right': s:clr('comment', 'bg'), + \ 'airline_tabsel_right': s:clr('fg', 'bg', ), + \ 'airline_tabmod_right': s:clr('green', 'bg'), + \} +endif +"}}} +" CtrlP: {{{2 +if exists('g:loaded_ctrlp') + let g:airline#themes#dracula#palette.ctrlp = airline#extensions#ctrlp#generate_color_map( + \ s:clr('fg', 'selection'), + \ s:clr('fg', 'comment'), + \ s:clr('fg', 'purple'), + \) +endif +"}}}2 +"}}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/autoload/dracula.vim b/sources_non_forked/dracula/autoload/dracula.vim new file mode 100644 index 00000000..23f96565 --- /dev/null +++ b/sources_non_forked/dracula/autoload/dracula.vim @@ -0,0 +1,57 @@ +" Palette: {{{ + +let g:dracula#palette = {} +let g:dracula#palette.fg = ['#F8F8F2', 253] + +let g:dracula#palette.bglighter = ['#424450', 238] +let g:dracula#palette.bglight = ['#343746', 237] +let g:dracula#palette.bg = ['#282A36', 236] +let g:dracula#palette.bgdark = ['#21222C', 235] +let g:dracula#palette.bgdarker = ['#191A21', 234] + +let g:dracula#palette.comment = ['#6272A4', 61] +let g:dracula#palette.selection = ['#44475A', 239] +let g:dracula#palette.subtle = ['#424450', 238] + +let g:dracula#palette.cyan = ['#8BE9FD', 117] +let g:dracula#palette.green = ['#50FA7B', 84] +let g:dracula#palette.orange = ['#FFB86C', 215] +let g:dracula#palette.pink = ['#FF79C6', 212] +let g:dracula#palette.purple = ['#BD93F9', 141] +let g:dracula#palette.red = ['#FF5555', 203] +let g:dracula#palette.yellow = ['#F1FA8C', 228] + +" +" ANSI +" +let g:dracula#palette.color_0 = '#21222C' +let g:dracula#palette.color_1 = '#FF5555' +let g:dracula#palette.color_2 = '#50FA7B' +let g:dracula#palette.color_3 = '#F1FA8C' +let g:dracula#palette.color_4 = '#BD93F9' +let g:dracula#palette.color_5 = '#FF79C6' +let g:dracula#palette.color_6 = '#8BE9FD' +let g:dracula#palette.color_7 = '#F8F8F2' +let g:dracula#palette.color_8 = '#6272A4' +let g:dracula#palette.color_9 = '#FF6E6E' +let g:dracula#palette.color_10 = '#69FF94' +let g:dracula#palette.color_11 = '#FFFFA5' +let g:dracula#palette.color_12 = '#D6ACFF' +let g:dracula#palette.color_13 = '#FF92DF' +let g:dracula#palette.color_14 = '#A4FFFF' +let g:dracula#palette.color_15 = '#FFFFFF' + +" }}} + +" Helper function that takes a variadic list of filetypes as args and returns +" whether or not the execution of the ftplugin should be aborted. +func! dracula#should_abort(...) + if ! exists('g:colors_name') || g:colors_name !=# 'dracula' + return 1 + elseif a:0 > 0 && (! exists('b:current_syntax') || index(a:000, b:current_syntax) == -1) + return 1 + endif + return 0 +endfunction + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim b/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim new file mode 100644 index 00000000..42ed79d3 --- /dev/null +++ b/sources_non_forked/dracula/autoload/lightline/colorscheme/dracula.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/dracula.vim +" Author: adamalbrecht +" License: MIT License +" Last Change: 2018/04/11 +" ============================================================================= + +let s:black = g:dracula#palette.bg +let s:gray = g:dracula#palette.selection +let s:white = g:dracula#palette.fg +let s:darkblue = g:dracula#palette.comment +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow + +if exists('g:lightline') + + let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + let s:p.normal.left = [ [ s:black, s:purple ], [ s:cyan, s:gray ] ] + let s:p.normal.right = [ [ s:black, s:purple ], [ s:white, s:darkblue ] ] + let s:p.inactive.right = [ [ s:black, s:darkblue ], [ s:white, s:black ] ] + let s:p.inactive.left = [ [ s:cyan, s:black ], [ s:white, s:black ] ] + let s:p.insert.left = [ [ s:black, s:green ], [ s:cyan, s:gray ] ] + let s:p.replace.left = [ [ s:black, s:red ], [ s:cyan, s:gray ] ] + let s:p.visual.left = [ [ s:black, s:orange ], [ s:cyan, s:gray ] ] + let s:p.normal.middle = [ [ s:white, s:gray ] ] + let s:p.inactive.middle = [ [ s:white, s:gray ] ] + let s:p.tabline.left = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.tabsel = [ [ s:cyan, s:black ] ] + let s:p.tabline.middle = [ [ s:darkblue, s:gray ] ] + let s:p.tabline.right = copy(s:p.normal.right) + let s:p.normal.error = [ [ s:red, s:black ] ] + let s:p.normal.warning = [ [ s:yellow, s:black ] ] + + let g:lightline#colorscheme#dracula#palette = lightline#colorscheme#flatten(s:p) + +endif + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0: diff --git a/sources_non_forked/dracula/colors/dracula.vim b/sources_non_forked/dracula/colors/dracula.vim new file mode 100644 index 00000000..cac11386 --- /dev/null +++ b/sources_non_forked/dracula/colors/dracula.vim @@ -0,0 +1,351 @@ +" Dracula Theme: {{{ +" +" https://github.com/zenorocha/dracula-theme +" +" Copyright 2016, All rights reserved +" +" Code licensed under the MIT license +" http://zenorocha.mit-license.org +" +" @author Trevor Heins <@heinst> +" @author Éverton Ribeiro +" @author Derek Sifford +" @author Zeno Rocha +scriptencoding utf8 +" }}} + +" Configuration: {{{ + +if v:version > 580 + highlight clear + if exists('syntax_on') + syntax reset + endif +endif + +let g:colors_name = 'dracula' + +if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256 + finish +endif + +" Palette: {{{2 + +let s:fg = g:dracula#palette.fg + +let s:bglighter = g:dracula#palette.bglighter +let s:bglight = g:dracula#palette.bglight +let s:bg = g:dracula#palette.bg +let s:bgdark = g:dracula#palette.bgdark +let s:bgdarker = g:dracula#palette.bgdarker + +let s:comment = g:dracula#palette.comment +let s:selection = g:dracula#palette.selection +let s:subtle = g:dracula#palette.subtle + +let s:cyan = g:dracula#palette.cyan +let s:green = g:dracula#palette.green +let s:orange = g:dracula#palette.orange +let s:pink = g:dracula#palette.pink +let s:purple = g:dracula#palette.purple +let s:red = g:dracula#palette.red +let s:yellow = g:dracula#palette.yellow + +let s:none = ['NONE', 'NONE'] + +if has('nvim') + for s:i in range(16) + let g:terminal_color_{s:i} = g:dracula#palette['color_' . s:i] + endfor +endif + +if has('terminal') + let g:terminal_ansi_colors = [] + for s:i in range(16) + call add(g:terminal_ansi_colors, g:dracula#palette['color_' . s:i]) + endfor +endif + +" }}}2 +" User Configuration: {{{2 + +if !exists('g:dracula_bold') + let g:dracula_bold = 1 +endif + +if !exists('g:dracula_italic') + let g:dracula_italic = 1 +endif + +if !exists('g:dracula_underline') + let g:dracula_underline = 1 +endif + +if !exists('g:dracula_undercurl') + let g:dracula_undercurl = g:dracula_underline +endif + +if !exists('g:dracula_full_special_attrs_support') + let g:dracula_full_special_attrs_support = has('gui_running') +endif + +if !exists('g:dracula_inverse') + let g:dracula_inverse = 1 +endif + +if !exists('g:dracula_colorterm') + let g:dracula_colorterm = 1 +endif + +if !exists('g:dracula_high_contrast_diff') + let g:dracula_high_contrast_diff = 0 +endif + +"}}}2 +" Script Helpers: {{{2 + +let s:attrs = { + \ 'bold': g:dracula_bold == 1 ? 'bold' : 0, + \ 'italic': g:dracula_italic == 1 ? 'italic' : 0, + \ 'underline': g:dracula_underline == 1 ? 'underline' : 0, + \ 'undercurl': g:dracula_undercurl == 1 ? 'undercurl' : 0, + \ 'inverse': g:dracula_inverse == 1 ? 'inverse' : 0, + \} + +function! s:h(scope, fg, ...) " bg, attr_list, special + let l:fg = copy(a:fg) + let l:bg = get(a:, 1, ['NONE', 'NONE']) + + let l:attr_list = filter(get(a:, 2, ['NONE']), 'type(v:val) == 1') + let l:attrs = len(l:attr_list) > 0 ? join(l:attr_list, ',') : 'NONE' + + " If the UI does not have full support for special attributes (like underline and + " undercurl) and the highlight does not explicitly set the foreground color, + " make the foreground the same as the attribute color to ensure the user will + " get some highlight if the attribute is not supported. The default behavior + " is to assume that terminals do not have full support, but the user can set + " the global variable `g:dracula_full_special_attrs_support` explicitly if the + " default behavior is not desirable. + let l:special = get(a:, 3, ['NONE', 'NONE']) + if l:special[0] !=# 'NONE' && l:fg[0] ==# 'NONE' && !g:dracula_full_special_attrs_support + let l:fg[0] = l:special[0] + let l:fg[1] = l:special[1] + endif + + let l:hl_string = [ + \ 'highlight', a:scope, + \ 'guifg=' . l:fg[0], 'ctermfg=' . l:fg[1], + \ 'guibg=' . l:bg[0], 'ctermbg=' . l:bg[1], + \ 'gui=' . l:attrs, 'cterm=' . l:attrs, + \ 'guisp=' . l:special[0], + \] + + execute join(l:hl_string, ' ') +endfunction + +"}}}2 +" Dracula Highlight Groups: {{{2 + +call s:h('DraculaBgLight', s:none, s:bglight) +call s:h('DraculaBgLighter', s:none, s:bglighter) +call s:h('DraculaBgDark', s:none, s:bgdark) +call s:h('DraculaBgDarker', s:none, s:bgdarker) + +call s:h('DraculaFg', s:fg) +call s:h('DraculaFgUnderline', s:fg, s:none, [s:attrs.underline]) +call s:h('DraculaFgBold', s:fg, s:none, [s:attrs.bold]) + +call s:h('DraculaComment', s:comment) +call s:h('DraculaCommentBold', s:comment, s:none, [s:attrs.bold]) + +call s:h('DraculaSelection', s:none, s:selection) + +call s:h('DraculaSubtle', s:subtle) + +call s:h('DraculaCyan', s:cyan) +call s:h('DraculaCyanItalic', s:cyan, s:none, [s:attrs.italic]) + +call s:h('DraculaGreen', s:green) +call s:h('DraculaGreenBold', s:green, s:none, [s:attrs.bold]) +call s:h('DraculaGreenItalic', s:green, s:none, [s:attrs.italic]) +call s:h('DraculaGreenItalicUnderline', s:green, s:none, [s:attrs.italic, s:attrs.underline]) + +call s:h('DraculaOrange', s:orange) +call s:h('DraculaOrangeBold', s:orange, s:none, [s:attrs.bold]) +call s:h('DraculaOrangeItalic', s:orange, s:none, [s:attrs.italic]) +call s:h('DraculaOrangeBoldItalic', s:orange, s:none, [s:attrs.bold, s:attrs.italic]) +call s:h('DraculaOrangeInverse', s:bg, s:orange) + +call s:h('DraculaPink', s:pink) +call s:h('DraculaPinkItalic', s:pink, s:none, [s:attrs.italic]) + +call s:h('DraculaPurple', s:purple) +call s:h('DraculaPurpleBold', s:purple, s:none, [s:attrs.bold]) +call s:h('DraculaPurpleItalic', s:purple, s:none, [s:attrs.italic]) + +call s:h('DraculaRed', s:red) +call s:h('DraculaRedInverse', s:fg, s:red) + +call s:h('DraculaYellow', s:yellow) +call s:h('DraculaYellowItalic', s:yellow, s:none, [s:attrs.italic]) + +call s:h('DraculaError', s:red, s:none, [], s:red) + +call s:h('DraculaErrorLine', s:none, s:none, [s:attrs.undercurl], s:red) +call s:h('DraculaWarnLine', s:none, s:none, [s:attrs.undercurl], s:orange) +call s:h('DraculaInfoLine', s:none, s:none, [s:attrs.undercurl], s:cyan) + +call s:h('DraculaTodo', s:cyan, s:none, [s:attrs.bold, s:attrs.inverse]) +call s:h('DraculaSearch', s:green, s:none, [s:attrs.inverse]) +call s:h('DraculaBoundary', s:comment, s:bgdark) +call s:h('DraculaWinSeparator', s:comment, s:bgdark) +call s:h('DraculaLink', s:cyan, s:none, [s:attrs.underline]) + +if g:dracula_high_contrast_diff + call s:h('DraculaDiffChange', s:yellow, s:purple) +else + call s:h('DraculaDiffChange', s:orange, s:none) +endif + +call s:h('DraculaDiffText', s:bg, s:orange) +call s:h('DraculaDiffDelete', s:red, s:bgdark) + +" }}}2 + +" }}} +" User Interface: {{{ + +set background=dark + +" Required as some plugins will overwrite +call s:h('Normal', s:fg, g:dracula_colorterm || has('gui_running') ? s:bg : s:none ) +call s:h('StatusLine', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineNC', s:none, s:bglight) +call s:h('StatusLineTerm', s:none, s:bglighter, [s:attrs.bold]) +call s:h('StatusLineTermNC', s:none, s:bglight) +call s:h('WildMenu', s:bg, s:purple, [s:attrs.bold]) +call s:h('CursorLine', s:none, s:subtle) + +hi! link ColorColumn DraculaBgDark +hi! link CursorColumn CursorLine +hi! link CursorLineNr DraculaYellow +hi! link DiffAdd DraculaGreen +hi! link DiffAdded DiffAdd +hi! link DiffChange DraculaDiffChange +hi! link DiffDelete DraculaDiffDelete +hi! link DiffRemoved DiffDelete +hi! link DiffText DraculaDiffText +hi! link Directory DraculaPurpleBold +hi! link ErrorMsg DraculaRedInverse +hi! link FoldColumn DraculaSubtle +hi! link Folded DraculaBoundary +hi! link IncSearch DraculaOrangeInverse +call s:h('LineNr', s:comment) +hi! link MoreMsg DraculaFgBold +hi! link NonText DraculaSubtle +hi! link Pmenu DraculaBgDark +hi! link PmenuSbar DraculaBgDark +hi! link PmenuSel DraculaSelection +hi! link PmenuThumb DraculaSelection +hi! link Question DraculaFgBold +hi! link Search DraculaSearch +call s:h('SignColumn', s:comment) +hi! link TabLine DraculaBoundary +hi! link TabLineFill DraculaBgDark +hi! link TabLineSel Normal +hi! link Title DraculaGreenBold +hi! link VertSplit DraculaWinSeparator +hi! link Visual DraculaSelection +hi! link VisualNOS Visual +hi! link WarningMsg DraculaOrangeInverse + +" }}} +" Syntax: {{{ + +" Required as some plugins will overwrite +call s:h('MatchParen', s:green, s:none, [s:attrs.underline]) +call s:h('Conceal', s:cyan, s:none) + +" Neovim uses SpecialKey for escape characters only. Vim uses it for that, plus whitespace. +if has('nvim') + hi! link SpecialKey DraculaRed + hi! link LspReferenceText DraculaSelection + hi! link LspReferenceRead DraculaSelection + hi! link LspReferenceWrite DraculaSelection + " Link old 'LspDiagnosticsDefault*' hl groups + " for backward compatibility with neovim v0.5.x + hi! link LspDiagnosticsDefaultInformation DiagnosticInfo + hi! link LspDiagnosticsDefaultHint DiagnosticHint + hi! link LspDiagnosticsDefaultError DiagnosticError + hi! link LspDiagnosticsDefaultWarning DiagnosticWarn + hi! link LspDiagnosticsUnderlineError DiagnosticUnderlineError + hi! link LspDiagnosticsUnderlineHint DiagnosticUnderlineHint + hi! link LspDiagnosticsUnderlineInformation DiagnosticUnderlineInfo + hi! link LspDiagnosticsUnderlineWarning DiagnosticUnderlineWarn + + hi! link DiagnosticInfo DraculaCyan + hi! link DiagnosticHint DraculaCyan + hi! link DiagnosticError DraculaError + hi! link DiagnosticWarn DraculaOrange + hi! link DiagnosticUnderlineError DraculaErrorLine + hi! link DiagnosticUnderlineHint DraculaInfoLine + hi! link DiagnosticUnderlineInfo DraculaInfoLine + hi! link DiagnosticUnderlineWarn DraculaWarnLine + + hi! link WinSeparator DraculaWinSeparator +else + hi! link SpecialKey DraculaPink +endif + +hi! link Comment DraculaComment +hi! link Underlined DraculaFgUnderline +hi! link Todo DraculaTodo + +hi! link Error DraculaError +hi! link SpellBad DraculaErrorLine +hi! link SpellLocal DraculaWarnLine +hi! link SpellCap DraculaInfoLine +hi! link SpellRare DraculaInfoLine + +hi! link Constant DraculaPurple +hi! link String DraculaYellow +hi! link Character DraculaPink +hi! link Number Constant +hi! link Boolean Constant +hi! link Float Constant + +hi! link Identifier DraculaFg +hi! link Function DraculaGreen + +hi! link Statement DraculaPink +hi! link Conditional DraculaPink +hi! link Repeat DraculaPink +hi! link Label DraculaPink +hi! link Operator DraculaPink +hi! link Keyword DraculaPink +hi! link Exception DraculaPink + +hi! link PreProc DraculaPink +hi! link Include DraculaPink +hi! link Define DraculaPink +hi! link Macro DraculaPink +hi! link PreCondit DraculaPink +hi! link StorageClass DraculaPink +hi! link Structure DraculaPink +hi! link Typedef DraculaPink + +hi! link Type DraculaCyanItalic + +hi! link Delimiter DraculaFg + +hi! link Special DraculaPink +hi! link SpecialComment DraculaCyanItalic +hi! link Tag DraculaCyan +hi! link helpHyperTextJump DraculaLink +hi! link helpCommand DraculaPurple +hi! link helpExample DraculaGreen +hi! link helpBacktick Special + +"}}} + +" vim: fdm=marker ts=2 sts=2 sw=2 fdl=0 et: diff --git a/sources_non_forked/dracula/doc/dracula.txt b/sources_non_forked/dracula/doc/dracula.txt new file mode 100644 index 00000000..80e44f19 --- /dev/null +++ b/sources_non_forked/dracula/doc/dracula.txt @@ -0,0 +1,169 @@ +*dracula.txt* For Vim version 8 Last change: 2021 Oct 22 +*dracula* *vim-dracula* + + |\ ,, ~ + \\ _ || _ ~ + / \\ ,._-_ < \, _-_ \\ \\ || < \, ~ + || || || /-|| || || || || /-|| ~ + || || || (( || || || || || (( || ~ + \\/ \\, \/\\ \\,/ \\/\\ \\ \/\\ ~ + + A dark theme for vim + +============================================================================== +CONTENTS *dracula-contents* + + 1. Intro ................................................... |dracula-intro| + 2. Usage ................................................... |dracula-usage| + 3. Configuration ................................... |dracula-configuration| + 4. Personal Customization .......................... |dracula-customization| + 5. License ............................................... |dracula-license| + 6. Bugs ..................................................... |dracula-bugs| + 7. Contributing ..................................... |dracula-contributing| + 8. Credits ............................................... |dracula-credits| + +============================================================================== +INTRO *dracula-intro* + +Dracula is a vim plugin that contains + + - a dark colorscheme for vim + - a similarly-themed colorscheme for the vim plugin airline + (https://github.com/vim-airline/vim-airline) + +============================================================================== +USAGE *dracula-usage* + +Install it with your favorite plugin manager, and then > + colorscheme dracula +in your vimrc! See also |dracula_runtimepath|. + +If you are an airline user, you can also do > + let g:airline_theme='dracula' +to have airline use Dracula. + + *dracula_runtimepath* + +Note that dracula must be in your 'runtimepath' for this command to work +properly: Version 2.0 introduced autoload functionality for part of the +plugin, which doesn't work without 'runtimepath' properly set. + +For users of Vim 8's |packages| feature, it suffices to put > + packadd! dracula + colorscheme dracula +in your vimrc. {name} Should be replaced by the directory you put the code in. +For example, if you use ~/.vim/pack/themes/start/my-dracula-theme, you would +do > + packadd! my-dracula-theme + +For users of other plugin managers, consult your documentation +to make sure you put dracula on the 'runtimepath' before loading it. + +============================================================================== +CONFIGURATION *dracula-configuration* + +There are a couple of variables used by Dracula that you might want to adjust +depending on your terminal's capabilities. + +Default values are shown. + +------------------------------------------------------------------------------ +In the following section, `1` signifies `on` and `0` signifies `off`. + +* *g:dracula_bold* +Include bold attributes in highlighting > + let g:dracula_bold = 1 + +* *g:dracula_italic* +Include italic attributes in highlighting > + let g:dracula_italic = 1 + +* *g:dracula_underline* +Include underline attributes in highlighting > + let g:dracula_underline = 1 + +* *g:dracula_undercurl* +Include undercurl attributes in highlighting (only if underline enabled) > + let g:dracula_undercurl = 1 + +* *g:dracula_full_special_attrs_support* +Explicitly declare full support for special attributes. By default it is 1 +for graphical applications and 0 for terminals and terminal emulators. On +terminal emulators, set to 1 to allow underline/undercurl highlights without +changing the foreground color. > + let g:dracula_full_special_attrs_support = 1 + +* *g:dracula_high_contrast_diff* +Use high-contrast color when in diff mode. By default it is disabled, set to +1 to enable it. + let g:dracula_high_contrast_diff = 1 + +* *g:dracula_inverse* +Include inverse attributes in highlighting > + let g:dracula_inverse = 1 + +* *g:dracula_colorterm* +Include background fill colors > + let g:dracula_colorterm = 1 + +============================================================================== +CUSTOMIZATION *dracula-customization* + +Like all colorschemes, Dracula is easy to customize with |autocmd|. Make use +of the |ColorScheme| event as in the following examples. + +It would be a good idea to put all of your personal changes in an |augroup|, +which you can do with the following code: > + augroup dracula_customization + au! + " autocmds... + augroup END +> + +- To add underline styling to |hl-CursorLine|, you can use the following: > + autocmd ColorScheme dracula hi CursorLine cterm=underline term=underline +< +============================================================================== +LICENSE *dracula-license* + +MIT License. Copyright © 2016 Dracula Theme. +Full text available at +https://github.com/dracula/vim/blob/master/LICENSE + +============================================================================== +BUGS *dracula-bugs* + +At the time of this writing, no major bugs have been found. + +If you find one and wish to report it, you can do so at +https://github.com/dracula/vim/issues + +============================================================================== +CONTRIBUTING *dracula-contributing* + +Want to submit a new feature, bugfix, or hack on Dracula? +Submit pull requests to +https://github.com/dracula/vim/pulls + +Existing code determines style guidelines. + +============================================================================== +CREDITS *dracula-credits* + +Proudly built by the Dracula Theme organization +https://github.com/dracula + +Dracula for other applications available at +https://draculatheme.com + +Further information available at +https://draculatheme.com/vim + +Maintained by: +- Derek S. (https://github.com/dsifford) +- D. Ben Knoble (https://github.com/benknoble) + +Git repository: +https://github.com/dracula/vim + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/dracula/screenshot.png b/sources_non_forked/dracula/screenshot.png new file mode 100644 index 00000000..a6db5c67 Binary files /dev/null and b/sources_non_forked/dracula/screenshot.png differ diff --git a/sources_non_forked/editorconfig-vim/.appveyor.yml b/sources_non_forked/editorconfig-vim/.appveyor.yml new file mode 100644 index 00000000..630fc2f4 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.appveyor.yml @@ -0,0 +1,107 @@ +# appveyor.yml for editorconfig-vim. Currently only tests the core. +# Modified from https://github.com/ppalaga/ec4j/commit/1c849658fb189cd95bc41af95acd43b4f0d75a48 +# +# Copyright (c) 2017--2019 Angelo Zerr and other contributors as +# indicated by the @author tags. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# @author Chris White (cxw42) - Adapted to editorconfig-vim + +# === When to build === +# See https://www.appveyor.com/docs/how-to/filtering-commits/ + +skip_commits: + message: /\[minor\]/ + files: + - '**/*.md' + +# === Build matrix === + +# Win is default; Ubuntu is override. See +# https://www.appveyor.com/blog/2018/04/25/specialized-build-matrix-configuration-in-appveyor/ +image: + - Visual Studio 2013 + - Ubuntu1604 + +# === How to build === + +cache: + - C:\vim -> .appveyor.yml, tests\fetch-vim.bat + +environment: + VIM_EXE: C:\vim\vim\vim80\vim.exe + +for: + # Don't run the Windows build if the commit message includes "[ci-linux]" + - + matrix: + only: + - image: Visual Studio 2013 + skip_commits: + message: /\[ci-linux\]/ + + # Platform-specific configuration for Ubuntu + - + matrix: + only: + - image: Ubuntu1604 + # $APPVEYOR_BUILD_FOLDER isn't expanded in the environment section + # here, so I can't set $VIM_EXE the way I want to. Instead, + # I set $VIM_EXE in the sh-specific install steps below. + environment: + VIM_EXE: UNDEFINED + cache: + - $APPVEYOR_BUILD_FOLDER/vim -> .appveyor.yml, tests/fetch-vim.sh + + # Plus, don't run Ubuntu if the commit message includes [ci-win] + skip_commits: + message: /\[ci-win\]/ + +install: + # Ubuntu-specific setup. These carry forward to the build_script. + - sh: export VIM_EXE="$APPVEYOR_BUILD_FOLDER/vim/bin/vim" + - sh: export PATH="$PATH":$APPVEYOR_BUILD_FOLDER/vim/bin + - sh: echo "$VIM_EXE , $PATH" + + # Cross-platform - test the core + - cmake --version + - git submodule update --init --recursive + - cmd: tests\fetch-vim + - sh: tests/fetch-vim.sh + +build_script: + # Build the core tests + - cd tests + - cd core + - mkdir build + - cd build + - cmake .. + +# Note on multicore testing: +# Two cores are available per https://help.appveyor.com/discussions/questions/11179-how-many-cores-and-threads-can-be-used-in-free-appveyor-build . +# However, using -j2 seems to make each job take much longer. + +test_script: + # Run the core tests + - ctest . --output-on-failure -C Debug + + # CTestCustom specifies skipping UTF-8 tests on Windows. + - cmd: echo "Reminder - did not try UTF-8" + - sh: echo "Reminder - tried UTF-8" + +on_failure: + - echo "failed" + - cmd: type tests\core\build\Testing\Temporary\LastTest.log + - sh: cat tests/core/build/Testing/Temporary/LastTest.log + diff --git a/sources_non_forked/editorconfig-vim/.editorconfig b/sources_non_forked/editorconfig-vim/.editorconfig new file mode 100644 index 00000000..7eed9e11 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.editorconfig @@ -0,0 +1,27 @@ +root = true + +[*] +end_of_line = lf +charset = utf-8 +max_line_length = 80 + +[*.{vim,sh}] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 + +[*.rb] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 120 + +[*.yml] +indent_style = space +indent_size = 2 + +[*.{bat,vbs,ps1}] +end_of_line = CRLF diff --git a/sources_non_forked/editorconfig-vim/.gitignore b/sources_non_forked/editorconfig-vim/.gitignore new file mode 100644 index 00000000..1d86f15e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.gitignore @@ -0,0 +1,8 @@ +tags +tests/**/build +tests/**/.bundle + +# Editor backup files +*.swp +*~ +~* diff --git a/sources_non_forked/editorconfig-vim/.gitmodules b/sources_non_forked/editorconfig-vim/.gitmodules new file mode 100644 index 00000000..8cf01bc4 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.gitmodules @@ -0,0 +1,6 @@ +[submodule "plugin_tests"] + path = tests/plugin/spec/plugin_tests + url = https://github.com/editorconfig/editorconfig-plugin-tests.git +[submodule "core_tests"] + path = tests/core/tests + url = https://github.com/editorconfig/editorconfig-core-test.git diff --git a/sources_non_forked/editorconfig-vim/.travis.yml b/sources_non_forked/editorconfig-vim/.travis.yml new file mode 100644 index 00000000..1eaad3b3 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/.travis.yml @@ -0,0 +1,30 @@ +# Make sure xvfb works - https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-directly +dist: trusty + +matrix: + include: + - name: "plugin" + env: TEST_WHICH=plugin + language: ruby + rvm: + - 2.2.4 + gemfile: tests/plugin/Gemfile + - name: "core" + env: TEST_WHICH=core + +addons: + apt: + packages: + - vim-gtk + +before_script: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + +script: + ./tests/travis-test.sh + +notifications: + email: + on_success: change + on_failure: always diff --git a/sources_non_forked/editorconfig-vim/CONTRIBUTORS b/sources_non_forked/editorconfig-vim/CONTRIBUTORS new file mode 100644 index 00000000..b799668c --- /dev/null +++ b/sources_non_forked/editorconfig-vim/CONTRIBUTORS @@ -0,0 +1,6 @@ +Contributors to the EditorConfig Vim Plugin: + +Hong Xu +Trey Hunner +Kent Frazier +Chris White diff --git a/sources_non_forked/editorconfig-vim/LICENSE b/sources_non_forked/editorconfig-vim/LICENSE new file mode 100644 index 00000000..ed9286e0 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/LICENSE @@ -0,0 +1,26 @@ +Unless otherwise stated, all files are distributed under the Simplified BSD +license included below. + +Copyright (c) 2011-2019 EditorConfig Team +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/sources_non_forked/editorconfig-vim/LICENSE.PSF b/sources_non_forked/editorconfig-vim/LICENSE.PSF new file mode 100644 index 00000000..36eb8e0d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/LICENSE.PSF @@ -0,0 +1,53 @@ +Some code in editorconfig-vim is derived from code licensed under the +PSF license. The following is the text of that license, retrieved 2019-05-05 +from https://docs.python.org/2.6/license.html#terms-and-conditions-for-accessing-or-otherwise-using-python + +PSF LICENSE AGREEMENT FOR PYTHON 2.6.9 + +1. This LICENSE AGREEMENT is between the Python Software Foundation +(``PSF''), and the Individual or Organization (``Licensee'') accessing and +otherwise using Python 2.6.9 software in source or binary form and its +associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 2.6.9 +alone or in any derivative version, provided, however, that PSF's +License Agreement and PSF's notice of copyright, i.e., ``Copyright (c) +2001-2010 Python Software Foundation; All Rights Reserved'' are +retained in Python 2.6.9 alone or in any derivative version prepared +by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 2.6.9 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 2.6.9. + +4. PSF is making Python 2.6.9 available to Licensee on an ``AS IS'' +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. +BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY +REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY +PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.6.9 WILL NOT INFRINGE +ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +2.6.9 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.6.9, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python 2.6.9, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + +# vi: set ft=: diff --git a/sources_non_forked/editorconfig-vim/README.md b/sources_non_forked/editorconfig-vim/README.md new file mode 100644 index 00000000..248d315e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/README.md @@ -0,0 +1,148 @@ +# EditorConfig Vim Plugin + +[![Travis Build Status](https://img.shields.io/travis/cxw42/editorconfig-vim.svg?logo=travis)](https://travis-ci.org/editorconfig/editorconfig-vim) +[![Appveyor Build Status](https://img.shields.io/appveyor/ci/cxw42/editorconfig-vim.svg?logo=appveyor)](https://ci.appveyor.com/project/cxw42/editorconfig-vim) + +This is an [EditorConfig][] plugin for Vim. This plugin can be found on both +[GitHub][] and [Vim online][]. + +## Installation + +To install this plugin, you can use one of the following ways: + +### Install with the archive + +Download the [archive][] and extract it into your Vim runtime directory +(`~/.vim` on UNIX/Linux and `$VIM_INSTALLATION_FOLDER\vimfiles` on windows). +You should have 3 sub-directories in this runtime directory now: "autoload", +"doc" and "plugin". + +### Install as Vim8 plugin + +Install as a Vim 8 plugin. Note `local` can be any name, but some path +element must be present. On Windows, instead of `~/.vim` use +`$VIM_INSTALLATION_FOLDER\vimfiles`. +```shell +mkdir -p ~/.vim/pack/local/start +cd ~/.vim/pack/local/start +git clone https://github.com/editorconfig/editorconfig-vim.git +``` + +### Install with [pathogen][] + +Use pathogen (the git repository of this plugin is +https://github.com/editorconfig/editorconfig-vim.git) + +### Install with [Vundle][] + +Use Vundle by adding to your `.vimrc` Vundle plugins section: + +```viml +Plugin 'editorconfig/editorconfig-vim' +``` + +Then call `:PluginInstall`. + +### Install with [vim-plug][] + +Use vim-plug by adding to your `.vimrc` in your plugin section: + +```viml +Plug 'editorconfig/editorconfig-vim' +``` + +Source your `.vimrc` by calling `:source $MYVIMRC`. + +Then call `:PlugInstall`. + +### No external editorconfig core library is required + +Previous versions of this plugin also required a Python "core". +The core included the code to parse `.editorconfig` files. +This plugin **includes** the core, so you don't need to download the +core separately. + +## Supported properties + +The EditorConfig Vim plugin supports the following EditorConfig [properties][]: + +* `indent_style` +* `indent_size` +* `tab_width` +* `end_of_line` +* `charset` +* `insert_final_newline` (Feature `+fixendofline`, available on Vim 7.4.785+, + or [PreserveNoEOL][] is required for this property) +* `trim_trailing_whitespace` +* `max_line_length` +* `root` (only used by EditorConfig core) + +## Selected Options + +The supported options are documented in [editorconfig.txt][] +and can be viewed by executing the following: `:help editorconfig`. You may +need to execute `:helptags ALL` so that Vim is aware of editorconfig.txt. + +### Excluded patterns + +To ensure that this plugin works well with [Tim Pope's fugitive][], use the +following patterns array: + +```viml +let g:EditorConfig_exclude_patterns = ['fugitive://.*'] +``` + +If you wanted to avoid loading EditorConfig for any remote files over ssh: + +```viml +let g:EditorConfig_exclude_patterns = ['scp://.*'] +``` + +Of course these two items could be combined into the following: + +```viml +let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] +``` + +### Disable for a specific filetype + +You can disable this plugin for a specific buffer by setting +`b:EditorConfig_disable`. Therefore, you can disable the +plugin for all buffers of a specific filetype. For example, to disable +EditorConfig for all git commit messages (filetype `gitcommit`): + +```viml +au FileType gitcommit let b:EditorConfig_disable = 1 +``` + +### Disable rules + +In very rare cases, +you might need to override some project-specific EditorConfig rules in global +or local vimrc in some cases, e.g., to resolve conflicts of trailing whitespace +trimming and buffer autosaving. This is not recommended, but you can: + +```viml +let g:EditorConfig_disable_rules = ['trim_trailing_whitespace'] +``` + +You are able to disable any supported EditorConfig properties. + +## Bugs and Feature Requests + +Feel free to submit bugs, feature requests, and other issues to the +[issue tracker][]. Be sure you have read the [contribution guidelines][]! + +[EditorConfig]: http://editorconfig.org +[GitHub]: https://github.com/editorconfig/editorconfig-vim +[PreserveNoEOL]: http://www.vim.org/scripts/script.php?script_id=4550 +[Tim Pope's fugitive]: https://github.com/tpope/vim-fugitive +[Vim online]: http://www.vim.org/scripts/script.php?script_id=3934 +[Vundle]: https://github.com/gmarik/Vundle.vim +[archive]: https://github.com/editorconfig/editorconfig-vim/archive/master.zip +[contribution guidelines]: https://github.com/editorconfig/editorconfig/blob/master/CONTRIBUTING.md#submitting-an-issue +[issue tracker]: https://github.com/editorconfig/editorconfig-vim/issues +[pathogen]: https://github.com/tpope/vim-pathogen +[properties]: http://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties +[editorconfig.txt]: https://github.com/editorconfig/editorconfig-vim/blob/master/doc/editorconfig.txt +[vim-plug]: https://github.com/junegunn/vim-plug diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim new file mode 100644 index 00000000..1f61a330 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig.vim @@ -0,0 +1,60 @@ +" autoload/editorconfig.vim: EditorConfig native Vimscript plugin +" Copyright (c) 2011-2019 EditorConfig Team +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. +" + +if v:version < 700 + finish +endif + +let s:saved_cpo = &cpo +set cpo&vim + +" {{{1 variables +let s:hook_list = [] + +function! editorconfig#AddNewHook(func) " {{{1 + " Add a new hook + + call add(s:hook_list, a:func) +endfunction + +function! editorconfig#ApplyHooks(config) abort " {{{1 + " apply hooks + + for Hook in s:hook_list + let l:hook_ret = Hook(a:config) + + if type(l:hook_ret) != type(0) && l:hook_ret != 0 + " TODO print some debug info here + endif + endfor +endfunction + +" }}} + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vim: fdm=marker fdc=3 diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim new file mode 100644 index 00000000..6885e17c --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core.vim @@ -0,0 +1,147 @@ +" autoload/editorconfig_core.vim: top-level functions for +" editorconfig-core-vimscript and editorconfig-vim. + +" Copyright (c) 2018-2020 EditorConfig Team, including Chris White {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" Variables {{{1 + +" Note: we create this variable in every script that accesses it. Normally, I +" would put this in plugin/editorconfig.vim. However, in some of my tests, +" the command-line testing environment did not load plugin/* in the normal +" way. Therefore, I do the check everywhere so I don't have to special-case +" the command line. + +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}1 + +" The latest version of the specification that we support. +" See discussion at https://github.com/editorconfig/editorconfig/issues/395 +function! editorconfig_core#version() + return [0,13,0] +endfunction + +" === CLI =============================================================== {{{1 + +" For use from the command line. Output settings for in_name to +" the buffer named out_name. If an optional argument is provided, it is the +" name of the config file to use (default '.editorconfig'). +" TODO support multiple files +" +" filename (if any) +" @param names {Dictionary} The names of the files to use for this run +" - output [required] Where the editorconfig settings should be written +" - target [required] A string or list of strings to process. Each +" must be a full path. +" - dump [optional] If present, write debug info to this file +" @param job {Dictionary} What to do - same format as the input of +" editorconfig_core#handler#get_configurations(), +" except without the target member. + +function! editorconfig_core#currbuf_cli(names, job) " out_name, in_name, ... + let l:output = [] + + " Preprocess the job + let l:job = deepcopy(a:job) + + if has_key(l:job, 'version') " string to list + let l:ver = split(editorconfig_core#util#strip(l:job.version), '\v\.') + for l:idx in range(len(l:ver)) + let l:ver[l:idx] = str2nr(l:ver[l:idx]) + endfor + + let l:job.version = l:ver + endif + + " TODO provide version output from here instead of the shell script +" if string(a:names) ==? 'version' +" return +" endif +" + if type(a:names) != type({}) || type(a:job) != type({}) + throw 'Need two Dictionary arguments' + endif + + if has_key(a:names, 'dump') + execute 'redir! > ' . fnameescape(a:names.dump) + echom 'Names: ' . string(a:names) + echom 'Job: ' . string(l:job) + let g:editorconfig_core_vimscript_debug = 1 + endif + + if type(a:names['target']) == type([]) + let l:targets = a:names.target + else + let l:targets = [a:names.target] + endif + + for l:target in l:targets + + " Pre-process quoting weirdness so we are more flexible in the face + " of CMake+CTest+BAT+Powershell quoting. + + " Permit wrapping in double-quotes + let l:target = substitute(l:target, '\v^"(.*)"$', '\1', '') + + " Permit empty ('') entries in l:targets + if strlen(l:target)<1 + continue + endif + + if has_key(a:names, 'dump') + echom 'Trying: ' . string(l:target) + endif + + let l:job.target = l:target + let l:options = editorconfig_core#handler#get_configurations(l:job) + + if has_key(a:names, 'dump') + echom 'editorconfig_core#currbuf_cli result: ' . string(l:options) + endif + + if len(l:targets) > 1 + let l:output += [ '[' . l:target . ']' ] + endif + + for [ l:key, l:value ] in items(l:options) + let l:output += [ l:key . '=' . l:value ] + endfor + + endfor "foreach target + + " Write the output file + call writefile(l:output, a:names.output) +endfunction "editorconfig_core#currbuf_cli + +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fo-=ro: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim new file mode 100644 index 00000000..6f60db5d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/fnmatch.vim @@ -0,0 +1,465 @@ +" autoload/editorconfig_core/fnmatch.vim: Globbing for +" editorconfig-vim. Ported from the Python core's fnmatch.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. }}}1 + +"Filename matching with shell patterns. +" +"fnmatch(FILENAME, PATH, PATTERN) matches according to the local convention. +"fnmatchcase(FILENAME, PATH, PATTERN) always takes case in account. +" +"The functions operate by translating the pattern into a regular +"expression. They cache the compiled regular expressions for speed. +" +"The function translate(PATTERN) returns a regular expression +"corresponding to PATTERN. (It does not compile it.) + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{1 +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}1 +" === Regexes =========================================================== {{{1 +let s:LEFT_BRACE = '\v%(^|[^\\])\{' +"LEFT_BRACE = re.compile( +" r""" +" +" (?: ^ | [^\\] ) # Beginning of string or a character besides "\" +" +" \{ # "{" +" +" """, re.VERBOSE +") + +let s:RIGHT_BRACE = '\v%(^|[^\\])\}' +"RIGHT_BRACE = re.compile( +" r""" +" +" (?: ^ | [^\\] ) # Beginning of string or a character besides "\" +" +" \} # "}" +" +" """, re.VERBOSE +") + +let s:NUMERIC_RANGE = '\v([+-]?\d+)' . '\.\.' . '([+-]?\d+)' +"NUMERIC_RANGE = re.compile( +" r""" +" ( # Capture a number +" [+-] ? # Zero or one "+" or "-" characters +" \d + # One or more digits +" ) +" +" \.\. # ".." +" +" ( # Capture a number +" [+-] ? # Zero or one "+" or "-" characters +" \d + # One or more digits +" ) +" """, re.VERBOSE +") + +" }}}1 +" === Internal functions ================================================ {{{1 + +" Dump the bytes of a:text. For debugging use. +function! s:dump_bytes(text) + let l:idx=0 + while l:idx < strlen(a:text) + let l:byte_val = char2nr(a:text[l:idx]) + echom printf('%10s%-5d%02x %s', '', l:idx, l:byte_val, + \ a:text[l:idx]) + let l:idx+=1 + endwhile +endfunction "s:dump_bytes + +" Dump the characters of a:text and their codepoints. For debugging use. +function! s:dump_chars(text) + let l:chars = split(a:text, '\zs') + let l:idx = 0 + let l:out1 = '' + let l:out2 = '' + while l:idx < len(l:chars) + let l:char = l:chars[l:idx] + let l:out1 .= printf('%5s', l:char) + let l:out2 .= printf('%5x', char2nr(l:char)) + let l:idx+=1 + endwhile + + echom l:out1 + echom l:out2 +endfunction "s:dump_chars + +" }}}1 +" === Translating globs to patterns ===================================== {{{1 + +" Used by s:re_escape: backslash-escape any character below U+0080; +" replace all others with a %U escape. +" See https://vi.stackexchange.com/a/19617/1430 by yours truly +" (https://vi.stackexchange.com/users/1430/cxw). +unlockvar s:replacement_expr +let s:replacement_expr = + \ '\=' . + \ '((char2nr(submatch(1)) >= 128) ? ' . + \ 'printf("%%U%08x", char2nr(submatch(1))) : ' . + \ '("\\" . submatch(1))' . + \ ')' +lockvar s:replacement_expr + +" Escaper for very-magic regexes +function! s:re_escape(text) + return substitute(a:text, '\v([^0-9a-zA-Z_])', s:replacement_expr, 'g') +endfunction + +"def translate(pat, nested=0): +" Translate a shell PATTERN to a regular expression. +" There is no way to quote meta-characters. +function! editorconfig_core#fnmatch#translate(pat, ...) + let l:nested = 0 + if a:0 + let l:nested = a:1 + endif + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#translate: pattern ' . a:pat + echom printf( + \ '- %d chars', strlen(substitute(a:pat, ".", "x", "g"))) + call s:dump_chars(a:pat) + endif + + let l:pat = a:pat " TODO remove if we wind up not needing this + + " Note: the Python sets MULTILINE and DOTALL, but Vim has \_. + " instead of DOTALL, and \_^ / \_$ instead of MULTILINE. + + let l:is_escaped = 0 + + " Find out whether the pattern has balanced braces. + let l:left_braces=[] + let l:right_braces=[] + call substitute(l:pat, s:LEFT_BRACE, '\=add(l:left_braces, 1)', 'g') + call substitute(l:pat, s:RIGHT_BRACE, '\=add(l:right_braces, 1)', 'g') + " Thanks to http://jeromebelleman.gitlab.io/posts/productivity/vimsub/ + let l:matching_braces = (len(l:left_braces) == len(l:right_braces)) + + " Unicode support (#2). Indexing l:pat[l:index] returns bytes, per + " https://github.com/neovim/neovim/issues/68#issue-28114985 . + " Instead, use split() per vimdoc to break the input string into an + " array of *characters*, and process that. + let l:characters = split(l:pat, '\zs') + + let l:index = 0 " character index + let l:length = len(l:characters) + let l:brace_level = 0 + let l:in_brackets = 0 + + let l:result = '' + let l:numeric_groups = [] + while l:index < l:length + let l:current_char = l:characters[l:index] + let l:index += 1 + +" if g:editorconfig_core_vimscript_debug +" echom ' - fnmatch#translate: ' . l:current_char . '@' . +" \ (l:index-1) . '; result ' . l:result +" endif + + if l:current_char ==# '*' + let l:pos = l:index + if l:pos < l:length && l:characters[l:pos] ==# '*' + let l:result .= '\_.*' + let l:index += 1 " skip the second star + else + let l:result .= '[^/]*' + endif + + elseif l:current_char ==# '?' + let l:result .= '\_[^/]' + + elseif l:current_char ==# '[' + if l:in_brackets + let l:result .= '\[' + else + let l:pos = l:index + let l:has_slash = 0 + while l:pos < l:length && l:characters[l:pos] != ']' + if l:characters[l:pos] ==# '/' && l:characters[l:pos-1] !=# '\' + let has_slash = 1 + break + endif + let l:pos += 1 + endwhile + if l:has_slash + " POSIX IEEE 1003.1-2017 sec. 2.13.3: '/' cannot occur + " in a bracket expression, so [/] matches a literal + " three-character string '[' . '/' . ']'. + let l:result .= '\[' + \ . s:re_escape(join(l:characters[l:index : l:pos-1], '')) + \ . '\/' + " escape the slash + let l:index = l:pos + 1 + " resume after the slash + else + if l:index < l:length && l:characters[l:index] =~# '\v%(\^|\!)' + let l:index += 1 + let l:result .= '[^' + else + let l:result .= '[' + endif + let l:in_brackets = 1 + endif + endif + + elseif l:current_char ==# '-' + if l:in_brackets + let l:result .= l:current_char + else + let l:result .= '\' . l:current_char + endif + + elseif l:current_char ==# ']' + if l:in_brackets && !l:is_escaped + let l:result .= ']' + let l:in_brackets = 0 + elseif l:is_escaped + let l:result .= '\]' + let l:is_escaped = 0 + else + let l:result .= '\]' + endif + + elseif l:current_char ==# '{' + let l:pos = l:index + let l:has_comma = 0 + while l:pos < l:length && (l:characters[l:pos] !=# '}' || l:is_escaped) + if l:characters[l:pos] ==# ',' && ! l:is_escaped + let l:has_comma = 1 + break + endif + let l:is_escaped = l:characters[l:pos] ==# '\' && ! l:is_escaped + let l:pos += 1 + endwhile + if ! l:has_comma && l:pos < l:length + let l:num_range = + \ matchlist(join(l:characters[l:index : l:pos-1], ''), + \ s:NUMERIC_RANGE) + if len(l:num_range) > 0 " Remember the ranges + call add(l:numeric_groups, [ 0+l:num_range[1], 0+l:num_range[2] ]) + let l:result .= '([+-]?\d+)' + else + let l:inner_xlat = editorconfig_core#fnmatch#translate( + \ join(l:characters[l:index : l:pos-1], ''), 1) + let l:inner_result = l:inner_xlat[0] + let l:inner_groups = l:inner_xlat[1] + let l:result .= '\{' . l:inner_result . '\}' + let l:numeric_groups += l:inner_groups + endif + let l:index = l:pos + 1 + elseif l:matching_braces + let l:result .= '%(' + let l:brace_level += 1 + else + let l:result .= '\{' + endif + + elseif l:current_char ==# ',' + if l:brace_level > 0 && ! l:is_escaped + let l:result .= '|' + else + let l:result .= '\,' + endif + + elseif l:current_char ==# '}' + if l:brace_level > 0 && ! l:is_escaped + let l:result .= ')' + let l:brace_level -= 1 + else + let l:result .= '\}' + endif + + elseif l:current_char ==# '/' + if join(l:characters[l:index : (l:index + 2)], '') ==# '**/' + let l:result .= '%(/|/\_.*/)' + let l:index += 3 + else + let l:result .= '\/' + endif + + elseif l:current_char != '\' + let l:result .= s:re_escape(l:current_char) + endif + + if l:current_char ==# '\' + if l:is_escaped + let l:result .= s:re_escape(l:current_char) + endif + let l:is_escaped = ! l:is_escaped + else + let l:is_escaped = 0 + endif + + endwhile + + if ! l:nested + let l:result .= '\_$' + endif + + return [l:result, l:numeric_groups] +endfunction " #editorconfig_core#fnmatch#translate + +let s:_cache = {} +function! s:cached_translate(pat) + if ! has_key(s:_cache, a:pat) + "regex = re.compile(res) + let s:_cache[a:pat] = + \ editorconfig_core#fnmatch#translate(a:pat) + " we don't compile the regex + endif + return s:_cache[a:pat] +endfunction " cached_translate + +" }}}1 +" === Matching functions ================================================ {{{1 + +function! editorconfig_core#fnmatch#fnmatch(name, path, pattern) +"def fnmatch(name, pat): +" """Test whether FILENAME matches PATH/PATTERN. +" +" Patterns are Unix shell style: +" +" - ``*`` matches everything except path separator +" - ``**`` matches everything +" - ``?`` matches any single character +" - ``[seq]`` matches any character in seq +" - ``[!seq]`` matches any char not in seq +" - ``{s1,s2,s3}`` matches any of the strings given (separated by commas) +" +" An initial period in FILENAME is not special. +" Both FILENAME and PATTERN are first case-normalized +" if the operating system requires it. +" If you don't want this, use fnmatchcase(FILENAME, PATTERN). +" """ +" + " Note: This throws away the backslash in '\.txt' on Cygwin, but that + " makes sense since it's Windows under the hood. + " We don't care about shellslash since we're going to change backslashes + " to slashes in just a moment anyway. + let l:localname = fnamemodify(a:name, ':p') + + if editorconfig_core#util#is_win() " normalize + let l:localname = substitute(tolower(l:localname), '\v\\', '/', 'g') + let l:path = substitute(tolower(a:path), '\v\\', '/', 'g') + let l:pattern = tolower(a:pattern) + else + let l:localname = l:localname + let l:path = a:path + let l:pattern = a:pattern + endif + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatch testing <' . l:localname . '> against <' . + \ l:pattern . '> wrt <' . l:path . '>' + endif + + return editorconfig_core#fnmatch#fnmatchcase(l:localname, l:path, l:pattern) +endfunction " fnmatch + +function! editorconfig_core#fnmatch#fnmatchcase(name, path, pattern) +"def fnmatchcase(name, pat): +" """Test whether FILENAME matches PATH/PATTERN, including case. +" +" This is a version of fnmatch() which doesn't case-normalize +" its arguments. +" """ +" + let [regex, num_groups] = s:cached_translate(a:pattern) + + let l:escaped_path = s:re_escape(a:path) + let l:regex = '\v' . l:escaped_path . l:regex + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatchcase: regex ' . l:regex + call s:dump_chars(l:regex) + echom '- fnmatch#fnmatchcase: checking ' . a:name + call s:dump_chars(a:name) + endif + + let l:match_groups = matchlist(a:name, l:regex)[1:] " [0] = full match + + if g:editorconfig_core_vimscript_debug + echom printf(' Got %d matches', len(l:match_groups)) + endif + + if len(l:match_groups) == 0 + return 0 + endif + + " Check numeric ranges + let pattern_matched = 1 + for l:idx in range(0,len(l:match_groups)) + let l:num = l:match_groups[l:idx] + if l:num ==# '' + break + endif + + let [min_num, max_num] = num_groups[l:idx] + if (min_num > (0+l:num)) || ((0+l:num) > max_num) + let pattern_matched = 0 + break + endif + + " Reject leading zeros without sign. This is very odd --- + " see editorconfig/editorconfig#371. + if match(l:num, '\v^0') != -1 + let pattern_matched = 0 + break + endif + endfor + + if g:editorconfig_core_vimscript_debug + echom '- fnmatch#fnmatchcase: ' . (pattern_matched ? 'matched' : 'did not match') + endif + + return pattern_matched +endfunction " fnmatchcase + +" }}}1 +" === Copyright notices ================================================= {{{1 +" Based on code from fnmatch.py file distributed with Python 2.6. +" Portions Copyright (c) 2001-2010 Python Software Foundation; +" All Rights Reserved. Licensed under PSF License (see LICENSE.PSF file). +" +" Changes to original fnmatch: +" +" - translate function supports ``*`` and ``**`` similarly to fnmatch C library +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim new file mode 100644 index 00000000..c9a66e16 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/handler.vim @@ -0,0 +1,183 @@ +" autoload/editorconfig_core/handler.vim: Main worker for +" editorconfig-core-vimscript and editorconfig-vim. +" Modified from the Python core's handler.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" Return full filepath for filename in each directory in and above path. {{{1 +" Input path must be an absolute path. +" TODO shellslash/shellescape? +function! s:get_filenames(path, config_filename) + let l:path = a:path + let l:path_list = [] + while 1 + call add(l:path_list, editorconfig_core#util#path_join(l:path, a:config_filename)) + let l:newpath = fnamemodify(l:path, ':h') + if l:path ==? l:newpath || !strlen(l:path) + break + endif + let l:path = l:newpath + endwhile + return l:path_list +endfunction " get_filenames + +" }}}1 +" === Main ============================================================== {{{1 + +" Find EditorConfig files and return all options matching target_filename. +" Throws on failure. +" @param job {Dictionary} required 'target'; optional 'config' and 'version' +function! editorconfig_core#handler#get_configurations(job) + " TODO? support VERSION checks? + +" Special exceptions that may be raised by this function include: +" - ``VersionError``: self.version is invalid EditorConfig version +" - ``PathError``: self.filepath is not a valid absolute filepath +" - ``ParsingError``: improperly formatted EditorConfig file found + + let l:job = deepcopy(a:job) + if has_key(l:job, 'config') + let l:config_filename = l:job.config + else + let l:config_filename = '.editorconfig' + let l:job.config = l:config_filename + endif + + if has_key(l:job, 'version') + let l:version = l:job.version + else + let l:version = editorconfig_core#version() + let l:job.version = l:version + endif + + let l:target_filename = l:job.target + + "echom 'Beginning job ' . string(l:job) + if !s:check_assertions(l:job) + throw "Assertions failed" + endif + + let l:fullpath = fnamemodify(l:target_filename,':p') + let l:path = fnamemodify(l:fullpath, ':h') + let l:conf_files = s:get_filenames(l:path, l:config_filename) + + " echom 'fullpath ' . l:fullpath + " echom 'path ' . l:path + + let l:retval = {} + + " Attempt to find and parse every EditorConfig file in filetree + for l:conf_fn in l:conf_files + "echom 'Trying ' . l:conf_fn + let l:parsed = editorconfig_core#ini#read_ini_file(l:conf_fn, l:target_filename) + if !has_key(l:parsed, 'options') + continue + endif + " echom ' Has options' + + " Merge new EditorConfig file's options into current options + let l:old_options = l:retval + let l:retval = l:parsed.options + " echom 'Old options ' . string(l:old_options) + " echom 'New options ' . string(l:retval) + call extend(l:retval, l:old_options, 'force') + + " Stop parsing if parsed file has a ``root = true`` option + if l:parsed.root + break + endif + endfor + + call s:preprocess_values(l:job, l:retval) + return l:retval +endfunction " get_configurations + +function! s:check_assertions(job) +" TODO +" """Raise error if filepath or version have invalid values""" + +" # Raise ``PathError`` if filepath isn't an absolute path +" if not os.path.isabs(self.filepath): +" raise PathError("Input file must be a full path name.") + + " Throw if version specified is greater than current + let l:v = a:job.version + let l:us = editorconfig_core#version() + " echom 'Comparing requested version ' . string(l:v) . + " \ ' to our version ' . string(l:us) + if l:v[0] > l:us[0] || l:v[1] > l:us[1] || l:v[2] > l:us[2] + throw 'Required version ' . string(l:v) . + \ ' is greater than the current version ' . string(l:us) + endif + + return 1 " All OK if we got here +endfunction " check_assertions + +" }}}1 + +" Preprocess option values for consumption by plugins. {{{1 +" Modifies its argument in place. +function! s:preprocess_values(job, opts) + + " Lowercase option value for certain options + for l:name in ['end_of_line', 'indent_style', 'indent_size', + \ 'insert_final_newline', 'trim_trailing_whitespace', + \ 'charset'] + if has_key(a:opts, l:name) + let a:opts[l:name] = tolower(a:opts[l:name]) + endif + endfor + + " Set indent_size to "tab" if indent_size is unspecified and + " indent_style is set to "tab", provided we are at least v0.10.0. + if get(a:opts, 'indent_style', '') ==? "tab" && + \ !has_key(a:opts, 'indent_size') && + \ ( a:job.version[0]>0 || a:job.version[1] >=10 ) + let a:opts['indent_size'] = 'tab' + endif + + " Set tab_width to indent_size if indent_size is specified and + " tab_width is unspecified + if has_key(a:opts, 'indent_size') && !has_key(a:opts, 'tab_width') && + \ get(a:opts, 'indent_size', '') !=? "tab" + let a:opts['tab_width'] = a:opts['indent_size'] + endif + + " Set indent_size to tab_width if indent_size is "tab" + if has_key(a:opts, 'indent_size') && has_key(a:opts, 'tab_width') && + \ get(a:opts, 'indent_size', '') ==? "tab" + let a:opts['indent_size'] = a:opts['tab_width'] + endif +endfunction " preprocess_values + +" }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fdl=1: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim new file mode 100644 index 00000000..d773323f --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/ini.vim @@ -0,0 +1,276 @@ +" autoload/editorconfig_core/ini.vim: Config-file parser for +" editorconfig-core-vimscript and editorconfig-vim. +" Modifed from the Python core's ini.py. + +" Copyright (c) 2012-2019 EditorConfig Team {{{2 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. }}}2 + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{2 +if !exists('g:editorconfig_core_vimscript_debug') + let g:editorconfig_core_vimscript_debug = 0 +endif +" }}}2 +" === Constants, including regexes ====================================== {{{2 +" Regular expressions for parsing section headers and options. +" Allow ``]`` and escaped ``;`` and ``#`` characters in section headers. +" In fact, allow \ to escape any single character - it needs to cover at +" least \ * ? [ ! ] { }. +unlockvar s:SECTCRE s:OPTCRE s:MAX_SECTION_NAME s:MAX_PROPERTY_NAME s:MAX_PROPERTY_VALUE +let s:SECTCRE = '\v^\s*\[(%([^\\#;]|\\.)+)\]' + +" Regular expression for parsing option name/values. +" Allow any amount of whitespaces, followed by separator +" (either ``:`` or ``=``), followed by any amount of whitespace and then +" any characters to eol +let s:OPTCRE = '\v\s*([^:=[:space:]][^:=]*)\s*([:=])\s*(.*)$' + +let s:MAX_SECTION_NAME = 4096 +let s:MAX_PROPERTY_NAME = 50 +let s:MAX_PROPERTY_VALUE = 255 + +lockvar s:SECTCRE s:OPTCRE s:MAX_SECTION_NAME s:MAX_PROPERTY_NAME s:MAX_PROPERTY_VALUE + +" }}}2 +" === Main ============================================================== {{{1 + +" Read \p config_filename and return the options applicable to +" \p target_filename. This is the main entry point in this file. +function! editorconfig_core#ini#read_ini_file(config_filename, target_filename) + if !filereadable(a:config_filename) + return {} + endif + + try + let l:lines = readfile(a:config_filename) + if &encoding !=? 'utf-8' + " strip BOM + if len(l:lines) > 0 && l:lines[0][:2] ==# "\xEF\xBB\xBF" + let l:lines[0] = l:lines[0][3:] + endif + " convert from UTF-8 to 'encoding' + call map(l:lines, 'iconv(v:val, "utf-8", &encoding)') + endif + let result = s:parse(a:config_filename, a:target_filename, l:lines) + catch + " rethrow, but with a prefix since throw 'Vim...' fails. + throw 'Could not read editorconfig file at ' . v:throwpoint . ': ' . string(v:exception) + endtry + + return result +endfunction + +function! s:parse(config_filename, target_filename, lines) +" Parse a sectioned setup file. +" The sections in setup file contains a title line at the top, +" indicated by a name in square brackets (`[]'), plus key/value +" options lines, indicated by `name: value' format lines. +" Continuations are represented by an embedded newline then +" leading whitespace. Blank lines, lines beginning with a '#', +" and just about everything else are ignored. + + let l:in_section = 0 + let l:matching_section = 0 + let l:optname = '' + let l:lineno = 0 + let l:e = [] " Errors, if any + + let l:options = {} " Options applicable to this file + let l:is_root = 0 " Whether a:config_filename declares root=true + + while 1 + if l:lineno == len(a:lines) + break + endif + + let l:line = a:lines[l:lineno] + let l:lineno = l:lineno + 1 + + " comment or blank line? + if editorconfig_core#util#strip(l:line) ==# '' + continue + endif + if l:line =~# '\v^[#;]' + continue + endif + + " is it a section header? + if g:editorconfig_core_vimscript_debug + echom "Header? <" . l:line . ">" + endif + + let l:mo = matchlist(l:line, s:SECTCRE) + if len(l:mo) + let l:sectname = l:mo[1] + let l:in_section = 1 + if strlen(l:sectname) > s:MAX_SECTION_NAME + " Section name too long => ignore the section + let l:matching_section = 0 + else + let l:matching_section = s:matches_filename( + \ a:config_filename, a:target_filename, l:sectname) + endif + + if g:editorconfig_core_vimscript_debug + echom 'In section ' . l:sectname . ', which ' . + \ (l:matching_section ? 'matches' : 'does not match') + \ ' file ' . a:target_filename . ' (config ' . + \ a:config_filename . ')' + endif + + " So sections can't start with a continuation line + let l:optname = '' + + " Is it an option line? + else + let l:mo = matchlist(l:line, s:OPTCRE) + if len(l:mo) + let l:optname = mo[1] + let l:optval = mo[3] + + if g:editorconfig_core_vimscript_debug + echom printf('Saw raw opt <%s>=<%s>', l:optname, l:optval) + endif + + if l:optval =~# '\v[;#]' + " ';' and '#' are comment delimiters only if + " preceded by a spacing character + let l:m = matchlist(l:optval, '\v(.{-})\s[;#]') + if len(l:m) + let l:optval = l:m[1] + endif + + " ; and # can be escaped with backslash. + let l:optval = substitute(l:optval, '\v\\([;#])', '\1', 'g') + + endif + let l:optval = editorconfig_core#util#strip(l:optval) + " allow empty values + if l:optval ==? '""' + let l:optval = '' + endif + let l:optname = s:optionxform(l:optname) + if !l:in_section && optname ==? 'root' + let l:is_root = (optval ==? 'true') + endif + if g:editorconfig_core_vimscript_debug + echom printf('Saw opt <%s>=<%s>', l:optname, l:optval) + endif + + if l:matching_section && + \ strlen(l:optname) <= s:MAX_PROPERTY_NAME && + \ strlen(l:optval) <= s:MAX_PROPERTY_VALUE + let l:options[l:optname] = l:optval + endif + else + " a non-fatal parsing error occurred. set up the + " exception but keep going. the exception will be + " raised at the end of the file and will contain a + " list of all bogus lines + call add(e, "Parse error in '" . a:config_filename . "' at line " . + \ l:lineno . ": '" . l:line . "'") + endif + endif + endwhile + + " if any parsing errors occurred, raise an exception + if len(l:e) + throw string(l:e) + endif + + return {'root': l:is_root, 'options': l:options} +endfunction! + +" }}}1 +" === Helpers =========================================================== {{{1 + +" Preprocess option names +function! s:optionxform(optionstr) + let l:result = substitute(a:optionstr, '\v\s+$', '', 'g') " rstrip + return tolower(l:result) +endfunction + +" Return true if \p glob matches \p target_filename +function! s:matches_filename(config_filename, target_filename, glob) +" config_dirname = normpath(dirname(config_filename)).replace(sep, '/') + let l:config_dirname = fnamemodify(a:config_filename, ':p:h') . '/' + + if editorconfig_core#util#is_win() + " Regardless of whether shellslash is set, make everything slashes + let l:config_dirname = + \ tolower(substitute(l:config_dirname, '\v\\', '/', 'g')) + endif + + let l:glob = substitute(a:glob, '\v\\([#;])', '\1', 'g') + + " Take account of the path to the editorconfig file. + " editorconfig-core-c/src/lib/editorconfig.c says: + " "Pattern would be: /dir/of/editorconfig/file[double_star]/[section] if + " section does not contain '/', or /dir/of/editorconfig/file[section] + " if section starts with a '/', or /dir/of/editorconfig/file/[section] if + " section contains '/' but does not start with '/'." + + if stridx(l:glob, '/') != -1 " contains a slash + if l:glob[0] ==# '/' + let l:glob = l:glob[1:] " trim leading slash + endif +" This will be done by fnmatch +" let l:glob = l:config_dirname . l:glob + else " does not contain a slash + let l:config_dirname = l:config_dirname[:-2] + " Trim trailing slash + let l:glob = '**/' . l:glob + endif + + if g:editorconfig_core_vimscript_debug + echom '- ini#matches_filename: checking <' . a:target_filename . + \ '> against <' . l:glob . '> with respect to config file <' . + \ a:config_filename . '>' + echom '- ini#matches_filename: config_dirname is ' . l:config_dirname + endif + + return editorconfig_core#fnmatch#fnmatch(a:target_filename, + \ l:config_dirname, l:glob) +endfunction " matches_filename + +" }}}1 +" === Copyright notices ================================================= {{{2 +" Based on code from ConfigParser.py file distributed with Python 2.6. +" Portions Copyright (c) 2001-2010 Python Software Foundation; +" All Rights Reserved. Licensed under PSF License (see LICENSE.PSF file). +" +" Changes to original ConfigParser: +" +" - Special characters can be used in section names +" - Octothorpe can be used for comments (not just at beginning of line) +" - Only track INI options in sections that match target filename +" - Stop parsing files with when ``root = true`` is found +" }}}2 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker fdl=1: diff --git a/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim new file mode 100644 index 00000000..c4df04af --- /dev/null +++ b/sources_non_forked/editorconfig-vim/autoload/editorconfig_core/util.vim @@ -0,0 +1,84 @@ +" util.vim: part of editorconfig-core-vimscript and editorconfig-vim. +" Copyright (c) 2018-2019 EditorConfig Team, including Chris White {{{1 +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. }}}1 + +let s:saved_cpo = &cpo +set cpo&vim + +" A verbatim copy of ingo#fs#path#Separator() {{{1 +" from https://github.com/vim-scripts/ingo-library/blob/558132e2221db3af26dc2f2c6756d092d48a459f/autoload/ingo/fs/path.vim +" distributed under the Vim license. +function! editorconfig_core#util#Separator() + return (exists('+shellslash') && ! &shellslash ? '\' : '/') +endfunction " }}}1 + +" path_join(): ('a','b')->'a/b'; ('a/','b')->'a/b'. {{{1 +function! editorconfig_core#util#path_join(a, b) + " TODO shellescape/shellslash? + "echom 'Joining <' . a:a . '> and <' . a:b . '>' + "echom 'Length is ' . strlen(a:a) + "echom 'Last char is ' . char2nr(a:a[-1]) + if a:a !~# '\v%(\/|\\)$' + return a:a . editorconfig_core#util#Separator() . a:b + else + return a:a . a:b + endif +endfunction " }}}1 + +" is_win() by xolox {{{1 +" The following function is modified from +" https://github.com/xolox/vim-misc/blob/master/autoload/xolox/misc/os.vim +" Copyright (c) 2015 Peter Odding +" +" Permission is hereby granted, free of charge, to any person obtaining a copy +" of this software and associated documentation files (the "Software"), to deal +" in the Software without restriction, including without limitation the rights +" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +" copies of the Software, and to permit persons to whom the Software is +" furnished to do so, subject to the following conditions: +" +" The above copyright notice and this permission notice shall be included in all +" copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +" SOFTWARE. +function! editorconfig_core#util#is_win() + " Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise. + return has('win16') || has('win32') || has('win64') +endfunction " }}}1 + +" strip() {{{1 +function! editorconfig_core#util#strip(s) + return substitute(a:s, '\v^\s+|\s+$','','g') +endfunction " }}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/doc/editorconfig.txt b/sources_non_forked/editorconfig-vim/doc/editorconfig.txt new file mode 100644 index 00000000..98f374e6 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/doc/editorconfig.txt @@ -0,0 +1,220 @@ +*editorconfig.txt* + +File: editorconfig.txt +Version: 1.1.1 +Maintainer: EditorConfig Team +Description: EditorConfig vim plugin + +License: + Copyright (c) 2011-2019 EditorConfig Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + +CONTENTS~ + *editorconfig-contents* +---------------------------------------------------------------------------- +1. Overview |editorconfig-overview| +2. Installation |editorconfig-installation| +3. Commands |editorconfig-commands| +4. Settings |editorconfig-settings| +5. Advanced |editorconfig-advanced| + + +OVERVIEW~ + *editorconfig-overview* +---------------------------------------------------------------------------- +This is the EditorConfig plugin for vim. + + +INSTALLATION~ + *editorconfig-installation* +---------------------------------------------------------------------------- +Follow the instructions in the README.md file to install this plugin. + +COMMANDS~ + *editorconfig-commands* +---------------------------------------------------------------------------- + + *:EditorConfigReload* +Command: + :EditorConfigReload + +Reload the EditorConfig conf files. When `.editorconfig` files are modified, +this command could prevent you to reload the current edited file to load the +new configuration. + +SETTINGS~ + *editorconfig-settings* +---------------------------------------------------------------------------- + *g:EditorConfig_core_mode* +Specify the mode of EditorConfig core. Generally it is OK to leave this option +empty. Currently, the supported modes are "vim_core" (default) and +"external_command". + + vim_core: Use the included VimScript EditorConfig Core. + external_command: Run external EditorConfig Core. + +If "g:EditorConfig_core_mode" is not specified, this plugin will automatically +choose "vim_core". + +If you choose "external_command" mode, you must also set +|g:EditorConfig_exec_path|. + +Changes to "g:EditorConfig_core_mode" will not take effect until Vim +is restarted. + + *b:EditorConfig_disable* +This is a buffer-local variable that disables the EditorConfig plugin for a +single buffer. + +Example: Disable EditorConfig for the current buffer: +> + let b:EditorConfig_disable = 1 +< +Example: Disable EditorConfig for all git commit messages: +> + au FileType gitcommit let b:EditorConfig_disable = 1 +< + + *g:EditorConfig_exclude_patterns* +This is a list contains file path patterns which will be ignored by +EditorConfig plugin. When the path of the opened buffer (i.e. +"expand('%:p')") matches any of the patterns in the list, EditorConfig will +not load for this file. The default is an empty list. + +Example: Avoid loading EditorConfig for any remote files over ssh +> + let g:EditorConfig_exclude_patterns = ['scp://.*'] +< + + *g:EditorConfig_exec_path* +The file path to the EditorConfig core executable. You can set this value in +your |vimrc| like this: +> + let g:EditorConfig_exec_path = 'Path to your EditorConfig Core executable' +< +The default value is empty. + +If "g:EditorConfig_exec_path" is not set, the plugin will use the "vim_core" +mode regardless of the setting of |g:EditorConfig_core_mode|. + +Changes to "g:EditorConfig_exec_path" will not take effect until Vim +is restarted. + + *g:EditorConfig_max_line_indicator* +The way to show the line where the maximal length is reached. Accepted values +are "line", "fill" and "exceeding", otherwise there will be no max line +indicator. + + "line": the right column of the max line length column will be + highlighted, made possible by adding "+1" to 'colorcolumn'. + + "fill": all the columns to the right of the max line length column + will be highlighted, made possible by setting 'colorcolumn' + to a list of numbers starting from "max_line_length + 1" to + the number of columns on the screen. + + "exceeding": the right column of the max line length column will be + highlighted on lines that exceed the max line length, made + possible by adding a match for the ColorColumn group. + + "none": no max line length indicator will be shown. This is the + recommended value when you do not want any indicator to be + shown, but values other than "line" or "fill" would also work + as "none". + +To set this option, add any of the following lines to your |vimrc| file: +> + let g:EditorConfig_max_line_indicator = "line" + let g:EditorConfig_max_line_indicator = "fill" + let g:EditorConfig_max_line_indicator = "exceeding" + let g:EditorConfig_max_line_indicator = "none" +< +The default value is "line". + + *g:EditorConfig_preserve_formatoptions* +Set this to 1 if you don't want your formatoptions modified when +max_line_length is set: +> + let g:EditorConfig_preserve_formatoptions = 1 +< +This option defaults to 0. + + *g:EditorConfig_softtabstop_space* +When spaces are used for indent, Vim's 'softtabstop' feature will make the +backspace key delete one indent level. If you turn off that feature (by +setting the option to 0), only a single space will be deleted. +This option defaults to 1, which enables 'softtabstop' and uses the +'shiftwidth' value for it. You can also set this to -1 to automatically follow +the current 'shiftwidth' value (since Vim 7.3.693). Or set this to [] if +EditorConfig should not touch 'softtabstop' at all. + + *g:EditorConfig_softtabstop_tab* +When tabs are used for indent, Vim's 'softtabstop' feature only applies to +backspacing over existing runs of spaces. +This option defaults to 1, so backspace will delete one indent level worth of +spaces; -1 does the same but automatically follows the current 'shiftwidth' +value. Set this to 0 to have backspace delete just a single space character. +Or set this to [] if EditorConfig should not touch 'softtabstop' at all. + + *g:EditorConfig_verbose* +Set this to 1 if you want debug info printed: +> + let g:EditorConfig_verbose = 1 +< + +ADVANCED~ + *editorconfig-advanced* +---------------------------------------------------------------------------- + *editorconfig-hook* + *EditorConfig#AddNewHook()* +While this plugin offers several builtin supported properties (as mentioned +here: https://github.com/editorconfig/editorconfig-vim#supported-properties), +we are also able to add our own hooks to support additional EditorConfig +properties, including those not in the EditorConfig standard. For example, we +are working on an Objective-C project, and all our "*.m" files should be +Objective-C source files. However, vim sometimes detect "*.m" files as MATLAB +source files, which causes incorrect syntax highlighting, code indentation, +etc. To solve the case, we could write the following code into the |vimrc| +file: +> + function! FiletypeHook(config) + if has_key(a:config, 'vim_filetype') + let &filetype = a:config['vim_filetype'] + endif + + return 0 " Return 0 to show no error happened + endfunction + + call editorconfig#AddNewHook(function('FiletypeHook')) +< +And add the following code to your .editorconfig file: +> + [*.m] + vim_filetype = objc +< +Then try to open an Objective-C file, you will find the |filetype| is set to +"objc". + +vim:ft=help:tw=78 diff --git a/sources_non_forked/editorconfig-vim/mkzip.sh b/sources_non_forked/editorconfig-vim/mkzip.sh new file mode 100644 index 00000000..811724ca --- /dev/null +++ b/sources_non_forked/editorconfig-vim/mkzip.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +zip -r editorconfig-vim-$*.zip plugin/* autoload/* doc/* diff --git a/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim b/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim new file mode 100644 index 00000000..dba9ec37 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/plugin/editorconfig.vim @@ -0,0 +1,535 @@ +" plugin/editorconfig.vim: EditorConfig native Vimscript plugin file +" Copyright (c) 2011-2019 EditorConfig Team +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" +" 1. Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" 2. Redistributions in binary form must reproduce the above copyright notice, +" this list of conditions and the following disclaimer in the documentation +" and/or other materials provided with the distribution. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +" POSSIBILITY OF SUCH DAMAGE. +" + +" check for Vim versions and duplicate script loading. +if v:version < 700 || exists("g:loaded_EditorConfig") + finish +endif +let g:loaded_EditorConfig = 1 + +let s:saved_cpo = &cpo +set cpo&vim + +" variables {{{1 + +" Make sure the globals all exist +if !exists('g:EditorConfig_exec_path') + let g:EditorConfig_exec_path = '' +endif + +if !exists('g:EditorConfig_verbose') + let g:EditorConfig_verbose = 0 +endif + +if !exists('g:EditorConfig_preserve_formatoptions') + let g:EditorConfig_preserve_formatoptions = 0 +endif + +if !exists('g:EditorConfig_max_line_indicator') + let g:EditorConfig_max_line_indicator = 'line' +endif + +if !exists('g:EditorConfig_exclude_patterns') + let g:EditorConfig_exclude_patterns = [] +endif + +if !exists('g:EditorConfig_disable_rules') + let g:EditorConfig_disable_rules = [] +endif + +if !exists('g:EditorConfig_softtabstop_space') + let g:EditorConfig_softtabstop_space = 1 +endif + +if !exists('g:EditorConfig_softtabstop_tab') + let g:EditorConfig_softtabstop_tab = 1 +endif + +" Copy some of the globals into script variables --- changes to these +" globals won't affect the plugin until the plugin is reloaded. +if exists('g:EditorConfig_core_mode') && !empty(g:EditorConfig_core_mode) + let s:editorconfig_core_mode = g:EditorConfig_core_mode +else + let s:editorconfig_core_mode = '' +endif + +if exists('g:EditorConfig_exec_path') && !empty(g:EditorConfig_exec_path) + let s:editorconfig_exec_path = g:EditorConfig_exec_path +else + let s:editorconfig_exec_path = '' +endif + +let s:initialized = 0 + +" }}}1 + +" shellslash handling {{{1 +function! s:DisableShellSlash() " {{{2 + " disable shellslash for proper escaping of Windows paths + + " In Windows, 'shellslash' also changes the behavior of 'shellescape'. + " It makes 'shellescape' behave like in UNIX environment. So ':setl + " noshellslash' before evaluating 'shellescape' and restore the + " settings afterwards when 'shell' does not contain 'sh' somewhere. + if has('win32') && empty(matchstr(&shell, 'sh')) + let s:old_shellslash = &l:shellslash + setlocal noshellslash + endif +endfunction " }}}2 + +function! s:ResetShellSlash() " {{{2 + " reset shellslash to the user-set value, if any + if exists('s:old_shellslash') + let &l:shellslash = s:old_shellslash + unlet! s:old_shellslash + endif +endfunction " }}}2 +" }}}1 + +" Mode initialization functions {{{1 + +function! s:InitializeVimCore() +" Initialize vim core. Returns 1 on failure; 0 on success +" At the moment, all we need to do is to check that it is installed. + try + let l:vim_core_ver = editorconfig_core#version() + catch + return 1 + endtry + return 0 +endfunction + +function! s:InitializeExternalCommand() +" Initialize external_command mode + + if empty(s:editorconfig_exec_path) + echo 'Please specify a g:EditorConfig_exec_path' + return 1 + endif + + if g:EditorConfig_verbose + echo 'Checking for external command ' . s:editorconfig_exec_path . ' ...' + endif + + if !executable(s:editorconfig_exec_path) + echo 'File ' . s:editorconfig_exec_path . ' is not executable.' + return 1 + endif + + return 0 +endfunction +" }}}1 + +function! s:Initialize() " Initialize the plugin. {{{1 + " Returns truthy on error, falsy on success. + + if empty(s:editorconfig_core_mode) + let s:editorconfig_core_mode = 'vim_core' " Default core choice + endif + + if s:editorconfig_core_mode ==? 'external_command' + if s:InitializeExternalCommand() + echohl WarningMsg + echo 'EditorConfig: Failed to initialize external_command mode. ' . + \ 'Falling back to vim_core mode.' + echohl None + let s:editorconfig_core_mode = 'vim_core' + endif + endif + + if s:editorconfig_core_mode ==? 'vim_core' + if s:InitializeVimCore() + echohl ErrorMsg + echo 'EditorConfig: Failed to initialize vim_core mode. ' . + \ 'The plugin will not function.' + echohl None + return 1 + endif + + elseif s:editorconfig_core_mode ==? 'external_command' + " Nothing to do here, but this elseif is required to avoid + " external_command falling into the else clause. + + else " neither external_command nor vim_core + echohl ErrorMsg + echo "EditorConfig: I don't know how to use mode " . s:editorconfig_core_mode + echohl None + return 1 + endif + + let s:initialized = 1 + return 0 +endfunction " }}}1 + +function! s:GetFilenames(path, filename) " {{{1 +" Yield full filepath for filename in each directory in and above path + + let l:path_list = [] + let l:path = a:path + while 1 + let l:path_list += [l:path . '/' . a:filename] + let l:newpath = fnamemodify(l:path, ':h') + if l:path == l:newpath + break + endif + let l:path = l:newpath + endwhile + return l:path_list +endfunction " }}}1 + +function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1 + let b:editorconfig_tried = 1 + let l:buffer_name = expand('%:p') + " ignore buffers without a name + if empty(l:buffer_name) + return + endif + + if exists("b:EditorConfig_disable") && b:EditorConfig_disable + if g:EditorConfig_verbose + echo 'Skipping EditorConfig for buffer "' . l:buffer_name . '"' + endif + return + endif + + " Check if any .editorconfig does exist + let l:conf_files = s:GetFilenames(expand('%:p:h'), '.editorconfig') + let l:conf_found = 0 + for conf_file in conf_files + if filereadable(conf_file) + let l:conf_found = 1 + break + endif + endfor + if !l:conf_found + return + endif + + if !s:initialized + if s:Initialize() + return + endif + endif + + if g:EditorConfig_verbose + echo 'Applying EditorConfig ' . s:editorconfig_core_mode . + \ ' on file "' . l:buffer_name . '"' + endif + + " Ignore specific patterns + for pattern in g:EditorConfig_exclude_patterns + if l:buffer_name =~ pattern + return + endif + endfor + + if s:editorconfig_core_mode ==? 'vim_core' + if s:UseConfigFiles_VimCore() == 0 + let b:editorconfig_applied = 1 + endif + elseif s:editorconfig_core_mode ==? 'external_command' + call s:UseConfigFiles_ExternalCommand() + let b:editorconfig_applied = 1 + else + echohl Error | + \ echo "Unknown EditorConfig Core: " . + \ s:editorconfig_core_mode | + \ echohl None + endif +endfunction " }}}1 + +" Custom commands, and autoloading {{{1 + +" Autocommands, and function to enable/disable the plugin {{{2 +function! s:EditorConfigEnable(should_enable) + augroup editorconfig + autocmd! + if a:should_enable + autocmd BufNewFile,BufReadPost,BufFilePost * call s:UseConfigFiles() + endif + augroup END +endfunction + +" }}}2 + +" Commands {{{2 +command! EditorConfigEnable call s:EditorConfigEnable(1) +command! EditorConfigDisable call s:EditorConfigEnable(0) + +command! EditorConfigReload call s:UseConfigFiles() " Reload EditorConfig files +" }}}2 + +" On startup, enable the autocommands +call s:EditorConfigEnable(1) + +" Always set the filetype for .editorconfig files +augroup editorconfig_dosini + autocmd! + autocmd BufNewFile,BufRead .editorconfig set filetype=dosini +augroup END + +" }}}1 + +" UseConfigFiles function for different modes {{{1 + +function! s:UseConfigFiles_VimCore() +" Use the vimscript EditorConfig core + try + let l:config = editorconfig_core#handler#get_configurations( + \ { 'target': expand('%:p') } ) + call s:ApplyConfig(l:config) + return 0 " success + catch + return 1 " failure + endtry +endfunction + +function! s:UseConfigFiles_ExternalCommand() +" Use external EditorConfig core (e.g., the C core) + + call s:DisableShellSlash() + let l:exec_path = shellescape(s:editorconfig_exec_path) + call s:ResetShellSlash() + + call s:SpawnExternalParser(l:exec_path) +endfunction + +function! s:SpawnExternalParser(cmd) " {{{2 +" Spawn external EditorConfig. Used by s:UseConfigFiles_ExternalCommand() + + let l:cmd = a:cmd + + if empty(l:cmd) + throw 'No cmd provided' + endif + + let l:config = {} + + call s:DisableShellSlash() + let l:cmd = l:cmd . ' ' . shellescape(expand('%:p')) + call s:ResetShellSlash() + + let l:parsing_result = split(system(l:cmd), '\v[\r\n]+') + + " if editorconfig core's exit code is not zero, give out an error + " message + if v:shell_error != 0 + echohl ErrorMsg + echo 'Failed to execute "' . l:cmd . '". Exit code: ' . + \ v:shell_error + echo '' + echo 'Message:' + echo l:parsing_result + echohl None + return + endif + + if g:EditorConfig_verbose + echo 'Output from EditorConfig core executable:' + echo l:parsing_result + endif + + for one_line in l:parsing_result + let l:eq_pos = stridx(one_line, '=') + + if l:eq_pos == -1 " = is not found. Skip this line + continue + endif + + let l:eq_left = strpart(one_line, 0, l:eq_pos) + if l:eq_pos + 1 < strlen(one_line) + let l:eq_right = strpart(one_line, l:eq_pos + 1) + else + let l:eq_right = '' + endif + + let l:config[l:eq_left] = l:eq_right + endfor + + call s:ApplyConfig(l:config) +endfunction " }}}2 + +" }}}1 + +function! s:ApplyConfig(config) abort " Set the buffer options {{{1 + " Only process normal buffers (do not treat help files as '.txt' files) + if index(['', 'acwrite'], &buftype) == -1 + return + endif + + if g:EditorConfig_verbose + echo 'Options: ' . string(a:config) + endif + + if s:IsRuleActive('indent_style', a:config) + if a:config["indent_style"] == "tab" + setl noexpandtab + elseif a:config["indent_style"] == "space" + setl expandtab + endif + endif + + if s:IsRuleActive('tab_width', a:config) + let &l:tabstop = str2nr(a:config["tab_width"]) + endif + + if s:IsRuleActive('indent_size', a:config) + " if indent_size is 'tab', set shiftwidth to tabstop; + " if indent_size is a positive integer, set shiftwidth to the integer + " value + if a:config["indent_size"] == "tab" + let &l:shiftwidth = &l:tabstop + if type(g:EditorConfig_softtabstop_tab) != type([]) + let &l:softtabstop = g:EditorConfig_softtabstop_tab > 0 ? + \ &l:shiftwidth : g:EditorConfig_softtabstop_tab + endif + else + let l:indent_size = str2nr(a:config["indent_size"]) + if l:indent_size > 0 + let &l:shiftwidth = l:indent_size + if type(g:EditorConfig_softtabstop_space) != type([]) + let &l:softtabstop = g:EditorConfig_softtabstop_space > 0 ? + \ &l:shiftwidth : g:EditorConfig_softtabstop_space + endif + endif + endif + + endif + + if s:IsRuleActive('end_of_line', a:config) && + \ &l:modifiable + if a:config["end_of_line"] == "lf" + setl fileformat=unix + elseif a:config["end_of_line"] == "crlf" + setl fileformat=dos + elseif a:config["end_of_line"] == "cr" + setl fileformat=mac + endif + endif + + if s:IsRuleActive('charset', a:config) && + \ &l:modifiable + if a:config["charset"] == "utf-8" + setl fileencoding=utf-8 + setl nobomb + elseif a:config["charset"] == "utf-8-bom" + setl fileencoding=utf-8 + setl bomb + elseif a:config["charset"] == "latin1" + setl fileencoding=latin1 + setl nobomb + elseif a:config["charset"] == "utf-16be" + setl fileencoding=utf-16be + setl bomb + elseif a:config["charset"] == "utf-16le" + setl fileencoding=utf-16le + setl bomb + endif + endif + + augroup editorconfig_trim_trailing_whitespace + autocmd! BufWritePre + if s:IsRuleActive('trim_trailing_whitespace', a:config) && + \ get(a:config, 'trim_trailing_whitespace', 'false') ==# 'true' + autocmd BufWritePre call s:TrimTrailingWhitespace() + endif + augroup END + + if s:IsRuleActive('insert_final_newline', a:config) + if exists('+fixendofline') + if a:config["insert_final_newline"] == "false" + setl nofixendofline + else + setl fixendofline + endif + elseif exists(':SetNoEOL') == 2 + if a:config["insert_final_newline"] == "false" + silent! SetNoEOL " Use the PreserveNoEOL plugin to accomplish it + endif + endif + endif + + " highlight the columns following max_line_length + if s:IsRuleActive('max_line_length', a:config) && + \ a:config['max_line_length'] != 'off' + let l:max_line_length = str2nr(a:config['max_line_length']) + + if l:max_line_length >= 0 + let &l:textwidth = l:max_line_length + if g:EditorConfig_preserve_formatoptions == 0 + setlocal formatoptions+=tc + endif + endif + + if exists('+colorcolumn') + if l:max_line_length > 0 + if g:EditorConfig_max_line_indicator == 'line' + setlocal colorcolumn+=+1 + elseif g:EditorConfig_max_line_indicator == 'fill' && + \ l:max_line_length < &l:columns + " Fill only if the columns of screen is large enough + let &l:colorcolumn = join( + \ range(l:max_line_length+1,&l:columns),',') + elseif g:EditorConfig_max_line_indicator == 'exceeding' + let &l:colorcolumn = '' + for l:match in getmatches() + if get(l:match, 'group', '') == 'ColorColumn' + call matchdelete(get(l:match, 'id')) + endif + endfor + call matchadd('ColorColumn', + \ '\%' . (l:max_line_length + 1) . 'v.', 100) + endif + endif + endif + endif + + call editorconfig#ApplyHooks(a:config) +endfunction + +" }}}1 + +function! s:TrimTrailingWhitespace() " {{{1 + if &l:modifiable + " don't lose user position when trimming trailing whitespace + let s:view = winsaveview() + try + silent! keeppatterns keepjumps %s/\s\+$//e + finally + call winrestview(s:view) + endtry + endif +endfunction " }}}1 + +function! s:IsRuleActive(name, config) " {{{1 + return index(g:EditorConfig_disable_rules, a:name) < 0 && + \ has_key(a:config, a:name) +endfunction "}}}1 + +let &cpo = s:saved_cpo +unlet! s:saved_cpo + +" vim: fdm=marker fdc=3 diff --git a/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt b/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt new file mode 100644 index 00000000..2c124403 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/CMakeLists.txt @@ -0,0 +1,53 @@ +# CMakeLists.txt for core testing in +# editorconfig-core-vimscript and editorconfig-vim. + +# Copyright (c) 2011-2019 EditorConfig Team +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# To perform the test, from the root of the project tree, run +# mkdir build +# cd build +# cmake .. +# ctest . + +cmake_minimum_required(VERSION 3.5) +#set(CMAKE_LEGACY_CYGWIN_WIN32 0) + +# Do not check any compiler +project(editorconfig-core-vimscript NONE) + +enable_testing() + +# The test executable to use +if(NOT WIN32) + set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig") +else() + set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig.bat") +endif() +set(EDITORCONFIG_CMD_IS_TARGET FALSE) + +add_subdirectory(tests) + +# CTestCustom.cmake contains platform-specific test configuration. +configure_file(CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) diff --git a/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake b/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake new file mode 100644 index 00000000..5452f751 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/CTestCustom.cmake @@ -0,0 +1,34 @@ +# CTestCustom.cmake: Skip UTF-8 tests +# Part of editorconfig-vim + +# Copyright (c) 2011-2019 EditorConfig Team +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# Skip UTF8 tests on Windows for now per +# https://github.com/editorconfig/editorconfig-core-c/pull/31#issue-154810185 +if(WIN32 AND (NOT "$ENV{RUN_UTF8}")) + message(WARNING "Skipping UTF-8 tests on this platform") + set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} g_utf_8_char) + set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} utf_8_char) +endif() diff --git a/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs b/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs new file mode 100644 index 00000000..a1e05d24 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs @@ -0,0 +1,171 @@ +' ecvbslib.vbs: VBScript routines for use in +' editorconfig-core-vimscript and editorconfig-vim. +' Copyright (c) 2018--2019 Chris White. All rights reserved. +' Licensed CC-BY-SA, version 3.0 or any later version, at your option. + +' Remove CR and LF in a string +function nocrlf(strin) + nocrlf = Replace(Replace(strin, vbCr, ""), vbLf, "") +end function + +' === Base64 ================================================================ +' from https://stackoverflow.com/a/40118072/2877364 by +' https://stackoverflow.com/users/45375/mklement0 + +' Base64-encodes the specified string. +' Parameter fAsUtf16LE determines how the input text is encoded at the +' byte level before Base64 encoding is applied. +' * Pass False to use UTF-8 encoding. +' * Pass True to use UTF-16 LE encoding. +Function Base64Encode(ByVal sText, ByVal fAsUtf16LE) + + ' Use an aux. XML document with a Base64-encoded element. + ' Assigning the byte stream (array) returned by StrToBytes() to .NodeTypedValue + ' automatically performs Base64-encoding, whose result can then be accessed + ' as the element's text. + With CreateObject("Msxml2.DOMDocument").CreateElement("aux") + .DataType = "bin.base64" + if fAsUtf16LE then + .NodeTypedValue = StrToBytes(sText, "utf-16le", 2) + else + .NodeTypedValue = StrToBytes(sText, "utf-8", 3) + end if + Base64Encode = nocrlf(.Text) ' No line breaks; MSXML adds them. + End With + +End Function + +' Decodes the specified Base64-encoded string. +' If the decoded string's original encoding was: +' * UTF-8, pass False for fIsUtf16LE. +' * UTF-16 LE, pass True for fIsUtf16LE. +Function Base64Decode(ByVal sBase64EncodedText, ByVal fIsUtf16LE) + + Dim sTextEncoding + if fIsUtf16LE Then sTextEncoding = "utf-16le" Else sTextEncoding = "utf-8" + + ' Use an aux. XML document with a Base64-encoded element. + ' Assigning the encoded text to .Text makes the decoded byte array + ' available via .nodeTypedValue, which we can pass to BytesToStr() + With CreateObject("Msxml2.DOMDocument").CreateElement("aux") + .DataType = "bin.base64" + .Text = sBase64EncodedText + Base64Decode = BytesToStr(.NodeTypedValue, sTextEncoding) + End With + +End Function + +' Returns a binary representation (byte array) of the specified string in +' the specified text encoding, such as "utf-8" or "utf-16le". +' Pass the number of bytes that the encoding's BOM uses as iBomByteCount; +' pass 0 to include the BOM in the output. +function StrToBytes(ByVal sText, ByVal sTextEncoding, ByVal iBomByteCount) + + ' Create a text string with the specified encoding and then + ' get its binary (byte array) representation. + With CreateObject("ADODB.Stream") + ' Create a stream with the specified text encoding... + .Type = 2 ' adTypeText + .Charset = sTextEncoding + .Open + .WriteText sText + ' ... and convert it to a binary stream to get a byte-array + ' representation. + .Position = 0 + .Type = 1 ' adTypeBinary + .Position = iBomByteCount ' skip the BOM + StrToBytes = .Read + .Close + End With + +end function + +' Returns a string that corresponds to the specified byte array, interpreted +' with the specified text encoding, such as "utf-8" or "utf-16le". +function BytesToStr(ByVal byteArray, ByVal sTextEncoding) + + If LCase(sTextEncoding) = "utf-16le" then + ' UTF-16 LE happens to be VBScript's internal encoding, so we can + ' take a shortcut and use CStr() to directly convert the byte array + ' to a string. + BytesToStr = CStr(byteArray) + Else ' Convert the specified text encoding to a VBScript string. + ' Create a binary stream and copy the input byte array to it. + With CreateObject("ADODB.Stream") + .Type = 1 ' adTypeBinary + .Open + .Write byteArray + ' Now change the type to text, set the encoding, and output the + ' result as text. + .Position = 0 + .Type = 2 ' adTypeText + .CharSet = sTextEncoding + BytesToStr = .ReadText + .Close + End With + End If + +end function + +' === Runner ================================================================ + +' Run a command, copy its stdout/stderr to ours, and return its exit +' status. +' Modified from https://stackoverflow.com/a/32493083/2877364 by +' https://stackoverflow.com/users/3191599/nate-barbettini . +' See also https://www.vbsedit.com/html/4c5b06ac-dc45-4ec2-aca1-f168bab75483.asp +function RunCommandAndEcho(strCommand) + Const WshRunning = 0 + Const WshFinished = 1 + Const WshFailed = 2 + + Set WshShell = CreateObject("WScript.Shell") + 'WScript.Echo "Running >>" & strCommand & "<<..." + Set WshShellExec = WshShell.Exec(strCommand) + + Do While WshShellExec.Status = WshRunning + 'WScript.Echo "Waiting..." + WScript.Sleep 100 + Loop + + if not WshShellExec.StdOut.AtEndOfStream then + WScript.StdOut.Write(WshShellExec.StdOut.ReadAll()) + end if + + if not WshShellExec.StdErr.AtEndOfStream then + WScript.StdErr.Write(WshShellExec.StdErr.ReadAll()) + end if + + RunCommandAndEcho = WshShellExec.ExitCode +end function + +' === Argument processing =================================================== + +function MakeY64Args(args) + + dim b64args(100) ' 100 = arbitrary max + + ' Make Y64-flavored base64 versions of each arg so we don't have to + ' worry about quoting issues while executing PowerShell. + + idx=0 + For Each arg In args + b64args(idx) = Base64Encode(nocrlf(arg), False) + ' Y64 flavor of Base64 + b64args(idx) = replace( _ + replace( _ + replace(b64args(idx), "+", "."), _ + "/", "_" ), _ + "=", "-") + 'Wscript.Echo cstr(idx) & ": >" & arg & "< = >" & b64args(idx) & "<" + 'Wscript.Echo b64args(idx) + idx = idx+1 + Next + + MakeY64Args = b64args +end function + +Function QuoteForShell(strIn) + QuoteForShell = """" & _ + replace(strIn, """", """""") & """" +End Function diff --git a/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 b/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 new file mode 100644 index 00000000..45387d5a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1 @@ -0,0 +1,140 @@ +# ecvimlib.ps1: Editorconfig Vimscript core CLI, PowerShell version, +# library routines. +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. +# +# N.B.: debug output uses Warning only because those are displayed by default. + +#Requires -Version 3 + +# Get the directory of this script. From +# https://stackoverflow.com/a/5466355/2877364 by +# https://stackoverflow.com/users/23283/jaredpar + +$global:DIR = $PSScriptRoot + +### Set up debugging output ============================================ + +$global:debug=$env:EDITORCONFIG_DEBUG # Debug filename + +if($global:debug -and ($global:debug -notmatch '^/')) { + # Relative to this script unless it starts with a slash. This is because + # cwd is usually not $DIR when testing. + $global:debug="${DIR}/${global:debug}" +} + +### Process args ======================================================= + +function de64_args($argv) { + $argv | % { + $b64 = $_ -replace '-','=' -replace '_','/' -replace '\.','+' + [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($b64)) + } +} + +### Helpers ============================================================ + +# Append a string to $debug in UTF-8 rather than the default UTF-16 +filter global:D($file = $debug) { + if($debug) { + echo $_ | Out-File -FilePath $file -Encoding utf8 -Append + } +} + +# Escape a string for Vim +function global:vesc($str) { + return "'" + ($str -replace "'","''") + "'" +} + +# Escape a string for a command-line argument. +# See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.arguments?view=netframework-4.7.2 +function global:argesc($arg) { + return '"' + ($arg -replace '"','"""') + '"' +} + +### Find the Vim EXE =================================================== + +function global:Find-Vim +{ + if($env:VIM_EXE) { + if($debug) { echo "Using env Vim $($env:VIM_EXE)" | D } + return $env:VIM_EXE + } + + $vims = @(get-childitem 'c:\program files*\vim\**\vim.exe' | ` + sort LastWriteTime -Descending) # @() => always array + + # write-host ($vims | format-table | out-string) # DEBUG + # write-host ($vims | get-member | out-string) + if($vims.count -gt 0) { + if($debug) { echo "Using found Vim $($vims[0].FullName)" | D } + return $vims[0].FullName + } + + throw "Could not find vim.exe. Please set VIM_EXE to the path to your Vim." +} #Find-Vim + +### Runner ============================================================= + +# Run a process with the given arguments. +function global:run_process +{ + param( + [Parameter(Mandatory=$true, Position=0)][string]$run, + [string]$extrapath, + [string]$stdout, # Redirect stdout to this file + [string]$stderr, # Redirect stderr to this file + [string[]]$argv # Arguments to $run + ) + $si = new-object Diagnostics.ProcessStartInfo + if($extrapath) { + $si.EnvironmentVariables['path']+=";${extrapath}" + } + $si.FileName=$run + + # Stringify the arguments (blech) + $argstr = $argv | % { (argesc $_) + ' ' } + $si.Arguments = $argstr; + + if($debug) { echo "Running process $run with arguments >>$argstr<<" | D } + + $si.UseShellExecute=$false + # DEBUG $si.RedirectStandardInput=$true + if($stdout) { + if($debug) { echo "Saving stdout to ${stdout}" | D } + $si.RedirectStandardOutput=$true; + } + if($stderr) { + if($debug) { echo "Saving stderr to ${stderr}" | D } + $si.RedirectStandardError=$true; + } + + $p = [Diagnostics.Process]::Start($si) + # DEBUG $p.StandardInput.Close() # < /dev/null + + $p.WaitForExit() + $retval = $p.ExitCode + + if($stdout) { + echo "Standard output:" | D $stdout + $p.StandardOutput.ReadToEnd() | ` + Out-File -FilePath $stdout -Encoding utf8 -Append + } + + if($stderr) { + echo "Standard error:" | D $stderr + $p.StandardError.ReadToEnd() | ` + Out-File -FilePath $stderr -Encoding utf8 -Append + } + + $p.Close() + + return $retval +} + +if($debug) { + echo "======================================================" | D + Get-Date -format F | D +} + +$global:VIM = Find-Vim diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig b/sources_non_forked/editorconfig-vim/tests/core/editorconfig new file mode 100644 index 00000000..bdb5971d --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig @@ -0,0 +1,219 @@ +#!/bin/bash +# editorconfig: Editorconfig Vimscript core CLI +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. + +# Documentation {{{1 +helpstr=$(cat<<'EOF' +editorconfig: command-line invoker for the Vimscript editorconfig core + +Normal usage: + editorconfig [-f ] [-b ] + [-x ] + +The default is ".editorconfig". +If -b is given, behave as . +If -x is given, the is included in the debug-output file. + +Other options: + editorconfig -h, --help Show this help + editorconfig -v, --version Show version information + +Environment variables: + VIM_EXE File/path of vim (default "vim") + EDITORCONFIG_DEBUG File/path to which to append debug output + +EOF +) + +# }}}1 + +# Get the directory of this script into $this_script_dir. {{{1 +# From https://stackoverflow.com/a/246128/2877364 by +# https://stackoverflow.com/users/407731 et al. + +this_script_dir= +function get_dir() +{ + local script_source_path="${BASH_SOURCE[0]}" + while [ -h "$script_source_path" ]; do + # resolve $script_source_path until the file is no longer a symlink + this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )" + script_source_path="$(readlink "$script_source_path")" + [[ $script_source_path != /* ]] && script_source_path="$this_script_dir/$script_source_path" + # if $script_source_path was a relative symlink, we need to resolve + # it relative to the path where the symlink file was located + done + this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )" +} #get_dir() + +get_dir + +# }}}1 + +# Setup debug output, if $EDITORCONFIG_DEBUG is given {{{1 +debug="${EDITORCONFIG_DEBUG}" # Debug filename +if [[ $debug && $debug != /* ]]; then # Relative to this script unless it + debug="${this_script_dir}/${debug}" # starts with a slash. This is because +fi # cwd is usually not $this_script_dir when testing. +if [[ $debug ]] && ! touch "$debug"; then + echo "Could not write file '$debug' - aborting" 1>&2 + exit 1 +fi + +[[ $debug ]] && echo "$(date) ==================================" >> "$debug" + +# }}}1 + +# Option processing {{{1 + +# Use a manually-specified Vim, if any +if [[ $VIM_EXE ]]; then + vim_pgm="$VIM_EXE" +else + vim_pgm="vim" +fi + +# Command-line options +confname= +ver= +print_ver= +extra_info= + +while getopts 'hvf:b:-:x:' opt ; do + case "$opt" in + (v) print_ver=1 + ;; + + (f) confname="$OPTARG" + ;; + + (b) ver="$OPTARG" + ;; + + (-) case "$OPTARG" in # hacky long-option processing + version) print_ver=1 + ;; + dummy) # A dummy option so that I can test + # list-valued EDITORCONFIG_CMD + ;; + help) echo "$helpstr" + exit 0 + ;; + esac + ;; + + (h) echo "$helpstr" + exit 0 + ;; + + # A way to put the test name into the log + (x) extra_info="$OPTARG" + ;; + + esac +done + +shift $(( $OPTIND - 1 )) + +if [[ $print_ver ]]; then + echo "EditorConfig VimScript Core Version 0.12.2" + exit 0 +fi + +if (( "$#" < 1 )); then + exit 1 +fi + +if [[ $1 = '-' ]]; then + echo "Reading filenames from stdin not yet supported" 1>&2 # TODO + exit 1 +fi + +# }}}1 + +# Build the Vim command line {{{1 + +fn="$(mktemp)" # Vim will write the settings into here. ~stdout. +script_output_fn="${debug:+$(mktemp)}" # Vim's :messages. ~stderr. + +cmd="call editorconfig_core#currbuf_cli({" + +# Names +cmd+="'output':'${fn//\'/\'\'}', " + # filename to put the settings in +[[ $debug ]] && cmd+=" 'dump':'${script_output_fn//\'/\'\'}', " + # where to put debug info + +# Filenames to get the settings for +cmd+="'target':[" +for f in "$@" ; do + cmd+="'${f//\'/\'\'}', " +done +cmd+="]," + # filename to get the settings for + +# Job +cmd+="}, {" +[[ $confname ]] && cmd+="'config':'${confname//\'/\'\'}', " + # config name (e.g., .editorconfig) +[[ $ver ]] && cmd+="'version':'${ver//\'/\'\'}', " + # version number we should behave as +cmd+="})" + +vim_args=( + -c "set runtimepath+=$this_script_dir/../.." + -c "$cmd" +) + +# }}}1 + +# Run the editorconfig core through Vim {{{1 +# Thanks for options to +# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript . +# Add -V1 to the below for debugging output. +# Do not output anything to stdout or stderr, +# since it messes up ctest's interpretation +# of the results. + +"$vim_pgm" -nNes -i NONE -u NONE -U NONE \ + "${vim_args[@]}" \ + > "${debug:-/dev/null}" +vimstatus="$?" +if [[ $vimstatus -eq 0 ]]; then + cat "$fn" +fi + +# }}}1 + +# Produce debug output {{{1 +# Debug output cannot be included on stdout or stderr, because +# ctest's regex check looks both of those places. Therefore, dump to a +# separate debugging file. +if [[ $debug ]] +then + [[ $extra_info ]] && echo "--- $extra_info ---" >> "$debug" + echo "Vim in $vim_pgm" >> "$debug" + echo "Current directory: $(pwd)" >> "$debug" + echo "Script directory: $this_script_dir" >> "$debug" + echo Vim args: "${vim_args[@]}" >> "$debug" + #od -c <<<"${vim_args[@]}" >> "$debug" + echo "Vim returned $vimstatus" >> "$debug" + echo "Vim messages were: " >> "$debug" + cat "$script_output_fn" >> "$debug" + echo "Output was:" >> "$debug" + od -c "$fn" >> "$debug" + + rm -f "$script_output_fn" +fi + +# }}}1 + +# Cleanup {{{1 + +rm -f "$fn" + +# }}}1 + +exit "$vimstatus" # forward the Vim exit status to the caller +# vi: set ft=sh fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat b/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat new file mode 100644 index 00000000..77b54470 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig.bat @@ -0,0 +1,11 @@ +@echo off +:: editorconfig.bat: First-level invoker for editorconfig-core-vimscript +:: and editorconfig-vim. +:: Just passes the full command line to editorconfig1.vbs, since VBScript +:: applies very simple quoting rules when it parses a command line. +:: Copyright (c) 2018--2019 Chris White. All rights reserved. +:: Licensed CC-BY-SA, version 3.0 or any later version, at your option. +set here=%~dp0 + +cscript //Nologo "%here%editorconfig1.vbs" %* +:: %* has the whole command line diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs b/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs new file mode 100644 index 00000000..488411fc --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig1.vbs @@ -0,0 +1,39 @@ +' editorconfig1.vbs: run by editorconfig.bat +' runs editorconfig2.ps1 +' Part of editorconfig-core-vimscript and editorconfig-vim. +' +' Copyright (c) 2018--2019 Chris White. All rights reserved. +' Licensed CC-BY-SA, version 3.0 or any later version, at your option. +' +' Modified from +' https://stackoverflow.com/a/2470557/2877364 by +' https://stackoverflow.com/users/2441/aphoria + +' Thanks to https://www.geekshangout.com/vbs-script-to-get-the-location-of-the-current-script/ +currentScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "") + +' Load our common library. Thanks to https://stackoverflow.com/a/316169/2877364 +With CreateObject("Scripting.FileSystemObject") + executeGlobal .openTextFile(currentScriptPath & "ecvbslib.vbs").readAll() +End With + +' === MAIN ================================================================== + +' Encode all the arguments as modified base64 so there will be no quoting +' issues when we invoke powershell. +b64args = MakeY64Args(Wscript.Arguments) + +' Quote script name just in case +ps1name = QuoteForShell(currentScriptPath & "editorconfig2.ps1") +'Wscript.Echo "Script is in " & ps1name + +if True then + retval = RunCommandAndEcho( "powershell.exe" & _ + " -executionpolicy bypass -file " & ps1name & " " & join(b64args) _ + ) + ' add -noexit to leave window open so you can see error messages + + WScript.Quit retval +end if + +' vi: set ts=4 sts=4 sw=4 et ai: diff --git a/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 b/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 new file mode 100644 index 00000000..0bc3602a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1 @@ -0,0 +1,218 @@ +# editorconfig2.ps1: Editorconfig Vimscript core CLI, PowerShell version +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed CC-BY-SA, version 3.0 or any later version, at your option. +# Thanks to https://cecs.wright.edu/~pmateti/Courses/233/Labs/Scripting/bashVsPowerShellTable.html +# by Gallagher and Mateti. + +#Requires -Version 3 + +. "$PSScriptRoot\ecvimlib.ps1" + +# Argument parsing =================================================== {{{1 + +$argv = @(de64_args($args)) + +# Defaults +$report_version = $false +$set_version = '' +$config_name = '.editorconfig' +$extra_info = '' +$files=@() + +# Hand-parse - pretend we're sort of like getopt. +$idx = 0 +while($idx -lt $argv.count) { + $a = $argv[$idx] + + switch -CaseSensitive -Regex ($a) { + '^(-v|--version)$' { $report_version = $true } + + '^--dummy$' { + # A dummy option so that I can test list-valued EDITORCONFIG_CMD + } + + '^-f$' { + if($idx -eq ($argv.count-1)) { + throw '-f : no filename provided' + } else { + ++$idx + $config_name = $argv[$idx] + } + } #-f + + '^-b$' { + if($idx -eq ($argv.count-1)) { + throw '-b : no version provided' + } else { + ++$idx + $set_version = $argv[$idx] + } + } #-b + + '^-x$' { + if($idx -eq ($argv.count-1)) { + throw '-x : no info provided' + } else { + ++$idx + $extra_info = $argv[$idx] + } + } #-x + + '^--$' { # End of options, so capture the rest as filenames + ++$idx; + while($idx -lt $argv.count) { + $files += $argv[$idx] + } + } + + default { $files += $a } + } + + ++$idx +} # end foreach argument + +# }}}1 +# Argument processing ================================================ {{{1 + +if($debug) { + if($extra_info -ne '') { + echo "--- $extra_info --- " | D + } + + echo "Running in $DIR" | D + echo "Vim executable: $VIM" | D + echo "report version? $report_version" | D + echo "set version to: $set_version" | D + echo "config filename: $config_name" | D + echo "Filenames: $files" | D + echo "Args: $args" | D + echo "Decoded args: $argv" | D +} + +if($report_version) { + echo "EditorConfig VimScript Core Version 0.12.2" + exit +} + +if($files.count -lt 1) { + exit +} + +if($files[0] -eq '-') { + echo "Reading filenames from stdin not yet supported" # TODO + exit 1 +} + +$fn=[System.IO.Path]::GetTempFileName(); + # Vim will write the settings into here. Sort of like stdout. +$script_output_fn = '' +if($debug) { + $script_output_fn = [System.IO.Path]::GetTempFileName() +} + +# Permit throwing in setup commands +$cmd = '' +if($env:EDITORCONFIG_EXTRA) { + $cmd += $env:EDITORCONFIG_EXTRA + ' | ' +} + +# }}}1 +# Build Vim command line ============================================= {{{1 +$cmd += 'call editorconfig_core#currbuf_cli({' + +# Names +$cmd += "'output':" + (vesc($fn)) + ", " + # filename to put the settings in +if($debug) { + $cmd += " 'dump':" + (vesc($script_output_fn)) + ", " + # where to put debug info +} + +# Filenames to get the settings for +$cmd += "'target':[" +ForEach ($item in $files) { + $cmd += (vesc($item)) + ", " +} +$cmd += "]," + +# Job +$cmd += "}, {" +if($config_name) { $cmd += "'config':" + (vesc($config_name)) + ", " } + # config name (e.g., .editorconfig) +if($set_version) { $cmd += "'version':" + (vesc($set_version)) + ", " } + # version number we should behave as +$cmd += "})" + +#$cmd =':q!' # DEBUG +if($debug) { echo "Using Vim command ${cmd}" | D } +$vim_args = @( + '-c', "set runtimepath+=${DIR}\..\..", + '-c', $cmd, + '-c', 'quit!' # TODO write a wrapper that will cquit on exception +) + +# Run editorconfig. Thanks for options to +# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript . +# Add -V1 to the below for debugging output. +# Do not output anything to stdout or stderr, +# since it messes up ctest's interpretation +# of the results. + +$basic_args = '-nNes','-i','NONE','-u','NONE','-U','NONE' #, '-V1' + +# }}}1 +# Run Vim ============================================================ {{{1 + +if($debug) { echo "Running vim ${VIM}" | D } +$vimstatus = run_process $VIM -stdout $debug -stderr $debug ` + -argv ($basic_args+$vim_args) +if($debug) { echo "Done running vim" | D } + +if($vimstatus -eq 0) { + cat $fn +} + +# }}}1 +# Produce debug output =============================================== {{{1 + +# Debug output cannot be included on stdout or stderr, because +# ctest's regex check looks both of those places. Therefore, dump to a +# separate debugging file. + +if($debug) { + echo "Current directory:" | D + (get-item -path '.').FullName | D + echo "Script directory: $DIR" | D +### echo Vim args: "${vim_args[@]}" >> "$debug" +### #od -c <<<"${vim_args[@]}" >> "$debug" + echo "Vim returned $vimstatus" | D + echo "Vim messages were: " | D + cat $script_output_fn | D + echo "Output was:" | D + + # Modified from https://www.itprotoday.com/powershell/get-hex-dumps-files-powershell + Get-Content $script_output_fn -Encoding Byte -ReadCount 16 | ` + ForEach-Object { + $output = "" + $chars = '' + foreach ( $byte in $_ ) { + $output += "{0:X2} " -f $byte + if( ($byte -ge 32) -and ($byte -le 127) ) { + $chars += [char]$byte + } else { + $chars += '.' + } + } + $output + ' ' + $chars + } | D + + del -Force $script_output_fn +} #endif $debug + +# }}}1 + +del -Force $fn + +exit $vimstatus + +# vi: set fdm=marker: diff --git a/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat b/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat new file mode 100644 index 00000000..c834fd74 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/fetch-vim.bat @@ -0,0 +1,12 @@ +:: fetch-vim.bat: Fetch vim if necessary +:: For use in the editorconfig-vim Appveyor build +:: Copyright (c) 2018--2019 Chris White. All rights reserved. +:: Licensed Apache 2.0, or any later version, at your option. + +:: If it's already been loaded from the cache, we're done +if exist C:\vim\vim\vim80\vim.exe exit + +:: Otherwise, download and unzip it. +appveyor DownloadFile https://github.com/cxw42/editorconfig-core-vimscript/releases/download/v0.1.0/vim.7z + +7z x vim.7z -oC:\vim diff --git a/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh b/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh new file mode 100644 index 00000000..22e7912a --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/fetch-vim.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# fetch-vim.bat: Fetch vim if necessary +# For use in the editorconfig-vim Appveyor build +# Copyright (c) 2018--2019 Chris White. All rights reserved. +# Licensed Apache 2.0, or any later version, at your option. + +# Debugging +set -x +set -o nounset +#set -o errexit + +# Basic system info +uname -a +pwd +ls -l + +echo "VIM_EXE: $VIM_EXE" +set + +# If it's already been loaded from the cache, we're done +if [[ -x "$VIM_EXE" ]]; then + echo Vim found in cache at "$VIM_EXE" + exit 0 +fi + +# Otherwise, clone and build it +WHITHER="$APPVEYOR_BUILD_FOLDER/vim" + +git clone https://github.com/vim/vim-appimage.git +cd vim-appimage +git submodule update --init --recursive + +cd vim/src +./configure --with-features=huge --prefix="$WHITHER" --enable-fail-if-missing +make -j2 # Free tier provides two cores +make install +./vim --version +cd $APPVEYOR_BUILD_FOLDER +find . -type f -name vim -exec ls -l {} + + +echo Done fetching and installing vim diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore b/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore new file mode 100644 index 00000000..cee07667 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/.gitignore @@ -0,0 +1,2 @@ +# Where bundler installs local Gemfile dependencies +/vendor/ diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile new file mode 100644 index 00000000..49270e49 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gem 'rake', '~> 12.3.3' +gem 'rspec', '~> 3.4.0' +gem 'vimrunner', '~> 0.3.1' diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock new file mode 100644 index 00000000..5d1c3f47 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Gemfile.lock @@ -0,0 +1,27 @@ +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.2.5) + rake (12.3.3) + rspec (3.4.0) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) + vimrunner (0.3.1) + +PLATFORMS + ruby + +DEPENDENCIES + rake (~> 12.3.3) + rspec (~> 3.4.0) + vimrunner (~> 0.3.1) diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile b/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile new file mode 100644 index 00000000..3119d82e --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/Rakefile @@ -0,0 +1,8 @@ +# +# run `rake` to run tests + +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig b/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig new file mode 100644 index 00000000..834f0eb3 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/spec/.editorconfig @@ -0,0 +1,4 @@ +[*.rb] +indent_style = space +indent_size = 2 +end_of_line = lf diff --git a/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb b/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb new file mode 100644 index 00000000..67e2eb71 --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb @@ -0,0 +1,169 @@ +require 'vimrunner' + +def create_vim(*initial_commands) + vim = Vimrunner.start + initial_commands.each do |cmd| + vim.command cmd + end + vim.add_plugin(File.expand_path('../../../..', __FILE__), 'plugin/editorconfig.vim') + return vim +end + +# The base path of the testing files +BASE_PATH = File.expand_path('../plugin_tests/test_files/', __FILE__) + +# file_name is the file name that should be open by Vim +# expected_values is a Hash that contains all the Vim options we need to test +def test_editorconfig(vim, file_name, expected_values) + vim.edit(File.join(BASE_PATH, file_name)) + + expected_values.each do |key, val| + vimval = vim.echo("&l:#{key}") + expect(vimval).to eq(val), "key #{key} had value #{vimval}, but I expected #{val}" + end + + vim.command 'bd!' +end + +def test_instance(vim) + describe 'plugin/editorconfig.vim' do + after(:all) do + vim.kill + end + + describe '#all' do + it '3_space.py' do + test_editorconfig vim, '3_space.txt', + expandtab: '1', + shiftwidth: '3', + tabstop: '3' + end + end + + it '4_space.py' do + test_editorconfig vim, '4_space.py', + expandtab: '1', + shiftwidth: '4', + tabstop: '8' + end + + it 'space.txt' do + test_editorconfig vim, 'space.txt', + expandtab: '1', + shiftwidth: vim.echo('&l:tabstop') + end + + it 'tab.txt' do + test_editorconfig vim, 'tab.txt', + expandtab: '0' + end + + it '4_tab.txt' do + test_editorconfig vim, '4_tab.txt', + expandtab: '0', + shiftwidth: '4', + tabstop: '4' + end + + it '4_tab_width_of_8' do + test_editorconfig vim, '4_tab_width_of_8.txt', + expandtab: '0', + shiftwidth: '4', + tabstop: '8' + end + + it 'lf.txt' do + test_editorconfig vim, 'lf.txt', + fileformat: 'unix' + end + + it 'crlf.txt' do + test_editorconfig vim, 'crlf.txt', + fileformat: 'dos' + end + + it 'cr.txt' do + test_editorconfig vim, 'cr.txt', + fileformat: 'mac' + end + + it 'utf-8.txt' do + test_editorconfig vim, 'utf-8.txt', + fileencoding: 'utf-8', + bomb: '0' + end + + it 'utf-8-bom.txt' do + test_editorconfig vim, 'utf-8-bom.txt', + fileencoding: 'utf-8', + bomb: '1' + end + + it 'utf-16be.txt' do + test_editorconfig vim, 'utf-16be.txt', + fileencoding: 'utf-16' + end + + it 'utf-16le.txt' do + test_editorconfig vim, 'utf-16le.txt', + fileencoding: 'utf-16le' + end + + it 'latin1.txt' do + test_editorconfig vim, 'latin1.txt', + fileencoding: 'latin1' + end + + # insert_final_newline by PreserveNoEOL tests are omitted, since they are not supported + if vim.echo("exists('+fixendofline')") == '1' + it 'with_newline.txt' do + test_editorconfig vim, 'with_newline.txt', + fixendofline: '1' + end + + it 'without_newline.txt' do + test_editorconfig vim, 'without_newline.txt', + fixendofline: '0' + end + end + end +end + +# Test the vim core +(lambda do + puts 'Testing default' + vim = create_vim + test_instance vim +end).call + +# Test the vim core with an express setting +(lambda do + puts 'Testing with express vim_core mode' + vim = create_vim("let g:EditorConfig_core_mode='vim_core'") + test_instance vim +end).call + +# Test with external-core mode, but no external core defined +(lambda do + puts 'Testing with fallback to vim_core mode' + vim = create_vim("let g:EditorConfig_core_mode='external_command'") + test_instance vim +end).call + +# Test with an external core, if desired +extcore = ENV['EDITORCONFIG_VIM_EXTERNAL_CORE'] +if extcore + puts "Testing with external_command #{extcore}" + vim = create_vim( + "let g:EditorConfig_core_mode='external_command'", + "let g:EditorConfig_exec_path='#{extcore}'", + ) + test_instance vim +end + +# Test the vim core with latin1 encoding +(lambda do + puts 'Testing with express vim_core mode' + vim = create_vim("set encoding=latin1") + test_instance vim +end).call diff --git a/sources_non_forked/editorconfig-vim/tests/travis-test.sh b/sources_non_forked/editorconfig-vim/tests/travis-test.sh new file mode 100644 index 00000000..ef886e6b --- /dev/null +++ b/sources_non_forked/editorconfig-vim/tests/travis-test.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# travis-test.sh: Script for running editorconfig-vim tests under Travis CI. +# Copyright (c) 2019 Chris White. All rights reserved. +# Licensed Apache, version 2.0 or any later version, at your option. + +# Error exit; debug output +set -vxEeuo pipefail + +# Permit `travis-test.sh plugin` if TEST_WHICH is unset +if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then + export TEST_WHICH="$1" +fi + +if [[ ! "${TEST_WHICH:-}" ]]; then + cat </dev/null ; pwd)" + export BUNDLE_GEMFILE="${here}/plugin/Gemfile" + # Install into tests/plugin/vendor. Don't clear it first, + # since you can clear it yourself if you're running from a + # dev environment. + bundle install --jobs=3 --retry=3 --deployment + fi + + # Use the standalone Vimscript EditorConfig core to test the plugin's + # external_command mode + export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig + + bundle exec rspec tests/plugin/spec/editorconfig_spec.rb + +elif [[ "$TEST_WHICH" = 'core' ]]; then # test core + cd tests/core + mkdir -p build # May already exist if running from a dev env + cd build + cmake .. + ctest . --output-on-failure -VV -C Debug + # -C Debug: for Visual Studio builds, you have to specify + # a configuration. + +else + echo 'Invalid TEST_WHICH value' 1>&2 + exit 1 +fi diff --git a/sources_non_forked/gist-vim/.github/FUNDING.yml b/sources_non_forked/gist-vim/.github/FUNDING.yml new file mode 100644 index 00000000..351ae11a --- /dev/null +++ b/sources_non_forked/gist-vim/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: mattn # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/sources_non_forked/gist-vim/Makefile b/sources_non_forked/gist-vim/Makefile new file mode 100644 index 00000000..81370a88 --- /dev/null +++ b/sources_non_forked/gist-vim/Makefile @@ -0,0 +1,11 @@ +all : gist-vim.zip + +remove-zip: + -rm -f doc/tags + -rm -f gist-vim.zip + +gist-vim.zip: remove-zip + zip -r gist-vim.zip autoload plugin doc README.mkd + +release: gist-vim.zip + vimup update-script gist.vim diff --git a/sources_non_forked/gist-vim/README.md b/sources_non_forked/gist-vim/README.md new file mode 100644 index 00000000..e91463f1 --- /dev/null +++ b/sources_non_forked/gist-vim/README.md @@ -0,0 +1,281 @@ +# Gist.vim + +This is a vimscript for creating gists (http://gist.github.com). + +For the latest version please see https://github.com/mattn/gist-vim. + +## Usage: + +- Post current buffer to gist, using default privacy option. + + :Gist + +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). + + :'<,'>Gist + +- Create a private gist. + + :Gist -p + +- Create a public gist. + (Only relevant if you've set gists to be private by default.) + + :Gist -P + +> This is only relevant if you've set gists to be private by default; +> if you get an empty gist list, try ":Gist --abandon". + +- Create a gist anonymously. + + :Gist -a + +- Create a gist with all open buffers. + + :Gist -m + +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the ":w" command within the gist buffer. + + :Gist -e + +- Edit the gist with name 'foo.js' (you need to have opened the gist buffer + first). + + :Gist -e foo.js + +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist -e -s something + +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -d + +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -f + +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist +1 + +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. + + :Gist -1 + +- Get gist XXXXX. + + :Gist XXXXX + +- Get gist XXXXX and add to clipboard. + + :Gist -c XXXXX + +- List your public gists. + + :Gist -l + +- List gists from user "mattn". + + :Gist -l mattn + +- List everyone's gists. + + :Gist -la + +- List gists from your starred gists. + + :Gist -ls + +- Open the gist on browser after you post or update it. + + :Gist -b + +## List Feature + +- Useful mappings on the gist-listing buffer: + - Both `o` or `Enter` open the gist file in a new buffer, and close the + gist-vim listing one. + - `b` opens the gist file in a browser; this is necessary because + `Shift-Enter` (as was originally) only works for GUI vim. + - `y` copies the contents of the selected gist to the clipboard, and + closes the gist-vim buffer. + - `p` pastes the contents of the selected gist to the buffer from where + gist-vim was called, and closes the gist-vim buffer. + - Hitting `Escape` or `Tab` at the gist-vim buffer closes it. + +- Gist listing has fixed-length columns now, more amenable to eye inspection. + Every line on the gist-listing buffer contains the gist id, name and + description, in that order. Columns are now padded and truncated to offer a + faster browsing, in the following way: + - The gist id string is fixed at 32 characters. + - The length (in characters) of the name of the gist is fixed and + can be set by the user using, for example: + + `let g:gistvim_namelength = 20` + + The default value for `gistvim_namelength` is 30. If the gist (file)name + exceeds that length, it is truncated to the specified length. + - Finally, the gist description is truncated in length to fit the remaining + of the line, avoiding wrapped lines that mess up the table layout. + - Note that the gist listing buffer now does not show the field 'code' + (not sure what that did in the first place). + +## Tips: + +If you set g:gist_clip_command, gist.vim will copy the gist code with option +'-c'. + +- Mac: + + let g:gist_clip_command = 'pbcopy' + +- Linux: + + let g:gist_clip_command = 'xclip -selection clipboard' + +- Others (cygwin?): + + let g:gist_clip_command = 'putclip' + +If you want to detect filetype from the filename: + + let g:gist_detect_filetype = 1 + +If you want to open browser after the post: + + let g:gist_open_browser_after_post = 1 + +If you want to change the browser: + + let g:gist_browser_command = 'w3m %URL%' + +or: + + let g:gist_browser_command = 'opera %URL% &' + +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": + + let g:gist_show_privates = 1 + +If you want your gist to be private by default: + + let g:gist_post_private = 1 + +If you want your gist to be anonymous by default: + + let g:gist_post_anonymous = 1 + +If you want to manipulate multiple files in a gist: + + let g:gist_get_multiplefile = 1 + +If you want to use on GitHub Enterprise: + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' + +You need to either set global git config: + + $ git config --global github.user Username + +## License: + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +## Install: + +Copy it to your plugin directory. +gist.vim will create a curl cookie-jar file in your runtimepath. + +- rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +### Install with [Vundle](https://github.com/gmarik/vundle) + +Add the following lines to your `.vimrc`. + + Bundle 'mattn/webapi-vim' + Bundle 'mattn/gist-vim' + +Now restart Vim and run `:BundleInstall`. + +### Install with [NeoBundle](https://github.com/Shougo/neobundle.vim) + +Add the following line to your `.vimrc`. + + NeoBundle 'mattn/gist-vim', {'depends': 'mattn/webapi-vim'} + +## Requirements: + +- curl command (http://curl.haxx.se/) +- webapi-vim (https://github.com/mattn/webapi-vim) +- and if you want to use your git profile, the git command-line client. + +## Setup: + +This plugin supports both basic and two-factor authentication using GitHub +API v3. The plugin stores its credentials in `~/.gist-vim`. + +First, you need to set your GitHub username in git's global configuration: + + $ git config --global github.user + +Then gist-vim will ask for your password in order to create an access +token. If you have two-factor authentication enabled, gist-vim will also +prompt you to enter the two-factor key you receive. + +NOTE: +If you want you can set it directly to `g:github_user` and `g:gist_token`. + +Whichever type of authentication you use, your GitHub password will not be +stored, only a OAuth access token produced specifically for gist-vim. The +token is stored in `~/.gist-vim`. If you stop using the plugin, you can +easily remove this file. To revoke the associated GitHub token, go to the +list of ["Authorized applications" on GitHub's "Account Settings" +page][uas]. + +[uas]: https://github.com/settings/applications + +**Note:** the username is optional if you only send anonymous gists. diff --git a/sources_non_forked/gist-vim/autoload/gist.vim b/sources_non_forked/gist-vim/autoload/gist.vim new file mode 100644 index 00000000..afe797e7 --- /dev/null +++ b/sources_non_forked/gist-vim/autoload/gist.vim @@ -0,0 +1,1165 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" Last Change: 10-Oct-2016. +" Version: 7.3 +" WebPage: http://github.com/mattn/gist-vim +" License: BSD + +let s:save_cpo = &cpoptions +set cpoptions&vim + +if exists('g:gist_disabled') && g:gist_disabled == 1 + function! gist#Gist(...) abort + endfunction + finish +endif + +if !exists('g:github_user') && !executable('git') + echohl ErrorMsg | echomsg 'Gist: require ''git'' command' | echohl None + finish +endif + +if !executable('curl') + echohl ErrorMsg | echomsg 'Gist: require ''curl'' command' | echohl None + finish +endif + +if globpath(&rtp, 'autoload/webapi/http.vim') ==# '' + echohl ErrorMsg | echomsg 'Gist: require ''webapi'', install https://github.com/mattn/webapi-vim' | echohl None + finish +else + call webapi#json#true() +endif + +let s:gist_token_file = expand(get(g:, 'gist_token_file', '~/.gist-vim')) +let s:system = function(get(g:, 'webapi#system_function', 'system')) + +if !exists('g:github_user') + let g:github_user = substitute(s:system('git config --get github.user'), "\n", '', '') + if strlen(g:github_user) == 0 + let g:github_user = $GITHUB_USER + end +endif + +if !exists('g:gist_api_url') + let g:gist_api_url = substitute(s:system('git config --get github.apiurl'), "\n", '', '') + if strlen(g:gist_api_url) == 0 + let g:gist_api_url = 'https://api.github.com/' + end + if exists('g:github_api_url') && !exists('g:gist_shutup_issue154') + if matchstr(g:gist_api_url, 'https\?://\zs[^/]\+\ze') != matchstr(g:github_api_url, 'https\?://\zs[^/]\+\ze') + echohl WarningMsg + echo '--- Warning ---' + echo 'It seems that you set different URIs for github_api_url/gist_api_url.' + echo 'If you want to remove this message: let g:gist_shutup_issue154 = 1' + echohl None + if confirm('Continue?', '&Yes\n&No') != 1 + let g:gist_disabled = 1 + finish + endif + redraw! + endif + endif +endif +if g:gist_api_url !~# '/$' + let g:gist_api_url .= '/' +endif + +if !exists('g:gist_update_on_write') + let g:gist_update_on_write = 1 +endif + +function! s:get_browser_command() abort + let gist_browser_command = get(g:, 'gist_browser_command', '') + if gist_browser_command ==# '' + if has('win32') || has('win64') + let gist_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%' + elseif has('mac') || has('macunix') || has('gui_macvim') || system('uname') =~? '^darwin' + let gist_browser_command = 'open %URL%' + elseif executable('xdg-open') + let gist_browser_command = 'xdg-open %URL%' + elseif executable('firefox') + let gist_browser_command = 'firefox %URL% &' + else + let gist_browser_command = '' + endif + endif + return gist_browser_command +endfunction + +function! s:open_browser(url) abort + let cmd = s:get_browser_command() + if len(cmd) == 0 + redraw + echohl WarningMsg + echo 'It seems that you don''t have general web browser. Open URL below.' + echohl None + echo a:url + return + endif + let quote = &shellxquote == '"' ? "'" : '"' + if cmd =~# '^!' + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + silent! exec cmd + elseif cmd =~# '^:[A-Z]' + let cmd = substitute(cmd, '%URL%', '\=a:url', 'g') + exec cmd + else + let cmd = substitute(cmd, '%URL%', '\=quote.a:url.quote', 'g') + call system(cmd) + endif +endfunction + +function! s:shellwords(str) abort + let words = split(a:str, '\%(\([^ \t\''"]\+\)\|''\([^\'']*\)''\|"\(\%([^\"\\]\|\\.\)*\)"\)\zs\s*\ze') + let words = map(words, 'substitute(v:val, ''\\\([\\ ]\)'', ''\1'', "g")') + let words = map(words, 'matchstr(v:val, ''^\%\("\zs\(.*\)\ze"\|''''\zs\(.*\)\ze''''\|.*\)$'')') + return words +endfunction + +function! s:truncate(str, num) + let mx_first = '^\(.\)\(.*\)$' + let str = a:str + let ret = '' + let width = 0 + while 1 + let char = substitute(str, mx_first, '\1', '') + let cells = strdisplaywidth(char) + if cells == 0 || width + cells > a:num + break + endif + let width = width + cells + let ret .= char + let str = substitute(str, mx_first, '\2', '') + endwhile + while width + 1 <= a:num + let ret .= " " + let width = width + 1 + endwhile + return ret +endfunction + +function! s:format_gist(gist) abort + let files = sort(keys(a:gist.files)) + if empty(files) + return '' + endif + let file = a:gist.files[files[0]] + let name = file.filename + if has_key(file, 'content') + let code = file.content + let code = "\n".join(map(split(code, "\n"), '" ".v:val'), "\n") + else + let code = '' + endif + let desc = type(a:gist.description)==0 || a:gist.description ==# '' ? '' : a:gist.description + let name = substitute(name, '[\r\n\t]', ' ', 'g') + let name = substitute(name, ' ', ' ', 'g') + let desc = substitute(desc, '[\r\n\t]', ' ', 'g') + let desc = substitute(desc, ' ', ' ', 'g') + " Display a nice formatted (and truncated if needed) table of gists on screen + " Calculate field lengths for gist-listing formatting on screen + redir =>a |exe "sil sign place buffer=".bufnr('')|redir end + let signlist = split(a, '\n') + let width = winwidth(0) - ((&number||&relativenumber) ? &numberwidth : 0) - &foldcolumn - (len(signlist) > 2 ? 2 : 0) + let idlen = 33 + let namelen = get(g:, 'gist_namelength', 30) + let desclen = width - (idlen + namelen + 10) + return printf('gist: %s %s %s', s:truncate(a:gist.id, idlen), s:truncate(name, namelen), s:truncate(desc, desclen)) +endfunction + +" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it. +let s:bufprefix = 'gist' . (has('unix') ? ':' : '_') +function! s:GistList(gistls, page) abort + if a:gistls ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:gistls ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:gistls.'/gists' + endif + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistls)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd vsplit +set\ winfixwidth ' s:bufprefix.a:gistls + elseif get(g:, 'gist_list_rightbelow', 0) + exec 'silent noautocmd rightbelow 5 split +set\ winfixheight ' s:bufprefix.a:gistls + else + exec 'silent noautocmd split' s:bufprefix.a:gistls + endif + endif + if a:page > 1 + let oldlines = getline(0, line('$')) + let url = url . '?page=' . a:page + endif + + setlocal modifiable + let old_undolevels = &undolevels + let oldlines = [] + silent %d _ + + redraw | echon 'Listing gists... ' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + bw! + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + if v:shell_error != 0 + bw! + redraw + echohl ErrorMsg | echomsg 'Gists not found' | echohl None + return + endif + let content = webapi#json#decode(res.content) + if type(content) == 4 && has_key(content, 'message') && len(content.message) + bw! + redraw + echohl ErrorMsg | echomsg content.message | echohl None + if content.message ==# 'Bad credentials' + call delete(s:gist_token_file) + endif + return + endif + + let lines = map(filter(content, '!empty(v:val.files)'), 's:format_gist(v:val)') + call setline(1, split(join(lines, "\n"), "\n")) + + $put='more...' + + let b:gistls = a:gistls + let b:page = a:page + setlocal buftype=nofile bufhidden=hide noswapfile + setlocal cursorline + setlocal nomodified + setlocal nomodifiable + syntax match SpecialKey /^gist:/he=e-1 + syntax match Title /^gist: \S\+/hs=s+5 contains=ALL + nnoremap :call GistListAction(0) + nnoremap o :call GistListAction(0) + nnoremap b :call GistListAction(1) + nnoremap y :call GistListAction(2) + nnoremap p :call GistListAction(3) + nnoremap :bw + nnoremap :call GistListAction(1) + + cal cursor(1+len(oldlines),1) + nohlsearch + redraw | echo '' +endfunction + +function! gist#list_recursively(user, ...) abort + let use_cache = get(a:000, 0, 1) + let limit = get(a:000, 1, -1) + let verbose = get(a:000, 2, 1) + if a:user ==# 'mine' + let url = g:gist_api_url . 'gists' + elseif a:user ==# 'starred' + let url = g:gist_api_url . 'gists/starred' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + " anonymous user cannot get gists to prevent infinite recursive loading + return [] + endif + + if use_cache && exists('g:gist_list_recursively_cache') + if has_key(g:gist_list_recursively_cache, a:user) + return webapi#json#decode(g:gist_list_recursively_cache[a:user]) + endif + endif + + let page = 1 + let gists = [] + let lastpage = -1 + + function! s:get_lastpage(res) abort + let links = split(a:res.header[match(a:res.header, 'Link')], ',') + let link = links[match(links, 'rel=[''"]last[''"]')] + let page = str2nr(matchlist(link, '\%(page=\)\(\d\+\)')[1]) + return page + endfunction + + if verbose > 0 + redraw | echon 'Loading gists...' + endif + + while limit == -1 || page <= limit + let res = webapi#http#get(url.'?page='.page, '', {'Authorization': auth}) + if limit == -1 + " update limit to the last page + let limit = s:get_lastpage(res) + endif + if verbose > 0 + redraw | echon 'Loading gists... ' . page . '/' . limit . ' pages has loaded.' + endif + let gists = gists + webapi#json#decode(res.content) + let page = page + 1 + endwhile + let g:gist_list_recursively_cache = get(g:, 'gist_list_recursively_cache', {}) + let g:gist_list_recursively_cache[a:user] = webapi#json#encode(gists) + return gists +endfunction + +function! gist#list(user, ...) abort + let page = get(a:000, 0, 0) + if a:user ==# '-all' + let url = g:gist_api_url.'gists/public' + elseif get(g:, 'gist_show_privates', 0) && a:user ==# 'starred' + let url = g:gist_api_url.'gists/starred' + elseif get(g:, 'gist_show_privates') && a:user ==# 'mine' + let url = g:gist_api_url.'gists' + else + let url = g:gist_api_url.'users/'.a:user.'/gists' + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return [] + endif + let res = webapi#http#get(url, '', { "Authorization": auth }) + return webapi#json#decode(res.content) +endfunction + +function! s:GistGetFileName(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + if has_key(gist, 'files') + return sort(keys(gist.files))[0] + endif + return '' +endfunction + +function! s:GistDetectFiletype(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + return '' + endif + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + let gist = webapi#json#decode(res.content) + let filename = sort(keys(gist.files))[0] + let ext = fnamemodify(filename, ':e') + if has_key(s:extmap, ext) + let type = s:extmap[ext] + else + let type = get(gist.files[filename], 'type', 'text') + endif + silent! exec 'setlocal ft='.tolower(type) +endfunction + +function! s:GistWrite(fname) abort + if substitute(a:fname, '\\', '/', 'g') == expand("%:p:gs@\\@/@") + if g:gist_update_on_write != 2 || v:cmdbang + Gist -e + else + echohl ErrorMsg | echomsg 'Please type ":w!" to update a gist.' | echohl None + endif + else + exe 'w'.(v:cmdbang ? '!' : '') fnameescape(v:cmdarg) fnameescape(a:fname) + silent! exe 'file' fnameescape(a:fname) + silent! au! BufWriteCmd + endif +endfunction + +function! s:GistGet(gistid, clipboard) abort + redraw | echon 'Getting gist... ' + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": s:GistGetAuthHeader() }) + if res.status =~# '^2' + try + let gist = webapi#json#decode(res.content) + catch + redraw + echohl ErrorMsg | echomsg 'Gist seems to be broken' | echohl None + return + endtry + if get(g:, 'gist_get_multiplefile', 0) != 0 + let num_file = len(keys(gist.files)) + else + let num_file = 1 + endif + redraw + if num_file > len(keys(gist.files)) + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif + augroup GistWrite + au! + augroup END + for n in range(num_file) + try + let old_undolevels = &undolevels + let filename = sort(keys(gist.files))[n] + + let winnum = bufwinnr(bufnr(s:bufprefix.a:gistid.'/'.filename)) + if winnum != -1 + if winnum != bufwinnr('%') + exe winnum 'wincmd w' + endif + setlocal modifiable + else + if num_file == 1 + if get(g:, 'gist_edit_with_buffers', 0) + let found = -1 + for wnr in range(1, winnr('$')) + let bnr = winbufnr(wnr) + if bnr != -1 && !empty(getbufvar(bnr, 'gist')) + let found = wnr + break + endif + endfor + if found != -1 + exe found 'wincmd w' + setlocal modifiable + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + silent only! + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + else + if get(g:, 'gist_list_vsplit', 0) + exec 'silent noautocmd rightbelow vnew' + else + exec 'silent noautocmd rightbelow new' + endif + endif + setlocal noswapfile + silent exec 'noautocmd file' s:bufprefix.a:gistid.'/'.fnameescape(filename) + endif + set undolevels=-1 + filetype detect + silent %d _ + + let content = gist.files[filename].content + call setline(1, split(content, "\n")) + let b:gist = { + \ "filename": filename, + \ "id": gist.id, + \ "description": gist.description, + \ "private": gist.public =~ 'true', + \} + catch + let &undolevels = old_undolevels + bw! + redraw + echohl ErrorMsg | echomsg 'Gist contains binary' | echohl None + return + endtry + let &undolevels = old_undolevels + setlocal buftype=acwrite bufhidden=hide noswapfile + setlocal nomodified + doau StdinReadPost,BufRead,BufReadPost + let gist_detect_filetype = get(g:, 'gist_detect_filetype', 0) + if (&ft ==# '' && gist_detect_filetype == 1) || gist_detect_filetype == 2 + call s:GistDetectFiletype(a:gistid) + endif + if a:clipboard + if exists('g:gist_clip_command') + exec 'silent w !'.g:gist_clip_command + elseif has('clipboard') + silent! %yank + + else + %yank + endif + endif + 1 + augroup GistWrite + au! BufWriteCmd call s:GistWrite(expand("")) + augroup END + endfor + else + bw! + redraw + echohl ErrorMsg | echomsg 'Gist not found' | echohl None + return + endif +endfunction + +function! s:GistListAction(mode) abort + let line = getline('.') + let mx = '^gist:\s*\zs\(\w\+\)\ze.*' + if line =~# mx + let gistid = matchstr(line, mx) + if a:mode == 1 + call s:open_browser('https://gist.github.com/' . gistid) + elseif a:mode == 0 + call s:GistGet(gistid, 0) + wincmd w + bw + elseif a:mode == 2 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + elseif a:mode == 3 + call s:GistGet(gistid, 1) + " TODO close with buffe rname + bdelete + bdelete + normal! "+p + endif + return + endif + if line =~# '^more\.\.\.$' + call s:GistList(b:gistls, b:page+1) + return + endif +endfunction + +function! s:GistUpdate(content, gistid, gistnm, desc) abort + let gist = { "id": a:gistid, "files" : {}, "description": "","public": function('webapi#json#true') } + if exists('b:gist') + if has_key(b:gist, 'filename') && len(a:gistnm) > 0 + let gist.files[b:gist.filename] = { "content": '', "filename": b:gist.filename } + let b:gist.filename = a:gistnm + endif + if has_key(b:gist, 'private') && b:gist.private | let gist['public'] = function('webapi#json#false') | endif + if has_key(b:gist, 'description') | let gist['description'] = b:gist.description | endif + if has_key(b:gist, 'filename') | let filename = b:gist.filename | endif + else + let filename = a:gistnm + if len(filename) == 0 | let filename = s:GistGetFileName(a:gistid) | endif + if len(filename) == 0 | let filename = s:get_current_filename(1) | endif + endif + + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + " Update description + " If no new description specified, keep the old description + if a:desc !=# ' ' + let gist['description'] = a:desc + else + let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth }) + if res.status =~# '^2' + let old_gist = webapi#json#decode(res.content) + let gist['description'] = old_gist.description + endif + endif + + let gist.files[filename] = { "content": a:content, "filename": filename } + + redraw | echon 'Updating gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/' . a:gistid, + \ webapi#json#encode(gist), { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = {"id": a:gistid, "filename": filename} + setlocal nomodified + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! s:GistDelete(gistid) abort + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + + redraw | echon 'Deleting gist... ' + let res = webapi#http#post(g:gist_api_url.'gists/'.a:gistid, '', { + \ "Authorization": auth, + \ "Content-Type": "application/json", + \}, 'DELETE') + if res.status =~# '^2' + if exists('b:gist') + unlet b:gist + endif + redraw | echomsg 'Done: ' + else + echohl ErrorMsg | echomsg 'Delete failed: ' . res.message | echohl None + endif +endfunction + +function! s:get_current_filename(no) abort + let filename = expand('%:t') + if len(filename) == 0 && &ft !=# '' + let pair = filter(items(s:extmap), 'v:val[1] == &ft') + if len(pair) > 0 + let filename = printf('gistfile%d%s', a:no, pair[0][0]) + endif + endif + if filename ==# '' + let filename = printf('gistfile%d.txt', a:no) + endif + return filename +endfunction + +function! s:update_GistID(id) abort + let view = winsaveview() + normal! gg + let ret = 0 + if search('\:\s*$') + let line = getline('.') + let line = substitute(line, '\s\+$', '', 'g') + call setline('.', line . ' ' . a:id) + let ret = 1 + endif + call winrestview(view) + return ret +endfunction + +" GistPost function: +" Post new gist to github +" +" if there is an embedded gist url or gist id in your file, +" it will just update it. +" -- by c9s +" +" embedded gist id format: +" +" GistID: 123123 +" +function! s:GistPost(content, private, desc, anonymous) abort + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + let filename = s:get_current_filename(1) + let gist.files[filename] = { "content": a:content, "filename": filename } + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ "filename": filename, + \ "id": matchstr(loc, '[^/]\+$'), + \ "description": gist['description'], + \ "private": a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: '. res.message | echohl None + endif + return loc +endfunction + +function! s:GistPostBuffers(private, desc, anonymous) abort + let bufnrs = range(1, bufnr('$')) + let bn = bufnr('%') + let query = [] + + let gist = { "files" : {}, "description": "","public": function('webapi#json#true') } + if a:desc !=# ' ' | let gist['description'] = a:desc | endif + if a:private | let gist['public'] = function('webapi#json#false') | endif + + let index = 1 + for bufnr in bufnrs + if !bufexists(bufnr) || buflisted(bufnr) == 0 + continue + endif + echo 'Creating gist content'.index.'... ' + silent! exec 'buffer!' bufnr + let content = join(getline(1, line('$')), "\n") + let filename = s:get_current_filename(index) + let gist.files[filename] = { "content": content, "filename": filename } + let index = index + 1 + endfor + silent! exec 'buffer!' bn + + let header = {"Content-Type": "application/json"} + if !a:anonymous + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + redraw + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + endif + let header['Authorization'] = auth + endif + + redraw | echon 'Posting it to gist... ' + let res = webapi#http#post(g:gist_api_url.'gists', webapi#json#encode(gist), header) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let loc = obj['html_url'] + let b:gist = { + \ "filename": filename, + \ "id": matchstr(loc, '[^/]\+$'), + \ "description": gist['description'], + \ "private": a:private, + \} + if s:update_GistID(b:gist['id']) + Gist -e + endif + redraw | echomsg 'Done: '.loc + else + let loc = '' + echohl ErrorMsg | echomsg 'Post failed: ' . res.message | echohl None + endif + return loc +endfunction + +function! gist#Gist(count, bang, line1, line2, ...) abort + redraw + let bufname = bufname('%') + " find GistID: in content , then we should just update + let gistid = '' + let gistls = '' + let gistnm = '' + let gistdesc = ' ' + let private = get(g:, 'gist_post_private', 0) + let multibuffer = 0 + let clipboard = 0 + let deletepost = 0 + let editpost = 0 + let anonymous = get(g:, 'gist_post_anonymous', 0) + let openbrowser = 0 + let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$' + let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$' + if strlen(g:github_user) == 0 && anonymous == 0 + echohl ErrorMsg | echomsg 'You have not configured a Github account. Read '':help gist-vim-setup''.' | echohl None + return + endif + if a:bang == '!' + let gistidbuf = '' + elseif bufname =~# bufnamemx + let gistidbuf = matchstr(bufname, bufnamemx) + elseif exists('b:gist') && has_key(b:gist, 'id') + let gistidbuf = b:gist['id'] + else + let gistidbuf = matchstr(join(getline(a:line1, a:line2), "\n"), 'GistID:\s*\zs\w\+') + endif + + let args = (a:0 > 0) ? s:shellwords(a:1) : [] + for arg in args + if arg =~# '^\(-h\|--help\)$\C' + help :Gist + return + elseif arg =~# '^\(-g\|--git\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + echo printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-G\|--gitclone\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id') + exe '!' printf('git clone git@github.com:%s', b:gist['id']) + return + elseif arg =~# '^\(-la\|--listall\)$\C' + let gistls = '-all' + elseif arg =~# '^\(-ls\|--liststar\)$\C' + let gistls = 'starred' + elseif arg =~# '^\(-l\|--list\)$\C' + if get(g:, 'gist_show_privates') + let gistls = 'mine' + else + let gistls = g:github_user + endif + elseif arg =~# '^\(-m\|--multibuffer\)$\C' + let multibuffer = 1 + elseif arg =~# '^\(-p\|--private\)$\C' + let private = 1 + elseif arg =~# '^\(-P\|--public\)$\C' + let private = 0 + elseif arg =~# '^\(-a\|--anonymous\)$\C' + let anonymous = 1 + elseif arg =~# '^\(-s\|--description\)$\C' + let gistdesc = '' + elseif arg =~# '^\(-c\|--clipboard\)$\C' + let clipboard = 1 + elseif arg =~# '^--rawurl$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' + let gistid = gistidbuf + echo 'https://gist.github.com/raw/'.gistid + return + elseif arg =~# '^\(-d\|--delete\)$\C' && gistidbuf !=# '' + let gistid = gistidbuf + let deletepost = 1 + elseif arg =~# '^\(-e\|--edit\)$\C' + if gistidbuf !=# '' + let gistid = gistidbuf + endif + let editpost = 1 + elseif arg =~# '^\(+1\|--star\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'PUT') + if res.status =~# '^2' + echomsg 'Starred' gistid + else + echohl ErrorMsg | echomsg 'Star failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-1\|--unstar\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'DELETE') + if res.status =~# '^2' + echomsg 'Unstarred' gistid + else + echohl ErrorMsg | echomsg 'Unstar failed' | echohl None + endif + endif + return + elseif arg =~# '^\(-f\|--fork\)$\C' && gistidbuf !=# '' + let auth = s:GistGetAuthHeader() + if len(auth) == 0 + echohl ErrorMsg | echomsg v:errmsg | echohl None + return + else + let gistid = gistidbuf + let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/fork', '', { "Authorization": auth }) + if res.status =~# '^2' + let obj = webapi#json#decode(res.content) + let gistid = obj['id'] + else + echohl ErrorMsg | echomsg 'Fork failed' | echohl None + return + endif + endif + elseif arg =~# '^\(-b\|--browser\)$\C' + let openbrowser = 1 + elseif arg !~# '^-' && len(gistnm) == 0 + if gistdesc !=# ' ' + let gistdesc = matchstr(arg, '^\s*\zs.*\ze\s*$') + elseif editpost == 1 || deletepost == 1 + let gistnm = arg + elseif len(gistls) > 0 && arg !=# '^\w\+$\C' + let gistls = arg + elseif arg =~# '^[0-9a-z]\+$\C' + let gistid = arg + else + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + elseif len(arg) > 0 + echohl ErrorMsg | echomsg 'Invalid arguments: '.arg | echohl None + unlet args + return 0 + endif + endfor + unlet args + "echom "gistid=".gistid + "echom "gistls=".gistls + "echom "gistnm=".gistnm + "echom "gistdesc=".gistdesc + "echom "private=".private + "echom "clipboard=".clipboard + "echom "editpost=".editpost + "echom "deletepost=".deletepost + + if gistidbuf !=# '' && gistid ==# '' && editpost == 0 && deletepost == 0 && anonymous == 0 + let editpost = 1 + let gistid = gistidbuf + endif + + if len(gistls) > 0 + call s:GistList(gistls, 1) + elseif len(gistid) > 0 && editpost == 0 && deletepost == 0 + call s:GistGet(gistid, clipboard) + else + let url = '' + if multibuffer == 1 + let url = s:GistPostBuffers(private, gistdesc, anonymous) + else + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + if editpost == 1 + let url = s:GistUpdate(content, gistid, gistnm, gistdesc) + elseif deletepost == 1 + call s:GistDelete(gistid) + else + let url = s:GistPost(content, private, gistdesc, anonymous) + endif + if a:count >= 1 && get(g:, 'gist_keep_selection', 0) == 1 + silent! normal! gv + endif + endif + if type(url) == 1 && len(url) > 0 + if get(g:, 'gist_open_browser_after_post', 0) == 1 || openbrowser + call s:open_browser(url) + endif + let gist_put_url_to_clipboard_after_post = get(g:, 'gist_put_url_to_clipboard_after_post', 1) + if gist_put_url_to_clipboard_after_post > 0 || clipboard + if gist_put_url_to_clipboard_after_post == 2 + let url = url . "\n" + endif + if exists('g:gist_clip_command') + call system(g:gist_clip_command, url) + elseif has('clipboard') + let @+ = url + else + let @" = url + endif + endif + endif + endif + return 1 +endfunction + +function! s:GistGetAuthHeader() abort + if get(g:, 'gist_use_password_in_gitconfig', 0) != 0 + let password = substitute(system('git config --get github.password'), "\n", '', '') + if password =~# '^!' | let password = system(password[1:]) | endif + return printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + endif + let auth = '' + if !empty(get(g:, 'gist_token', $GITHUB_TOKEN)) + let auth = 'token ' . get(g:, 'gist_token', $GITHUB_TOKEN) + elseif filereadable(s:gist_token_file) + let str = join(readfile(s:gist_token_file), '') + if type(str) == 1 + let auth = str + endif + endif + if len(auth) > 0 + return auth + endif + + redraw + echohl WarningMsg + echo 'Gist.vim requires authorization to use the GitHub API. These settings are stored in "~/.gist-vim". If you want to revoke, do "rm ~/.gist-vim".' + echohl None + let password = inputsecret('GitHub Password for '.g:github_user.':') + if len(password) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let note = 'Gist.vim on '.hostname().' '.strftime('%Y/%m/%d-%H:%M:%S') + let note_url = 'http://www.vim.org/scripts/script.php?script_id=2423' + let insecureSecret = printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password)) + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ "scopes" : ["gist"], + \ "note" : note, + \ "note_url" : note_url, + \}), { + \ "Content-Type" : "application/json", + \ "Authorization" : insecureSecret, + \}) + let h = filter(res.header, 'stridx(v:val, "X-GitHub-OTP:") == 0') + if len(h) + let otp = inputsecret('OTP:') + if len(otp) == 0 + let v:errmsg = 'Canceled' + return '' + endif + let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({ + \ "scopes" : ["gist"], + \ "note" : note, + \ "note_url" : note_url, + \}), { + \ "Content-Type" : "application/json", + \ "Authorization" : insecureSecret, + \ "X-GitHub-OTP" : otp, + \}) + endif + let authorization = webapi#json#decode(res.content) + if has_key(authorization, 'token') + let secret = printf('token %s', authorization.token) + call writefile([secret], s:gist_token_file) + if !(has('win32') || has('win64')) + call system('chmod go= '.s:gist_token_file) + endif + elseif has_key(authorization, 'message') + let secret = '' + let v:errmsg = authorization.message + endif + return secret +endfunction + +let s:extmap = extend({ +\".adb": "ada", +\".ahk": "ahk", +\".arc": "arc", +\".as": "actionscript", +\".asm": "asm", +\".asp": "asp", +\".aw": "php", +\".b": "b", +\".bat": "bat", +\".befunge": "befunge", +\".bmx": "bmx", +\".boo": "boo", +\".c-objdump": "c-objdump", +\".c": "c", +\".cfg": "cfg", +\".cfm": "cfm", +\".ck": "ck", +\".cl": "cl", +\".clj": "clj", +\".cmake": "cmake", +\".coffee": "coffee", +\".cpp": "cpp", +\".cppobjdump": "cppobjdump", +\".cs": "csharp", +\".css": "css", +\".cw": "cw", +\".d-objdump": "d-objdump", +\".d": "d", +\".darcspatch": "darcspatch", +\".diff": "diff", +\".duby": "duby", +\".dylan": "dylan", +\".e": "e", +\".ebuild": "ebuild", +\".eclass": "eclass", +\".el": "lisp", +\".erb": "erb", +\".erl": "erlang", +\".f90": "f90", +\".factor": "factor", +\".feature": "feature", +\".fs": "fs", +\".fy": "fy", +\".go": "go", +\".groovy": "groovy", +\".gs": "gs", +\".gsp": "gsp", +\".haml": "haml", +\".hs": "haskell", +\".html": "html", +\".hx": "hx", +\".ik": "ik", +\".ino": "ino", +\".io": "io", +\".j": "j", +\".java": "java", +\".js": "javascript", +\".json": "json", +\".jsp": "jsp", +\".kid": "kid", +\".lhs": "lhs", +\".lisp": "lisp", +\".ll": "ll", +\".lua": "lua", +\".ly": "ly", +\".m": "objc", +\".mak": "mak", +\".man": "man", +\".mao": "mao", +\".matlab": "matlab", +\".md": "markdown", +\".minid": "minid", +\".ml": "ml", +\".moo": "moo", +\".mu": "mu", +\".mustache": "mustache", +\".mxt": "mxt", +\".myt": "myt", +\".n": "n", +\".nim": "nim", +\".nu": "nu", +\".numpy": "numpy", +\".objdump": "objdump", +\".ooc": "ooc", +\".parrot": "parrot", +\".pas": "pas", +\".pasm": "pasm", +\".pd": "pd", +\".phtml": "phtml", +\".pir": "pir", +\".pl": "perl", +\".po": "po", +\".py": "python", +\".pytb": "pytb", +\".pyx": "pyx", +\".r": "r", +\".raw": "raw", +\".rb": "ruby", +\".rhtml": "rhtml", +\".rkt": "rkt", +\".rs": "rs", +\".rst": "rst", +\".s": "s", +\".sass": "sass", +\".sc": "sc", +\".scala": "scala", +\".scm": "scheme", +\".scpt": "scpt", +\".scss": "scss", +\".self": "self", +\".sh": "sh", +\".sml": "sml", +\".sql": "sql", +\".st": "smalltalk", +\".swift": "swift", +\".tcl": "tcl", +\".tcsh": "tcsh", +\".tex": "tex", +\".textile": "textile", +\".tpl": "smarty", +\".twig": "twig", +\".txt" : "text", +\".v": "verilog", +\".vala": "vala", +\".vb": "vbnet", +\".vhd": "vhdl", +\".vim": "vim", +\".weechatlog": "weechatlog", +\".xml": "xml", +\".xq": "xquery", +\".xs": "xs", +\".yml": "yaml", +\}, get(g:, 'gist_extmap', {})) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim:set et: diff --git a/sources_non_forked/gist-vim/doc/gist-vim.txt b/sources_non_forked/gist-vim/doc/gist-vim.txt new file mode 100644 index 00000000..c7005a7f --- /dev/null +++ b/sources_non_forked/gist-vim/doc/gist-vim.txt @@ -0,0 +1,358 @@ +*Gist.vim* Vimscript for creating gists (http://gist.github.com) + +Usage |gist-vim-usage| +Tips |gist-vim-tips| +License |gist-vim-license| +Install |gist-vim-install| +Requirements |gist-vim-requirements| +Setup |gist-vim-setup| +FAQ |gist-vim-faq| + +This is a vimscript for creating gists (http://gist.github.com) + +For the latest version please see https://github.com/mattn/gist-vim. + +============================================================================== +USAGE *:Gist* *gist-vim-usage* + +- Post current buffer to gist, using default privacy option. > + + :Gist +< +- Post selected text to gist, using default privacy option. + This applies to all permutations listed below (except multi). > + + :'<,'>Gist +< +- Create a private gist. > + + :Gist -p + :Gist --private +< +- Create a public gist. + (Only relevant if you've set gists to be private by default.) > + + :Gist -P + :Gist --public +< +- Post whole text to gist as public. + This is only relevant if you've set gists to be private by default. +> + :Gist -P +< +- Create a gist anonymously. > + + :Gist -a + :Gist --anonymous +< +- Create a gist with all open buffers. > + + :Gist -m + :Gist --multibuffer +< +- Edit the gist (you need to have opened the gist buffer first). + You can update the gist with the {:w} command within the gist buffer. > + + :Gist -e + :Gist --edit +< +- Edit the gist with name "foo.js" (you need to have opened the gist buffer + first). > + + :Gist -e foo.js +< +- Post/Edit with the description " (you need to have opened the gist buffer + first). > + + :Gist -s something + :Gist --description something + :Gist -e -s something +< +- Delete the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -d + :Gist --delete +< +- Fork the gist (you need to have opened the gist buffer first). + Password authentication is needed. > + + :Gist -f + :Gist --fork +< +- Star the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist +1 +< +- Unstar the gist (you need to have opened the gist buffer first). + Password authentication is needed. +> + :Gist -1 +< +- Get gist XXXXX. > + + :Gist XXXXX +< +- Get gist XXXXX and add to clipboard. > + + :Gist -c XXXXX +< +- List your public gists. > + + :Gist -l + :Gist --list +< +- List gists from user "mattn". > + + :Gist -l mattn +< +- List everyone's gists. > + + :Gist -la + :Gist --listall +< +- List gists from your starred gists. +> + :Gist -ls + :Gist --liststar + +- While the gist list is visible, the following mappings apply: + + - 'o' or 'Enter' will open the selected gist file in a new buffer + and close the gist-vim listing split. + - 'b' will open the selected gist file in a browser. If you are in + GUI vim you can also achieve this by pressing 'Shift-Enter'. + - 'y' will copy the contents of the selected gist to the clipboard, + and close the gist-vim listing split. + - 'p' will (copy and) paste the contents of the selected gist to the + buffer from which gist-vim was called, and close the gist-vim + listing split. + - 'Esc' will close the gist-vim listing split without performing any + further action. + +- Open the gist on browser after you post or update it. +> + :Gist -b + :Gist --browser +< +- Post as new gist after editing on the buffer. +> + :Gist! +< +============================================================================== +TIPS *gist-vim-tips* + +If you set "g:gist_clip_command", gist.vim will copy the gist code with option +"-c". + + - Mac: > + let g:gist_clip_command = 'pbcopy' +< + - Linux: > + let g:gist_clip_command = 'xclip -selection clipboard' +< + - Others (cygwin?): > + let g:gist_clip_command = 'putclip' +< +If you want to detect filetype from the filename: > + + let g:gist_detect_filetype = 1 +< +If you want to open the browser after the post: > + + let g:gist_open_browser_after_post = 1 +< +If you want to change the browser: > + + let g:gist_browser_command = 'w3m %URL%' +< +or: > + + let g:gist_browser_command = 'opera %URL% &' +< +On windows, this should work with your user settings. + +If you want to show your private gists with ":Gist -l": > + + let g:gist_show_privates = 1 +< +If you want your gist to be private by default: > + + let g:gist_post_private = 1 +< +If you want your gist to be anonymous by default: > + + let g:gist_post_anonymous = 1 +< +If you want to edit all files for gists containing more than one: > + + let g:gist_get_multiplefile = 1 +< +If you want to use on GitHub Enterprise: > + + let g:gist_api_url = 'http://your-github-enterprise-domain/api/v3' +< +If you want to open gist with current editing buffers: > + + let g:gist_edit_with_buffers = 1 + +If you want to open gist list/buffer as vertical split: > + + let g:gist_list_vsplit = 1 + +If you want to modify filetype for the file on github, or add mapping of +filetype/file-extension: > + + let g:gist_extmap = { ".swift": "swift" } +< + key is file-extension, value is filetype. + +If you want to update a gist, embed > + + GistID: xxxxx +> +in your local file, then call > + + :Gist + +The gist-vim listing split lists gists ids, names (filenames) as well as +their description. This is done following a table layout, with fixed space +for each column. For offering quick browsing, gist-vim will truncate all +output exceeding the available horizontal space, assuring that every gist +listed only takes one line on the table. Although the gist id field width is +fixed internally, the user can define the length of the (file)name field on +the gist-vim listing. This can be done by the following declaration: + + let g:gist_namelength = 20 + +Note that the default value for gist_namelength is 30. Again, if the gist +(file)name exceeds the specified number of characters, it will be truncated. + +If you want to update a gist when only |:w!|: > + + " :w and :w! update a gist. + let g:gist_update_on_write = 1 + + " Only :w! updates a gist. + let g:gist_update_on_write = 2 +> +All other values are treated as 1. +This variable's value is 1 by default. + +============================================================================== +LICENSE *gist-vim-license* + + + Copyright 2010 by Yasuhiro Matsumoto + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +============================================================================== +INSTALL *gist-vim-install* + +Copy following files into your plugin directory. + +rtp: + - autoload/gist.vim + - plugin/gist.vim + +If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`. + +You need to install webapi-vim also: + + http://www.vim.org/scripts/script.php?script_id=4019 + +If you want to use latest one: + + https://github.com/mattn/webapi-vim + +============================================================================== +REQUIREMENTS *gist-vim-requirements* + + - curl command (http://curl.haxx.se/) + - webapi-vim (https://github.com/mattn/webapi-vim) + - and, if you want to use your git profile, the git command-line client. + +============================================================================== +SETUP *gist-vim-setup* + +This plugin uses GitHub API v3. The authentication value is stored in `~/.gist-vim`. +gist-vim provides two ways to authenticate against the GitHub APIs. + +First, you need to set your GitHub username in global git config: +> + $ git config --global github.user Username +< +Then, gist.vim will ask for your password to create an authorization when you +first use it. The password is not stored and only the OAuth access token will +be kept for later use. You can revoke the token at any time from the list of +"Authorized applications" on GitHub's "Account Settings" page. +(https://github.com/settings/applications) + +If you have two-factor authentication enabled on GitHub, you'll see the message +"Must specify two-factor authentication OTP code." In this case, you need to +create a "Personal Access Token" on GitHub's "Account Settings" page +(https://github.com/settings/applications) and place it in a file +named ~/.gist-vim like this: +> + token xxxxx +< +If you happen to have your password already written in ~/.gitconfig like +below: +> + [github] + password = xxxxx +< +Then, add following into your ~/.vimrc +> + let g:gist_use_password_in_gitconfig = 1 +< +This is not secure at all, so strongly discouraged. + +NOTE: the username is optional if you only send anonymous gists. + +============================================================================== +FAQ *gist-vim-faq* + +Q. :Gist returns a Forbidden error +A. Try deleting ~/.gist-vim and authenticating again. + +============================================================================== +THANKS *gist-vim-thanks* + + AD7six + Bruno Bigras + c9s + Daniel Bretoi + Jeremy Michael Cantrell + Kien N + kongo2002 + MATSUU Takuto + Matthew Weier O'Phinney + ornicar + Roland Schilter + steve + tyru + Will Gray + netj + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/gist-vim/gist.vim.vimup b/sources_non_forked/gist-vim/gist.vim.vimup new file mode 100644 index 00000000..fa853205 --- /dev/null +++ b/sources_non_forked/gist-vim/gist.vim.vimup @@ -0,0 +1,303 @@ +script_name: Gist.vim +script_id: '2423' +script_type: utility +script_package: gist-vim.zip +script_version: '7.3' +required_vim_version: '7.0' +summary: vimscript for gist + +detailed_description: | + This is vimscript for gist (http://gist.github.com) + + Usage: + + :Gist + post whole text to gist. + + :'<,'>Gist + post selected text to gist. + + :Gist -p + post whole text to gist with private. + if you got empty gist list, try :Gist --abandon + + :Gist -a + post whole text to gist with anonymous. + + :Gist -m + post multi buffer to gist. + + :Gist -e + edit the gist. (should be work on gist buffer) + you can update the gist with :w command on gist buffer. + + :Gist -e foo.js + edit the gist with name 'foo.js'. (should be work on gist buffer) + + :Gist -d + delete the gist. (should be work on gist buffer) + authentication required. + + :Gist -f + fork the gist. (should be work on gist buffer) + authentication required. + + :Gist XXXXX + get gist XXXXX. + + :Gist -c XXXXX. + get gist XXXXX and put to clipboard. + + :Gist -l + list gists from mine. + + :Gist -la + list gists from all. + + Tips: + if set g:gist_clip_command, gist.vim will copy the gist code + with option '-c'. + + # mac + let g:gist_clip_command = 'pbcopy' + + # linux + let g:gist_clip_command = 'xclip -selection clipboard' + + # others(cygwin?) + let g:gist_clip_command = 'putclip' + + if you want to detect filetype from filename... + + let g:gist_detect_filetype = 1 + + if you want to open browser after the post... + + let g:gist_open_browser_after_post = 1 + + if you want to change the browser... + + let g:gist_browser_command = 'w3m %URL%' + + or + + let g:gist_browser_command = 'opera %URL% &' + + on windows, should work with original setting. + + Require: + curl command (http://curl.haxx.se/) + and if you want to use profile of git, it require git command. + +install_details: | + copy it to your plugin directory. + + gist.vim leave cookie-jar file into runtimepath. + + rtp: + plugin/gist.vim + cookies/github + + See also: https://github.com/mattn/gist-vim/blob/master/README.mkd + +versions: +- '7.3': | + This is an upgrade for Gist.vim: fixed many bugs. Added few list actions: yank, paste, open in browser. + +- '7.2': | + This is an upgrade for Gist.vim: fixed many bugs. + +- '7.1': | + This is an upgrade for Gist.vim: updated installation notes. + +- '7.0': | + This is an upgrade for Gist.vim: fixed few bugs. + +- '6.9': | + This is an upgrade for Gist.vim: fixed few bugs. + +- '6.8': | + This is an upgrade for Gist.vim: changed authentication. removed password authentication. if you want to keep using password authentication, let gist_use_password_in_gitconfig to 1. + +- '6.7': | + This is an upgrade for Gist.vim: fix behavior of g:gist_browser_command = ':OpenBrowser %URL%'. + +- '6.6': | + This is an upgrade for Gist.vim: fixed detecting filetype. + +- '6.5': | + This is an upgrade for Gist.vim: use webapi namespace. NOTE: please upgrade webapi-vim also. + +- '6.4': | + This is an upgrade for Gist.vim: fixed updating with description. + +- '6.3': | + This is an upgrade for Gist.vim: fixed typos. + +- '6.2': | + This is an upgrade for Gist.vim: fixed some bugs. + +- '6.1': | + This is an upgrade for Gist.vim: fixed opening browser. + +- '6.0': | + This is an upgrade for Gist.vim: changed to use github APIs. Note to remove cookies directory if you used. + +- '5.9': | + This is an upgrade for Gist.vim: add support anonymous post. fixed many bugs. + +- '5.8': | + This is an upgrade for Gist.vim: add support for description. you can post description using -s option. + +- '5.7': | + This is an upgrade for Gist.vim: post with filetype more cleverly. + +- '5.6': | + This is an upgrade for Gist.vim: fix '--abandon'. + +- '5.5': | + This is an upgrade for Gist.vim: fix: forgot to upload autoload/gist.vim. + +- '5.4': | + This is an upgrade for Gist.vim: fix: does not work correctly with blockwize selection. + +- '5.3': | + This is an upgrade for Gist.vim: upd: support autoload. + +- '5.2': | + This is an upgrade for Gist.vim: add: support block-wise selection. + +- '5.1': | + This is an upgrade for Gist.vim: fix: can't update privates. + +- '5.0': | + This is an upgrade for Gist.vim: follow update of gist.github.com + +- '4.9': | + fix: don't add new line after "Done: xxx". + fix: show WHY FAILED' when failed to post. + add: support for :OpenBrowser. + add: new option 'gist_curl_options'. + +- '4.8': | + This is an upgrade for Gist.vim: fix: can't open private gist with ":Gist XXXXX". + +- '4.7': | + This is an upgrade for Gist.vim: fix: filetype detection. + +- '4.6': | + This is an upgrade for Gist.vim: fix: strange cookies folder. + +- '4.5': | + This is an upgrade for Gist.vim: fix: use gist_clip_command for copying URL to clipboard. this fix strange behavior on Mac OSX. + +- '4.4': | + This is an upgrade for Gist.vim: fix: gist is now only using https. + +- '4.3': | + This is an upgrade for Gist.vim: add new option '-f' for fork. + +- '4.2': | + This is an upgrade for Gist.vim: fixed code for login. + +- '4.1': | + This is an upgrade for Gist.vim: fixed code cleanup. + +- '4.0': | + This is an upgrade for Gist.vim: fixed deleting gist, listing privates. + +- '3.9': | + This is an upgrade for Gist.vim: fixed :w handler in gist buffer. + +- '3.8': | + This is an upgrade for Gist.vim: 'more...' on gist list. + +- '3.7': | + This is an upgrade for Gist.vim: fix problem that break "gist list" window at twice. + +- '3.6': | + This is an upgrade for Gist.vim: fix filetype detection for 'vimscript'. + +- '3.5': | + This is an upgrade for Gist.vim: fix filetype detection. + +- '3.4': | + This is an upgrade for Gist.vim: use '+' register on unix only if built with 'xterm_clipboard'. and some bug fixes. + +- '3.3': | + This is an upgrade for Gist.vim: fix problem that append empty line when getting gist. + +- '3.2': | + This is an upgrade for Gist.vim: added Gist header to recognize the gist. added script type header for Vimana. + +- '3.1': | + This is an upgrade for Gist.vim: fix checking redirect url. + +- '3.0': | + This is an upgrade for Gist.vim: fix for official changes(private button name was changed). + +- '2.9': | + This is an upgrade for Gist.vim: fix for official changes(private button name was changed). + +- '2.8': | + This is an upgrade for Gist.vim: be able to post multi buffer. currently updating or showing not supported. and ':Gist -d' delete the gist. + +- '2.7': | + This is an upgrade for Gist.vim: be able to write the gist to local file with ':w foo.txt'. + +- '2.6': | + This is an upgrade for Gist.vim: fixed problem that does not work 'Gist XXXX'. + +- '2.5': | + This is an upgrade for Gist.vim: use existing buffer when open the list or gist. + +- '2.4': | + This is an upgrade for Gist.vim: show error message when no any github settings. + +- '2.3': | + This is an upgrade for Gist.vim: added :w BufWriteCmd for GistUpdate. + +- '2.2': | + This is an upgrade for Gist.vim: fixed a bug for anonymous post. and new option '-a' for anonymous post. + +- '2.1': | + This is an upgrade for Gist.vim: support changing gist filename. + +- '2.0': | + This is an upgrade for Gist.vim: bugfix for listing gists in specified user. + +- '1.9': | + This is an upgrade for Gist.vim: added support editing the gist. and bits bug fix. + +- '1.8': | + This is an upgrade for Gist.vim: added new option g:gist_open_browser_after_post/g:gist_browser_command to open posted gist. + +- '1.7': | + This is an upgrade for Gist.vim: now changed argument for putting clipboard as ':Gist -c XXXXX'. + +- '1.6': | + This is an upgrade for Gist.vim: add gist's author in gist list. + +- '1.5': | + This is an upgrade for Gist.vim: oops. bugfix for auto-detection. + +- '1.4': | + This is an upgrade for Gist.vim: bugfix for auto-detection. + +- '1.3': | + This is an upgrade for Gist.vim: more auto-detection for filetype. + +- '1.2': | + This is an upgrade for Gist.vim: added new option for detect filetype from filename. + +- '1.1': | + This is an upgrade for Gist.vim: calling StdinReadPost. + +- '1.0': | + This is an upgrade for Gist.vim: treat literal "-" as part of username. + +- '0.9': | + This is an upgrade for Gist.vim: added new option 'g:gist_clip_command' that copy the gist code. + +# __END__ +# vim: filetype=yaml diff --git a/sources_non_forked/gist-vim/plugin/gist.vim b/sources_non_forked/gist-vim/plugin/gist.vim new file mode 100644 index 00000000..4aa674de --- /dev/null +++ b/sources_non_forked/gist-vim/plugin/gist.vim @@ -0,0 +1,23 @@ +"============================================================================= +" File: gist.vim +" Author: Yasuhiro Matsumoto +" WebPage: http://github.com/mattn/gist-vim +" License: BSD +" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim +" script type: plugin + +if &compatible || (exists('g:loaded_gist_vim') && g:loaded_gist_vim) + finish +endif +let g:loaded_gist_vim = 1 + +function! s:CompleteArgs(arg_lead,cmdline,cursor_pos) + return filter(copy(["-p", "-P", "-a", "-m", "-e", "-s", "-d", "+1", "-1", "-f", "-c", "-l", "-la", "-ls", "-b", + \ "--listall", "--liststar", "--list", "--multibuffer", "--private", "--public", "--anonymous", "--description", "--clipboard", + \ "--rawurl", "--delete", "--edit", "--star", "--unstar", "--fork", "--browser" + \ ]), 'stridx(v:val, a:arg_lead)==0') +endfunction + +command! -nargs=? -range=% -bang -complete=customlist,s:CompleteArgs Gist :call gist#Gist(, "", , , ) + +" vim:set et: diff --git a/sources_non_forked/goyo.vim/.github/FUNDING.yml b/sources_non_forked/goyo.vim/.github/FUNDING.yml new file mode 100644 index 00000000..f2848951 --- /dev/null +++ b/sources_non_forked/goyo.vim/.github/FUNDING.yml @@ -0,0 +1 @@ +github: junegunn diff --git a/sources_non_forked/goyo.vim/LICENSE b/sources_non_forked/goyo.vim/LICENSE new file mode 100644 index 00000000..50aa5d92 --- /dev/null +++ b/sources_non_forked/goyo.vim/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2021 Junegunn Choi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/sources_non_forked/goyo.vim/autoload/goyo.vim b/sources_non_forked/goyo.vim/autoload/goyo.vim new file mode 100644 index 00000000..0593f78c --- /dev/null +++ b/sources_non_forked/goyo.vim/autoload/goyo.vim @@ -0,0 +1,447 @@ +" Copyright (c) 2015 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +let s:cpo_save = &cpo +set cpo&vim + +function! s:const(val, min, max) + return min([max([a:val, a:min]), a:max]) +endfunction + +function! s:get_color(group, attr) + return synIDattr(synIDtrans(hlID(a:group)), a:attr) +endfunction + +function! s:set_color(group, attr, color) + let gui = has('gui_running') || has('termguicolors') && &termguicolors + execute printf('hi %s %s%s=%s', a:group, gui ? 'gui' : 'cterm', a:attr, a:color) +endfunction + +function! s:blank(repel) + if bufwinnr(t:goyo_pads.r) <= bufwinnr(t:goyo_pads.l) + 1 + \ || bufwinnr(t:goyo_pads.b) <= bufwinnr(t:goyo_pads.t) + 3 + call s:goyo_off() + endif + execute 'wincmd' a:repel +endfunction + +function! s:init_pad(command) + execute a:command + + setlocal buftype=nofile bufhidden=wipe nomodifiable nobuflisted noswapfile + \ nonu nocursorline nocursorcolumn winfixwidth winfixheight statusline=\ + if exists('&rnu') + setlocal nornu + endif + if exists('&colorcolumn') + setlocal colorcolumn= + endif + let bufnr = winbufnr(0) + + execute winnr('#') . 'wincmd w' + return bufnr +endfunction + +function! s:setup_pad(bufnr, vert, size, repel) + let win = bufwinnr(a:bufnr) + execute win . 'wincmd w' + execute (a:vert ? 'vertical ' : '') . 'resize ' . max([0, a:size]) + augroup goyop + execute 'autocmd WinEnter,CursorMoved nested call s:blank("'.a:repel.'")' + autocmd WinLeave call s:hide_statusline() + augroup END + + " To hide scrollbars of pad windows in GVim + let diff = winheight(0) - line('$') - (has('gui_running') ? 2 : 0) + if diff > 0 + setlocal modifiable + call append(0, map(range(1, diff), '""')) + normal! gg + setlocal nomodifiable + endif + execute winnr('#') . 'wincmd w' +endfunction + +function! s:resize_pads() + augroup goyop + autocmd! + augroup END + + let t:goyo_dim.width = s:const(t:goyo_dim.width, 2, &columns) + let t:goyo_dim.height = s:const(t:goyo_dim.height, 2, &lines) + + let vmargin = max([0, (&lines - t:goyo_dim.height) / 2 - 1]) + let yoff = s:const(t:goyo_dim.yoff, - vmargin, vmargin) + let top = vmargin + yoff + let bot = vmargin - yoff - 1 + call s:setup_pad(t:goyo_pads.t, 0, top, 'j') + call s:setup_pad(t:goyo_pads.b, 0, bot, 'k') + + let nwidth = max([len(string(line('$'))) + 1, &numberwidth]) + let width = t:goyo_dim.width + (&number ? nwidth : 0) + let hmargin = max([0, (&columns - width) / 2 - 1]) + let xoff = s:const(t:goyo_dim.xoff, - hmargin, hmargin) + call s:setup_pad(t:goyo_pads.l, 1, hmargin + xoff, 'l') + call s:setup_pad(t:goyo_pads.r, 1, hmargin - xoff, 'h') +endfunction + +function! s:tranquilize() + let bg = s:get_color('Normal', 'bg#') + for grp in ['NonText', 'FoldColumn', 'ColorColumn', 'VertSplit', + \ 'StatusLine', 'StatusLineNC', 'SignColumn'] + " -1 on Vim / '' on GVim + if bg == -1 || empty(bg) + call s:set_color(grp, 'fg', get(g:, 'goyo_bg', 'black')) + call s:set_color(grp, 'bg', 'NONE') + else + call s:set_color(grp, 'fg', bg) + call s:set_color(grp, 'bg', bg) + endif + call s:set_color(grp, '', 'NONE') + endfor +endfunction + +function! s:hide_statusline() + setlocal statusline=\ +endfunction + +function! s:hide_linenr() + if !get(g:, 'goyo_linenr', 0) + setlocal nonu + if exists('&rnu') + setlocal nornu + endif + endif + if exists('&colorcolumn') + setlocal colorcolumn= + endif +endfunction + +function! s:maps_nop() + let mapped = filter(['R', 'H', 'J', 'K', 'L', '|', '_'], + \ "empty(maparg(\"\\".v:val, 'n'))") + for c in mapped + execute 'nnoremap '.escape(c, '|').' ' + endfor + return mapped +endfunction + +function! s:maps_resize() + let commands = { + \ '=': ':let t:goyo_dim = parse_arg(t:goyo_dim_expr) call resize_pads()', + \ '>': ':let t:goyo_dim.width = winwidth(0) + 2 * v:count1 call resize_pads()', + \ '<': ':let t:goyo_dim.width = winwidth(0) - 2 * v:count1 call resize_pads()', + \ '+': ':let t:goyo_dim.height += 2 * v:count1 call resize_pads()', + \ '-': ':let t:goyo_dim.height -= 2 * v:count1 call resize_pads()' + \ } + let mapped = filter(keys(commands), "empty(maparg(\"\\".v:val, 'n'))") + for c in mapped + execute 'nnoremap '.c.' '.commands[c] + endfor + return mapped +endfunction + +nnoremap (goyo-resize) :call resize_pads() + +function! s:goyo_on(dim) + let dim = s:parse_arg(a:dim) + if empty(dim) + return + endif + + let s:orig_tab = tabpagenr() + let settings = + \ { 'laststatus': &laststatus, + \ 'showtabline': &showtabline, + \ 'fillchars': &fillchars, + \ 'winminwidth': &winminwidth, + \ 'winwidth': &winwidth, + \ 'winminheight': &winminheight, + \ 'winheight': &winheight, + \ 'ruler': &ruler, + \ 'sidescroll': &sidescroll, + \ 'sidescrolloff': &sidescrolloff + \ } + + " New tab + tab split + + let t:goyo_master = winbufnr(0) + let t:goyo_dim = dim + let t:goyo_dim_expr = a:dim + let t:goyo_pads = {} + let t:goyo_revert = settings + let t:goyo_maps = extend(s:maps_nop(), s:maps_resize()) + if has('gui_running') + let t:goyo_revert.guioptions = &guioptions + endif + + " vim-gitgutter + let t:goyo_disabled_gitgutter = get(g:, 'gitgutter_enabled', 0) + if t:goyo_disabled_gitgutter + silent! GitGutterDisable + endif + + " vim-signify + let t:goyo_disabled_signify = !empty(getbufvar(bufnr(''), 'sy')) + if t:goyo_disabled_signify + SignifyToggle + endif + + " vim-airline + let t:goyo_disabled_airline = exists('#airline') + if t:goyo_disabled_airline + AirlineToggle + endif + + " vim-powerline + let t:goyo_disabled_powerline = exists('#PowerlineMain') + if t:goyo_disabled_powerline + augroup PowerlineMain + autocmd! + augroup END + augroup! PowerlineMain + endif + + " lightline.vim + let t:goyo_disabled_lightline = exists('#lightline') + if t:goyo_disabled_lightline + silent! call lightline#disable() + endif + + call s:hide_linenr() + " Global options + let &winheight = max([&winminheight, 1]) + set winminheight=1 + set winheight=1 + set winminwidth=1 winwidth=1 + set laststatus=0 + set showtabline=0 + set noruler + set fillchars+=vert:\ + set fillchars+=stl:\ + set fillchars+=stlnc:\ + set sidescroll=1 + set sidescrolloff=0 + + " Hide left-hand scrollbars + if has('gui_running') + set guioptions-=l + set guioptions-=L + endif + + let t:goyo_pads.l = s:init_pad('vertical topleft new') + let t:goyo_pads.r = s:init_pad('vertical botright new') + let t:goyo_pads.t = s:init_pad('topleft new') + let t:goyo_pads.b = s:init_pad('botright new') + + call s:resize_pads() + call s:tranquilize() + + augroup goyo + autocmd! + autocmd TabLeave * nested call s:goyo_off() + autocmd VimResized * call s:resize_pads() + autocmd ColorScheme * call s:tranquilize() + autocmd BufWinEnter * call s:hide_linenr() | call s:hide_statusline() + autocmd WinEnter,WinLeave * call s:hide_statusline() + if has('nvim') + autocmd TermClose * call feedkeys("\(goyo-resize)") + endif + augroup END + + call s:hide_statusline() + if exists('g:goyo_callbacks[0]') + call g:goyo_callbacks[0]() + endif + if exists('#User#GoyoEnter') + doautocmd User GoyoEnter + endif +endfunction + +function! s:goyo_off() + if !exists('#goyo') + return + endif + + " Oops, not this tab + if !exists('t:goyo_revert') + return + endif + + " Clear auto commands + augroup goyo + autocmd! + augroup END + augroup! goyo + augroup goyop + autocmd! + augroup END + augroup! goyop + + for c in t:goyo_maps + execute 'nunmap '.escape(c, '|') + endfor + + let goyo_revert = t:goyo_revert + let goyo_disabled_gitgutter = t:goyo_disabled_gitgutter + let goyo_disabled_signify = t:goyo_disabled_signify + let goyo_disabled_airline = t:goyo_disabled_airline + let goyo_disabled_powerline = t:goyo_disabled_powerline + let goyo_disabled_lightline = t:goyo_disabled_lightline + let goyo_orig_buffer = t:goyo_master + let [line, col] = [line('.'), col('.')] + + if tabpagenr() == 1 + tabnew + normal! gt + bd + endif + tabclose + execute 'normal! '.s:orig_tab.'gt' + if winbufnr(0) == goyo_orig_buffer + " Doesn't work if window closed with `q` + execute printf('normal! %dG%d|', line, col) + endif + + let wmw = remove(goyo_revert, 'winminwidth') + let ww = remove(goyo_revert, 'winwidth') + let &winwidth = ww + let &winminwidth = wmw + let wmh = remove(goyo_revert, 'winminheight') + let wh = remove(goyo_revert, 'winheight') + let &winheight = max([wmh, 1]) + let &winminheight = wmh + let &winheight = wh + + for [k, v] in items(goyo_revert) + execute printf('let &%s = %s', k, string(v)) + endfor + execute 'colo '. get(g:, 'colors_name', 'default') + + if goyo_disabled_gitgutter + silent! GitGutterEnable + endif + + if goyo_disabled_signify + silent! if !b:sy.active + SignifyToggle + endif + endif + + if goyo_disabled_airline && !exists('#airline') + AirlineToggle + " For some reason, Airline requires two refreshes to avoid display + " artifacts + silent! AirlineRefresh + silent! AirlineRefresh + endif + + if goyo_disabled_powerline && !exists('#PowerlineMain') + doautocmd PowerlineStartup VimEnter + silent! PowerlineReloadColorscheme + endif + + if goyo_disabled_lightline + silent! call lightline#enable() + endif + + if exists('#Powerline') + doautocmd Powerline ColorScheme + endif + + if exists('g:goyo_callbacks[1]') + call g:goyo_callbacks[1]() + endif + if exists('#User#GoyoLeave') + doautocmd User GoyoLeave + endif +endfunction + +function! s:relsz(expr, limit) + if a:expr !~ '%$' + return str2nr(a:expr) + endif + return a:limit * str2nr(a:expr[:-2]) / 100 +endfunction + +function! s:parse_arg(arg) + if exists('g:goyo_height') || !exists('g:goyo_margin_top') && !exists('g:goyo_margin_bottom') + let height = s:relsz(get(g:, 'goyo_height', '85%'), &lines) + let yoff = 0 + else + let top = max([0, s:relsz(get(g:, 'goyo_margin_top', 4), &lines)]) + let bot = max([0, s:relsz(get(g:, 'goyo_margin_bottom', 4), &lines)]) + let height = &lines - top - bot + let yoff = top - bot + endif + + let dim = { 'width': s:relsz(get(g:, 'goyo_width', 80), &columns), + \ 'height': height, + \ 'xoff': 0, + \ 'yoff': yoff } + if empty(a:arg) + return dim + endif + let parts = matchlist(a:arg, '^\s*\([0-9]\+%\?\)\?\([+-][0-9]\+%\?\)\?\%(x\([0-9]\+%\?\)\?\([+-][0-9]\+%\?\)\?\)\?\s*$') + if empty(parts) + echohl WarningMsg + echo 'Invalid dimension expression: '.a:arg + echohl None + return {} + endif + if !empty(parts[1]) | let dim.width = s:relsz(parts[1], &columns) | endif + if !empty(parts[2]) | let dim.xoff = s:relsz(parts[2], &columns) | endif + if !empty(parts[3]) | let dim.height = s:relsz(parts[3], &lines) | endif + if !empty(parts[4]) | let dim.yoff = s:relsz(parts[4], &lines) | endif + return dim +endfunction + +function! goyo#execute(bang, dim) + if a:bang + if exists('#goyo') + call s:goyo_off() + endif + else + if exists('#goyo') == 0 + call s:goyo_on(a:dim) + elseif !empty(a:dim) + if winnr('$') < 5 + call s:goyo_off() + return goyo#execute(a:bang, a:dim) + endif + let dim = s:parse_arg(a:dim) + if !empty(dim) + let t:goyo_dim = dim + let t:goyo_dim_expr = a:dim + call s:resize_pads() + endif + else + call s:goyo_off() + end + end +endfunction + +let &cpo = s:cpo_save +unlet s:cpo_save + diff --git a/sources_non_forked/goyo.vim/doc/goyo.txt b/sources_non_forked/goyo.vim/doc/goyo.txt new file mode 100644 index 00000000..0dc57b2a --- /dev/null +++ b/sources_non_forked/goyo.vim/doc/goyo.txt @@ -0,0 +1,168 @@ +*goyo.txt* goyo Last change: April 2 2017 +GOYO - TABLE OF CONTENTS *goyo* *goyo-toc* +============================================================================== + + goyo.vim (고요) + Installation + Usage + Dimension expression + Configuration + Callbacks + Inspiration + Pros. + License + +GOYO.VIM (고요) *goyo-vim* +============================================================================== + +Distraction-free writing in Vim. + +https://raw.github.com/junegunn/i/master/goyo.png + +(Color scheme: {seoul256}{1}) + +Best served with {limelight.vim}{2}. + + {1} https://github.com/junegunn/seoul256.vim + {2} https://github.com/junegunn/limelight.vim + + +INSTALLATION *goyo-installation* +============================================================================== + +Use your favorite plugin manager. + + - {vim-plug}{3} + 1. Add `Plug 'junegunn/goyo.vim'` to .vimrc + 2. Run `:PlugInstall` + + {3} https://github.com/junegunn/vim-plug + + +USAGE *goyo-usage* +============================================================================== + + *:Goyo* + + - `:Goyo` + - Toggle Goyo + - `:Goyo [dimension]` + - Turn on or resize Goyo + - `:Goyo!` + - Turn Goyo off + +The window can be resized with the usual [count]`CTRL-W` + `>`, `<`, `+`, `-` keys, +and `CTRL-W` + `=` will resize it back to the initial size. + + +< Dimension expression >______________________________________________________~ + *goyo-dimension-expression* + +The expected format of a dimension expression is +`[WIDTH][XOFFSET][x[HEIGHT][YOFFSET]]`. `XOFFSET` and `YOFFSET` should be +prefixed by `+` or `-`. Each component can be given in percentage. +> + " Width + Goyo 120 + + " Height + Goyo x30 + + " Both + Goyo 120x30 + + " In percentage + Goyo 120x50% + + " With offsets + Goyo 50%+25%x50%-25% +< + +CONFIGURATION *goyo-configuration* +============================================================================== + + *g:goyo_width* *g:goyo_height* *g:goyo_linenr* + + - `g:goyo_width` (default: 80) + - `g:goyo_height` (default: 85%) + - `g:goyo_linenr` (default: 0) + + +< Callbacks >_________________________________________________________________~ + *goyo-callbacks* + +By default, {vim-airline}{4}, {vim-powerline}{5}, {powerline}{6}, +{lightline.vim}{7}, {vim-signify}{8}, and {vim-gitgutter}{9} are temporarily +disabled while in Goyo mode. + +If you have other plugins that you want to disable/enable, or if you want to +change the default settings of Goyo window, you can set up custom routines to +be triggered on `GoyoEnter` and `GoyoLeave` events. +> + function! s:goyo_enter() + silent !tmux set status off + silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z + set noshowmode + set noshowcmd + set scrolloff=999 + Limelight + " ... + endfunction + + function! s:goyo_leave() + silent !tmux set status on + silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z + set showmode + set showcmd + set scrolloff=5 + Limelight! + " ... + endfunction + + autocmd! User GoyoEnter nested call goyo_enter() + autocmd! User GoyoLeave nested call goyo_leave() +< +More examples can be found here: {Customization}{10} + + {4} https://github.com/bling/vim-airline + {5} https://github.com/Lokaltog/vim-powerline + {6} https://github.com/Lokaltog/powerline + {7} https://github.com/itchyny/lightline.vim + {8} https://github.com/mhinz/vim-signify + {9} https://github.com/airblade/vim-gitgutter + {10} https://github.com/junegunn/goyo.vim/wiki/Customization + + +INSPIRATION *goyo-inspiration* +============================================================================== + + - {LiteDFM}{11} + - {VimRoom}{12} + + {11} https://github.com/bilalq/lite-dfm + {12} http://projects.mikewest.org/vimroom/ + + +PROS. *goyo-pros* +============================================================================== + + 1. Works well with splits. Doesn't mess up with the current window arrangement + 2. Works well with popular statusline plugins + 3. Prevents accessing the empty windows around the central buffer + 4. Can be closed with any of `:q[uit]`, `:clo[se]`, `:tabc[lose]`, or `:Goyo` + 5. Can dynamically change the width of the window + 6. Adjusts its colors when color scheme is changed + 7. Realigns the window when the terminal (or window) is resized or when the size + of the font is changed + 8. Correctly hides colorcolumns and Emojis in statusline + 9. Highly customizable with callbacks + + +LICENSE *goyo-license* +============================================================================== + +MIT + + +============================================================================== +vim:tw=78:sw=2:ts=2:ft=help:norl:nowrap: diff --git a/sources_non_forked/goyo.vim/plugin/goyo.vim b/sources_non_forked/goyo.vim/plugin/goyo.vim new file mode 100644 index 00000000..af4793a1 --- /dev/null +++ b/sources_non_forked/goyo.vim/plugin/goyo.vim @@ -0,0 +1,24 @@ +" Copyright (c) 2015 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +command! -nargs=? -bar -bang Goyo call goyo#execute(0, ) diff --git a/sources_non_forked/gruvbox/CHANGELOG.md b/sources_non_forked/gruvbox/CHANGELOG.md new file mode 100644 index 00000000..90fd3a29 --- /dev/null +++ b/sources_non_forked/gruvbox/CHANGELOG.md @@ -0,0 +1,117 @@ +# Change Log + +## [Unreleased](https://github.com/morhetz/gruvbox/tree/HEAD) + +[Full Changelog](https://github.com/morhetz/gruvbox/compare/v1.3.5...HEAD) + +**Fixed bugs:** + +- Lighter background on terminal [\#8](https://github.com/morhetz/gruvbox/issues/8) + +**Closed issues:** + +- Installation issue. [\#54](https://github.com/morhetz/gruvbox/issues/54) + +- Italic font in terminal\(urxvt\) [\#49](https://github.com/morhetz/gruvbox/issues/49) + +- Unable to log in when sourcing the palette shellscript [\#48](https://github.com/morhetz/gruvbox/issues/48) + +- How can i modify multiple comment scheme [\#46](https://github.com/morhetz/gruvbox/issues/46) + +- Remove comment highlight in iterm [\#44](https://github.com/morhetz/gruvbox/issues/44) + +- Comments looking strange withing tmux [\#43](https://github.com/morhetz/gruvbox/issues/43) + +- comments are reverse-video in xterm [\#41](https://github.com/morhetz/gruvbox/issues/41) + +- What font are you using in the screenshots? [\#39](https://github.com/morhetz/gruvbox/issues/39) + +- vim-signature crashes when I use gruvbox [\#38](https://github.com/morhetz/gruvbox/issues/38) + +- Color of statusbar in inactive windows [\#37](https://github.com/morhetz/gruvbox/issues/37) + +- Go method and struct highlighting missing [\#36](https://github.com/morhetz/gruvbox/issues/36) + +- gruvbox\_256palette.sh doesn't work for Konsole [\#35](https://github.com/morhetz/gruvbox/issues/35) + +- Contrast in jekyll markdown files [\#33](https://github.com/morhetz/gruvbox/issues/33) + +- Pentadactyl Gruvbox Theme [\#32](https://github.com/morhetz/gruvbox/issues/32) + +- make vertsplit better [\#31](https://github.com/morhetz/gruvbox/issues/31) + +- Console support. [\#30](https://github.com/morhetz/gruvbox/issues/30) + +- How can I change the background color? [\#29](https://github.com/morhetz/gruvbox/issues/29) + +- Some words are not bold [\#28](https://github.com/morhetz/gruvbox/issues/28) + +- Terminal theme on base gruvbox [\#25](https://github.com/morhetz/gruvbox/issues/25) + +- Markdown has inverted colors when using \* [\#24](https://github.com/morhetz/gruvbox/issues/24) + +- how install it on mac osx [\#23](https://github.com/morhetz/gruvbox/issues/23) + +- Comments color for Terminal Vim [\#22](https://github.com/morhetz/gruvbox/issues/22) + +- Move palette files to gruvbox-generalized [\#20](https://github.com/morhetz/gruvbox/issues/20) + +- Maybe add Gruvbox Airline theme? [\#19](https://github.com/morhetz/gruvbox/issues/19) + +- For Sublime text [\#18](https://github.com/morhetz/gruvbox/issues/18) + +**Merged pull requests:** + +- Fix the 256 palette script failed login issue [\#53](https://github.com/morhetz/gruvbox/pull/53) ([jonasmalacofilho](https://github.com/jonasmalacofilho)) + +- add minimal coloring for gitcommit highlighting [\#52](https://github.com/morhetz/gruvbox/pull/52) ([daniely](https://github.com/daniely)) + +- For terminals, turn off italics by default. [\#47](https://github.com/morhetz/gruvbox/pull/47) ([ryanmjacobs](https://github.com/ryanmjacobs)) + +- Change color of vertical/horizontal seperators between split windows [\#45](https://github.com/morhetz/gruvbox/pull/45) ([deshtop](https://github.com/deshtop)) + +- Improve gruvbox with C code [\#34](https://github.com/morhetz/gruvbox/pull/34) ([gladiac](https://github.com/gladiac)) + +- Fix for linux console [\#27](https://github.com/morhetz/gruvbox/pull/27) ([vyp](https://github.com/vyp)) + +- Colors for plugin vimshell.vim [\#21](https://github.com/morhetz/gruvbox/pull/21) ([joelmo](https://github.com/joelmo)) + +## [v1.3.5](https://github.com/morhetz/gruvbox/tree/v1.3.5) (2014-03-19) + +[Full Changelog](https://github.com/morhetz/gruvbox/compare/v0.0.8...v1.3.5) + +**Implemented enhancements:** + +- Better selection colors [\#15](https://github.com/morhetz/gruvbox/issues/15) + +- When hlsearch is on, the cursor inverts the search color and not visible [\#2](https://github.com/morhetz/gruvbox/issues/2) + +**Fixed bugs:** + +- Problem with changing between dark and light on 256 color terminal [\#7](https://github.com/morhetz/gruvbox/issues/7) + +- IndentGuides coloring doesn't show up [\#1](https://github.com/morhetz/gruvbox/issues/1) + +**Closed issues:** + +- Requesting rxvt-unicode theme [\#17](https://github.com/morhetz/gruvbox/issues/17) + +- gruvbox\_256palette.sh gets reset \(gnome-terminal on Ubuntu\) [\#13](https://github.com/morhetz/gruvbox/issues/13) + +- Powerline colors [\#12](https://github.com/morhetz/gruvbox/issues/12) + +- Info necessary for making a port of this colorscheme [\#10](https://github.com/morhetz/gruvbox/issues/10) + +**Merged pull requests:** + +- Fix GNU screen detection for \*-bce [\#16](https://github.com/morhetz/gruvbox/pull/16) ([blueyed](https://github.com/blueyed)) + +- Added iTerm2 dark theme [\#11](https://github.com/morhetz/gruvbox/pull/11) ([Greduan](https://github.com/Greduan)) + +- Fix typo in Readme [\#5](https://github.com/morhetz/gruvbox/pull/5) ([ViViDboarder](https://github.com/ViViDboarder)) + +## [v0.0.8](https://github.com/morhetz/gruvbox/tree/v0.0.8) (2012-12-08) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/sources_non_forked/gruvbox/README.md b/sources_non_forked/gruvbox/README.md new file mode 100644 index 00000000..eca249c0 --- /dev/null +++ b/sources_non_forked/gruvbox/README.md @@ -0,0 +1,113 @@ + + +gruvbox is heavily inspired by [badwolf][], [jellybeans][] and [solarized][]. + +Designed as a bright theme with pastel 'retro groove' colors and light/dark mode switching in the way of [solarized][]. The main focus when developing gruvbox is to keep colors easily distinguishable, contrast enough and still pleasant for the eyes. + + [badwolf]: https://github.com/sjl/badwolf + [jellybeans]: https://github.com/nanotech/jellybeans.vim + [solarized]: http://ethanschoonover.com/solarized + +Attention +--------- + +1. [Read this first](https://github.com/morhetz/gruvbox/wiki/Terminal-specific) +2. Typeface from gallery is [Fantasque Sans Mono](https://github.com/belluzj/fantasque-sans) +3. Typeface from screenshots below is [Fira Mono](https://mozilla.github.io/Fira/) + +Screenshots +----------- + +Refer [Gallery][] for more syntax-specific screenshots. + + [Gallery]: https://github.com/morhetz/gruvbox/wiki/Gallery + +### Dark mode + +![Screenshot Dark](http://i.imgur.com/GkIl8Fn.png) + +### Light mode + +![Screenshot Light](http://i.imgur.com/X75niEa.png) + +### Airline theme + +![Screenshot Airline](http://i.imgur.com/wRQceUR.png) + +Palette +------- + +### Dark mode + +![Palette Dark](http://i.imgur.com/wa666xg.png) + +### Light mode + +![Palette Light](http://i.imgur.com/49qKyYW.png) + +Contrast options +---------------- + +Refer [wiki section][] for contrast configuration and other options. + + [wiki section]: https://github.com/morhetz/gruvbox/wiki/Configuration#ggruvbox_contrast_dark + +![Contrast Options](http://i.imgur.com/5MSbe6T.png) + +Documentation +------------- + +Please check [wiki][] for installation details, terminal-specific setup, troubleshooting, configuration options and others. + + [wiki]: https://github.com/morhetz/gruvbox/wiki + +Features +-------- + +* Lots of style-customization options (contrast, color invertion, italics usage etc.) +* Extended filetype highlighting: Html, Xml, Vim, Clojure, C, Python, JavaScript, TypeScript, PureScript, CoffeeScript, Ruby, Objective-C, Go, Lua, MoonScript, Java, Markdown, Haskell, Elixir +* Supported plugins: [EasyMotion][], [vim-sneak][], [Indent Guides][], [indentLine][], [Rainbow Parentheses][], [Airline][], [Lightline][], [GitGutter][], [Signify][], [ShowMarks][], [Signature][], [Syntastic][], [Ale][], [CtrlP][], [Startify][], [NERDTree][], [Dirvish][] + + [EasyMotion]: https://github.com/Lokaltog/vim-easymotion + [vim-sneak]: https://github.com/justinmk/vim-sneak + [Indent Guides]: https://github.com/nathanaelkane/vim-indent-guides + [indentLine]: https://github.com/Yggdroot/indentLine + [Rainbow Parentheses]: https://github.com/kien/rainbow_parentheses.vim + [Airline]: https://github.com/bling/vim-airline + [Lightline]: https://github.com/itchyny/lightline.vim + [GitGutter]: https://github.com/airblade/vim-gitgutter + [Signify]: https://github.com/mhinz/vim-signify + [ShowMarks]: http://www.vim.org/scripts/script.php?script_id=152 + [Signature]: https://github.com/kshenoy/vim-signature + [Syntastic]: https://github.com/scrooloose/syntastic + [Ale]: https://github.com/w0rp/ale + [CtrlP]: https://github.com/kien/ctrlp.vim + [Startify]: https://github.com/mhinz/vim-startify + [NERDTree]: https://github.com/scrooloose/nerdtree + [Dirvish]: https://github.com/justinmk/vim-dirvish + +Contributions +------------- + +See [gruvbox-contrib][] repo for contributions, ports and extras. + +[gruvbox-contrib]: https://github.com/morhetz/gruvbox-contrib + +ToDo +---- + +* Filetype syntax highlighting (R, TeX, Swift, Erlang) +* Plugin support (Tagbar, VimPlug) + +Self-Promotion +-------------- + +If you like gruvbox follow the repository on +[GitHub](https://github.com/morhetz/gruvbox) and vote for it on +[vim.org](http://www.vim.org/scripts/script.php?script_id=4349). + +License +------- +[MIT/X11][] + + [MIT/X11]: https://en.wikipedia.org/wiki/MIT_License diff --git a/sources_non_forked/gruvbox/autoload/airline/themes/gruvbox.vim b/sources_non_forked/gruvbox/autoload/airline/themes/gruvbox.vim new file mode 100644 index 00000000..6862a818 --- /dev/null +++ b/sources_non_forked/gruvbox/autoload/airline/themes/gruvbox.vim @@ -0,0 +1,79 @@ +" ----------------------------------------------------------------------------- +" File: gruvbox.vim +" Description: Retro groove color scheme for Airline +" Author: morhetz +" Source: https://github.com/morhetz/gruvbox +" Last Modified: 12 Aug 2017 +" ----------------------------------------------------------------------------- + +let g:airline#themes#gruvbox#palette = {} + +function! airline#themes#gruvbox#refresh() + + let M0 = airline#themes#get_highlight('Identifier') + let accents_group = airline#themes#get_highlight('Special') + let modified_group = [M0[0], '', M0[2], '', ''] + let warning_group = airline#themes#get_highlight2(['Normal', 'bg'], ['Question', 'fg']) + let error_group = airline#themes#get_highlight2(['Normal', 'bg'], ['WarningMsg', 'fg']) + + let s:N1 = airline#themes#get_highlight2(['Normal', 'bg'], ['StatusLineNC', 'bg']) + let s:N2 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['Pmenu', 'bg']) + let s:N3 = airline#themes#get_highlight2(['StatusLineNC', 'bg'], ['CursorLine', 'bg']) + let g:airline#themes#gruvbox#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3) + let g:airline#themes#gruvbox#palette.normal_modified = { 'airline_c': modified_group } + let g:airline#themes#gruvbox#palette.normal.airline_warning = warning_group + let g:airline#themes#gruvbox#palette.normal_modified.airline_warning = warning_group + let g:airline#themes#gruvbox#palette.normal.airline_error = error_group + let g:airline#themes#gruvbox#palette.normal_modified.airline_error = error_group + + let s:I1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Identifier', 'fg']) + let s:I2 = s:N2 + let s:I3 = airline#themes#get_highlight2(['Normal', 'fg'], ['Pmenu', 'bg']) + let g:airline#themes#gruvbox#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3) + let g:airline#themes#gruvbox#palette.insert_modified = g:airline#themes#gruvbox#palette.normal_modified + let g:airline#themes#gruvbox#palette.insert.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning + let g:airline#themes#gruvbox#palette.insert_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning + let g:airline#themes#gruvbox#palette.insert.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error + let g:airline#themes#gruvbox#palette.insert_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error + + let s:R1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Structure', 'fg']) + let s:R2 = s:I2 + let s:R3 = s:I3 + let g:airline#themes#gruvbox#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3) + let g:airline#themes#gruvbox#palette.replace_modified = g:airline#themes#gruvbox#palette.normal_modified + let g:airline#themes#gruvbox#palette.replace.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning + let g:airline#themes#gruvbox#palette.replace_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning + let g:airline#themes#gruvbox#palette.replace.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error + let g:airline#themes#gruvbox#palette.replace_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error + + let s:V1 = airline#themes#get_highlight2(['Normal', 'bg'], ['Question', 'fg']) + let s:V2 = s:N2 + let s:V3 = airline#themes#get_highlight2(['Normal', 'bg'], ['TabLine', 'fg']) + let g:airline#themes#gruvbox#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3) + let g:airline#themes#gruvbox#palette.visual_modified = { 'airline_c': [ s:V3[0], '', s:V3[2], '', '' ] } + let g:airline#themes#gruvbox#palette.visual.airline_warning = g:airline#themes#gruvbox#palette.normal.airline_warning + let g:airline#themes#gruvbox#palette.visual_modified.airline_warning = g:airline#themes#gruvbox#palette.normal_modified.airline_warning + let g:airline#themes#gruvbox#palette.visual.airline_error = g:airline#themes#gruvbox#palette.normal.airline_error + let g:airline#themes#gruvbox#palette.visual_modified.airline_error = g:airline#themes#gruvbox#palette.normal_modified.airline_error + + let s:IA = airline#themes#get_highlight2(['TabLine', 'fg'], ['CursorLine', 'bg']) + let g:airline#themes#gruvbox#palette.inactive = airline#themes#generate_color_map(s:IA, s:IA, s:IA) + let g:airline#themes#gruvbox#palette.inactive_modified = { 'airline_c': modified_group } + + let g:airline#themes#gruvbox#palette.accents = { 'red': accents_group } + + let s:TF = airline#themes#get_highlight2(['Normal', 'bg'], ['Normal', 'bg']) + let g:airline#themes#gruvbox#palette.tabline = { + \ 'airline_tab': s:N2, + \ 'airline_tabsel': s:N1, + \ 'airline_tabtype': s:V1, + \ 'airline_tabfill': s:TF, + \ 'airline_tabhid': s:IA, + \ 'airline_tabmod': s:I1 + \ } + +endfunction + +call airline#themes#gruvbox#refresh() + +" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: diff --git a/sources_non_forked/gruvbox/autoload/gruvbox.vim b/sources_non_forked/gruvbox/autoload/gruvbox.vim new file mode 100644 index 00000000..44bec6e1 --- /dev/null +++ b/sources_non_forked/gruvbox/autoload/gruvbox.vim @@ -0,0 +1,41 @@ +" ----------------------------------------------------------------------------- +" File: gruvbox.vim +" Description: Retro groove color scheme for Vim +" Author: morhetz +" Source: https://github.com/morhetz/gruvbox +" Last Modified: 09 Apr 2014 +" ----------------------------------------------------------------------------- + +function! gruvbox#invert_signs_toggle() + if g:gruvbox_invert_signs == 0 + let g:gruvbox_invert_signs=1 + else + let g:gruvbox_invert_signs=0 + endif + + colorscheme gruvbox +endfunction + +" Search Highlighting {{{ + +function! gruvbox#hls_show() + set hlsearch + call GruvboxHlsShowCursor() +endfunction + +function! gruvbox#hls_hide() + set nohlsearch + call GruvboxHlsHideCursor() +endfunction + +function! gruvbox#hls_toggle() + if &hlsearch + call gruvbox#hls_hide() + else + call gruvbox#hls_show() + endif +endfunction + +" }}} + +" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: diff --git a/sources_non_forked/gruvbox/autoload/lightline/colorscheme/gruvbox.vim b/sources_non_forked/gruvbox/autoload/lightline/colorscheme/gruvbox.vim new file mode 100644 index 00000000..4730c094 --- /dev/null +++ b/sources_non_forked/gruvbox/autoload/lightline/colorscheme/gruvbox.vim @@ -0,0 +1,57 @@ +" ----------------------------------------------------------------------------- +" File: gruvbox.vim +" Description: Gruvbox colorscheme for Lightline (itchyny/lightline.vim) +" Author: gmoe +" Source: https://github.com/morhetz/gruvbox +" Last Modified: 20 Sep 2017 +" ----------------------------------------------------------------------------- + +function! s:getGruvColor(group) + let guiColor = synIDattr(hlID(a:group), "fg", "gui") + let termColor = synIDattr(hlID(a:group), "fg", "cterm") + return [ guiColor, termColor ] +endfunction + +if exists('g:lightline') + + let s:bg0 = s:getGruvColor('GruvboxBg0') + let s:bg1 = s:getGruvColor('GruvboxBg1') + let s:bg2 = s:getGruvColor('GruvboxBg2') + let s:bg4 = s:getGruvColor('GruvboxBg4') + let s:fg1 = s:getGruvColor('GruvboxFg1') + let s:fg4 = s:getGruvColor('GruvboxFg4') + + let s:yellow = s:getGruvColor('GruvboxYellow') + let s:blue = s:getGruvColor('GruvboxBlue') + let s:aqua = s:getGruvColor('GruvboxAqua') + let s:orange = s:getGruvColor('GruvboxOrange') + let s:green = s:getGruvColor('GruvboxGreen') + + let s:p = {'normal':{}, 'inactive':{}, 'insert':{}, 'replace':{}, 'visual':{}, 'tabline':{}, 'terminal':{}} + let s:p.normal.left = [ [ s:bg0, s:fg4, 'bold' ], [ s:fg4, s:bg2 ] ] + let s:p.normal.right = [ [ s:bg0, s:fg4 ], [ s:fg4, s:bg2 ] ] + let s:p.normal.middle = [ [ s:fg4, s:bg1 ] ] + let s:p.inactive.right = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ] + let s:p.inactive.left = [ [ s:bg4, s:bg1 ], [ s:bg4, s:bg1 ] ] + let s:p.inactive.middle = [ [ s:bg4, s:bg1 ] ] + let s:p.insert.left = [ [ s:bg0, s:blue, 'bold' ], [ s:fg1, s:bg2 ] ] + let s:p.insert.right = [ [ s:bg0, s:blue ], [ s:fg1, s:bg2 ] ] + let s:p.insert.middle = [ [ s:fg4, s:bg2 ] ] + let s:p.terminal.left = [ [ s:bg0, s:green, 'bold' ], [ s:fg1, s:bg2 ] ] + let s:p.terminal.right = [ [ s:bg0, s:green ], [ s:fg1, s:bg2 ] ] + let s:p.terminal.middle = [ [ s:fg4, s:bg2 ] ] + let s:p.replace.left = [ [ s:bg0, s:aqua, 'bold' ], [ s:fg1, s:bg2 ] ] + let s:p.replace.right = [ [ s:bg0, s:aqua ], [ s:fg1, s:bg2 ] ] + let s:p.replace.middle = [ [ s:fg4, s:bg2 ] ] + let s:p.visual.left = [ [ s:bg0, s:orange, 'bold' ], [ s:bg0, s:bg4 ] ] + let s:p.visual.right = [ [ s:bg0, s:orange ], [ s:bg0, s:bg4 ] ] + let s:p.visual.middle = [ [ s:fg4, s:bg1 ] ] + let s:p.tabline.left = [ [ s:fg4, s:bg2 ] ] + let s:p.tabline.tabsel = [ [ s:bg0, s:fg4 ] ] + let s:p.tabline.middle = [ [ s:bg0, s:bg0 ] ] + let s:p.tabline.right = [ [ s:bg0, s:orange ] ] + let s:p.normal.error = [ [ s:bg0, s:orange ] ] + let s:p.normal.warning = [ [ s:bg2, s:yellow ] ] + + let g:lightline#colorscheme#gruvbox#palette = lightline#colorscheme#flatten(s:p) +endif diff --git a/sources_non_forked/gruvbox/colors/gruvbox.vim b/sources_non_forked/gruvbox/colors/gruvbox.vim new file mode 100644 index 00000000..66246fba --- /dev/null +++ b/sources_non_forked/gruvbox/colors/gruvbox.vim @@ -0,0 +1,1418 @@ +" ----------------------------------------------------------------------------- +" File: gruvbox.vim +" Description: Retro groove color scheme for Vim +" Author: morhetz +" Source: https://github.com/morhetz/gruvbox +" Last Modified: 12 Aug 2017 +" ----------------------------------------------------------------------------- + +" Supporting code ------------------------------------------------------------- +" Initialisation: {{{ + +if version > 580 + hi clear + if exists("syntax_on") + syntax reset + endif +endif + +let g:colors_name='gruvbox' + +if !(has('termguicolors') && &termguicolors) && !has('gui_running') && &t_Co != 256 + finish +endif + +" }}} +" Global Settings: {{{ + +if !exists('g:gruvbox_bold') + let g:gruvbox_bold=1 +endif +if !exists('g:gruvbox_italic') + if has('gui_running') || $TERM_ITALICS == 'true' + let g:gruvbox_italic=1 + else + let g:gruvbox_italic=0 + endif +endif +if !exists('g:gruvbox_undercurl') + let g:gruvbox_undercurl=1 +endif +if !exists('g:gruvbox_underline') + let g:gruvbox_underline=1 +endif +if !exists('g:gruvbox_inverse') + let g:gruvbox_inverse=1 +endif + +if !exists('g:gruvbox_guisp_fallback') || index(['fg', 'bg'], g:gruvbox_guisp_fallback) == -1 + let g:gruvbox_guisp_fallback='NONE' +endif + +if !exists('g:gruvbox_improved_strings') + let g:gruvbox_improved_strings=0 +endif + +if !exists('g:gruvbox_improved_warnings') + let g:gruvbox_improved_warnings=0 +endif + +if !exists('g:gruvbox_termcolors') + let g:gruvbox_termcolors=256 +endif + +if !exists('g:gruvbox_invert_indent_guides') + let g:gruvbox_invert_indent_guides=0 +endif + +if exists('g:gruvbox_contrast') + echo 'g:gruvbox_contrast is deprecated; use g:gruvbox_contrast_light and g:gruvbox_contrast_dark instead' +endif + +if !exists('g:gruvbox_contrast_dark') + let g:gruvbox_contrast_dark='medium' +endif + +if !exists('g:gruvbox_contrast_light') + let g:gruvbox_contrast_light='medium' +endif + +let s:is_dark=(&background == 'dark') + +" }}} +" Palette: {{{ + +" setup palette dictionary +let s:gb = {} + +" fill it with absolute colors +let s:gb.dark0_hard = ['#1d2021', 234] " 29-32-33 +let s:gb.dark0 = ['#282828', 235] " 40-40-40 +let s:gb.dark0_soft = ['#32302f', 236] " 50-48-47 +let s:gb.dark1 = ['#3c3836', 237] " 60-56-54 +let s:gb.dark2 = ['#504945', 239] " 80-73-69 +let s:gb.dark3 = ['#665c54', 241] " 102-92-84 +let s:gb.dark4 = ['#7c6f64', 243] " 124-111-100 +let s:gb.dark4_256 = ['#7c6f64', 243] " 124-111-100 + +let s:gb.gray_245 = ['#928374', 245] " 146-131-116 +let s:gb.gray_244 = ['#928374', 244] " 146-131-116 + +let s:gb.light0_hard = ['#f9f5d7', 230] " 249-245-215 +let s:gb.light0 = ['#fbf1c7', 229] " 253-244-193 +let s:gb.light0_soft = ['#f2e5bc', 228] " 242-229-188 +let s:gb.light1 = ['#ebdbb2', 223] " 235-219-178 +let s:gb.light2 = ['#d5c4a1', 250] " 213-196-161 +let s:gb.light3 = ['#bdae93', 248] " 189-174-147 +let s:gb.light4 = ['#a89984', 246] " 168-153-132 +let s:gb.light4_256 = ['#a89984', 246] " 168-153-132 + +let s:gb.bright_red = ['#fb4934', 167] " 251-73-52 +let s:gb.bright_green = ['#b8bb26', 142] " 184-187-38 +let s:gb.bright_yellow = ['#fabd2f', 214] " 250-189-47 +let s:gb.bright_blue = ['#83a598', 109] " 131-165-152 +let s:gb.bright_purple = ['#d3869b', 175] " 211-134-155 +let s:gb.bright_aqua = ['#8ec07c', 108] " 142-192-124 +let s:gb.bright_orange = ['#fe8019', 208] " 254-128-25 + +let s:gb.neutral_red = ['#cc241d', 124] " 204-36-29 +let s:gb.neutral_green = ['#98971a', 106] " 152-151-26 +let s:gb.neutral_yellow = ['#d79921', 172] " 215-153-33 +let s:gb.neutral_blue = ['#458588', 66] " 69-133-136 +let s:gb.neutral_purple = ['#b16286', 132] " 177-98-134 +let s:gb.neutral_aqua = ['#689d6a', 72] " 104-157-106 +let s:gb.neutral_orange = ['#d65d0e', 166] " 214-93-14 + +let s:gb.faded_red = ['#9d0006', 88] " 157-0-6 +let s:gb.faded_green = ['#79740e', 100] " 121-116-14 +let s:gb.faded_yellow = ['#b57614', 136] " 181-118-20 +let s:gb.faded_blue = ['#076678', 24] " 7-102-120 +let s:gb.faded_purple = ['#8f3f71', 96] " 143-63-113 +let s:gb.faded_aqua = ['#427b58', 66] " 66-123-88 +let s:gb.faded_orange = ['#af3a03', 130] " 175-58-3 + +" }}} +" Setup Emphasis: {{{ + +let s:bold = 'bold,' +if g:gruvbox_bold == 0 + let s:bold = '' +endif + +let s:italic = 'italic,' +if g:gruvbox_italic == 0 + let s:italic = '' +endif + +let s:underline = 'underline,' +if g:gruvbox_underline == 0 + let s:underline = '' +endif + +let s:undercurl = 'undercurl,' +if g:gruvbox_undercurl == 0 + let s:undercurl = '' +endif + +let s:inverse = 'inverse,' +if g:gruvbox_inverse == 0 + let s:inverse = '' +endif + +" }}} +" Setup Colors: {{{ + +let s:vim_bg = ['bg', 'bg'] +let s:vim_fg = ['fg', 'fg'] +let s:none = ['NONE', 'NONE'] + +" determine relative colors +if s:is_dark + let s:bg0 = s:gb.dark0 + if g:gruvbox_contrast_dark == 'soft' + let s:bg0 = s:gb.dark0_soft + elseif g:gruvbox_contrast_dark == 'hard' + let s:bg0 = s:gb.dark0_hard + endif + + let s:bg1 = s:gb.dark1 + let s:bg2 = s:gb.dark2 + let s:bg3 = s:gb.dark3 + let s:bg4 = s:gb.dark4 + + let s:gray = s:gb.gray_245 + + let s:fg0 = s:gb.light0 + let s:fg1 = s:gb.light1 + let s:fg2 = s:gb.light2 + let s:fg3 = s:gb.light3 + let s:fg4 = s:gb.light4 + + let s:fg4_256 = s:gb.light4_256 + + let s:red = s:gb.bright_red + let s:green = s:gb.bright_green + let s:yellow = s:gb.bright_yellow + let s:blue = s:gb.bright_blue + let s:purple = s:gb.bright_purple + let s:aqua = s:gb.bright_aqua + let s:orange = s:gb.bright_orange +else + let s:bg0 = s:gb.light0 + if g:gruvbox_contrast_light == 'soft' + let s:bg0 = s:gb.light0_soft + elseif g:gruvbox_contrast_light == 'hard' + let s:bg0 = s:gb.light0_hard + endif + + let s:bg1 = s:gb.light1 + let s:bg2 = s:gb.light2 + let s:bg3 = s:gb.light3 + let s:bg4 = s:gb.light4 + + let s:gray = s:gb.gray_244 + + let s:fg0 = s:gb.dark0 + let s:fg1 = s:gb.dark1 + let s:fg2 = s:gb.dark2 + let s:fg3 = s:gb.dark3 + let s:fg4 = s:gb.dark4 + + let s:fg4_256 = s:gb.dark4_256 + + let s:red = s:gb.faded_red + let s:green = s:gb.faded_green + let s:yellow = s:gb.faded_yellow + let s:blue = s:gb.faded_blue + let s:purple = s:gb.faded_purple + let s:aqua = s:gb.faded_aqua + let s:orange = s:gb.faded_orange +endif + +" reset to 16 colors fallback +if g:gruvbox_termcolors == 16 + let s:bg0[1] = 0 + let s:fg4[1] = 7 + let s:gray[1] = 8 + let s:red[1] = 9 + let s:green[1] = 10 + let s:yellow[1] = 11 + let s:blue[1] = 12 + let s:purple[1] = 13 + let s:aqua[1] = 14 + let s:fg1[1] = 15 +endif + +" save current relative colors back to palette dictionary +let s:gb.bg0 = s:bg0 +let s:gb.bg1 = s:bg1 +let s:gb.bg2 = s:bg2 +let s:gb.bg3 = s:bg3 +let s:gb.bg4 = s:bg4 + +let s:gb.gray = s:gray + +let s:gb.fg0 = s:fg0 +let s:gb.fg1 = s:fg1 +let s:gb.fg2 = s:fg2 +let s:gb.fg3 = s:fg3 +let s:gb.fg4 = s:fg4 + +let s:gb.fg4_256 = s:fg4_256 + +let s:gb.red = s:red +let s:gb.green = s:green +let s:gb.yellow = s:yellow +let s:gb.blue = s:blue +let s:gb.purple = s:purple +let s:gb.aqua = s:aqua +let s:gb.orange = s:orange + +" }}} +" Setup Terminal Colors For Neovim: {{{ + +if has('nvim') + let g:terminal_color_0 = s:bg0[0] + let g:terminal_color_8 = s:gray[0] + + let g:terminal_color_1 = s:gb.neutral_red[0] + let g:terminal_color_9 = s:red[0] + + let g:terminal_color_2 = s:gb.neutral_green[0] + let g:terminal_color_10 = s:green[0] + + let g:terminal_color_3 = s:gb.neutral_yellow[0] + let g:terminal_color_11 = s:yellow[0] + + let g:terminal_color_4 = s:gb.neutral_blue[0] + let g:terminal_color_12 = s:blue[0] + + let g:terminal_color_5 = s:gb.neutral_purple[0] + let g:terminal_color_13 = s:purple[0] + + let g:terminal_color_6 = s:gb.neutral_aqua[0] + let g:terminal_color_14 = s:aqua[0] + + let g:terminal_color_7 = s:fg4[0] + let g:terminal_color_15 = s:fg1[0] +endif + +" }}} +" Overload Setting: {{{ + +let s:hls_cursor = s:orange +if exists('g:gruvbox_hls_cursor') + let s:hls_cursor = get(s:gb, g:gruvbox_hls_cursor) +endif + +let s:number_column = s:none +if exists('g:gruvbox_number_column') + let s:number_column = get(s:gb, g:gruvbox_number_column) +endif + +let s:sign_column = s:bg1 + +if exists('g:gitgutter_override_sign_column_highlight') && + \ g:gitgutter_override_sign_column_highlight == 1 + let s:sign_column = s:number_column +else + let g:gitgutter_override_sign_column_highlight = 0 + + if exists('g:gruvbox_sign_column') + let s:sign_column = get(s:gb, g:gruvbox_sign_column) + endif +endif + +let s:color_column = s:bg1 +if exists('g:gruvbox_color_column') + let s:color_column = get(s:gb, g:gruvbox_color_column) +endif + +let s:vert_split = s:bg0 +if exists('g:gruvbox_vert_split') + let s:vert_split = get(s:gb, g:gruvbox_vert_split) +endif + +let s:invert_signs = '' +if exists('g:gruvbox_invert_signs') + if g:gruvbox_invert_signs == 1 + let s:invert_signs = s:inverse + endif +endif + +let s:invert_selection = s:inverse +if exists('g:gruvbox_invert_selection') + if g:gruvbox_invert_selection == 0 + let s:invert_selection = '' + endif +endif + +let s:invert_tabline = '' +if exists('g:gruvbox_invert_tabline') + if g:gruvbox_invert_tabline == 1 + let s:invert_tabline = s:inverse + endif +endif + +let s:italicize_comments = s:italic +if exists('g:gruvbox_italicize_comments') + if g:gruvbox_italicize_comments == 0 + let s:italicize_comments = '' + endif +endif + +let s:italicize_strings = '' +if exists('g:gruvbox_italicize_strings') + if g:gruvbox_italicize_strings == 1 + let s:italicize_strings = s:italic + endif +endif + +" }}} +" Highlighting Function: {{{ + +function! s:HL(group, fg, ...) + " Arguments: group, guifg, guibg, gui, guisp + + " foreground + let fg = a:fg + + " background + if a:0 >= 1 + let bg = a:1 + else + let bg = s:none + endif + + " emphasis + if a:0 >= 2 && strlen(a:2) + let emstr = a:2 + else + let emstr = 'NONE,' + endif + + " special fallback + if a:0 >= 3 + if g:gruvbox_guisp_fallback != 'NONE' + let fg = a:3 + endif + + " bg fallback mode should invert higlighting + if g:gruvbox_guisp_fallback == 'bg' + let emstr .= 'inverse,' + endif + endif + + let histring = [ 'hi', a:group, + \ 'guifg=' . fg[0], 'ctermfg=' . fg[1], + \ 'guibg=' . bg[0], 'ctermbg=' . bg[1], + \ 'gui=' . emstr[:-2], 'cterm=' . emstr[:-2] + \ ] + + " special + if a:0 >= 3 + call add(histring, 'guisp=' . a:3[0]) + endif + + execute join(histring, ' ') +endfunction + +" }}} +" Gruvbox Hi Groups: {{{ + +" memoize common hi groups +call s:HL('GruvboxFg0', s:fg0) +call s:HL('GruvboxFg1', s:fg1) +call s:HL('GruvboxFg2', s:fg2) +call s:HL('GruvboxFg3', s:fg3) +call s:HL('GruvboxFg4', s:fg4) +call s:HL('GruvboxGray', s:gray) +call s:HL('GruvboxBg0', s:bg0) +call s:HL('GruvboxBg1', s:bg1) +call s:HL('GruvboxBg2', s:bg2) +call s:HL('GruvboxBg3', s:bg3) +call s:HL('GruvboxBg4', s:bg4) + +call s:HL('GruvboxRed', s:red) +call s:HL('GruvboxRedBold', s:red, s:none, s:bold) +call s:HL('GruvboxGreen', s:green) +call s:HL('GruvboxGreenBold', s:green, s:none, s:bold) +call s:HL('GruvboxYellow', s:yellow) +call s:HL('GruvboxYellowBold', s:yellow, s:none, s:bold) +call s:HL('GruvboxBlue', s:blue) +call s:HL('GruvboxBlueBold', s:blue, s:none, s:bold) +call s:HL('GruvboxPurple', s:purple) +call s:HL('GruvboxPurpleBold', s:purple, s:none, s:bold) +call s:HL('GruvboxAqua', s:aqua) +call s:HL('GruvboxAquaBold', s:aqua, s:none, s:bold) +call s:HL('GruvboxOrange', s:orange) +call s:HL('GruvboxOrangeBold', s:orange, s:none, s:bold) + +call s:HL('GruvboxRedSign', s:red, s:sign_column, s:invert_signs) +call s:HL('GruvboxGreenSign', s:green, s:sign_column, s:invert_signs) +call s:HL('GruvboxYellowSign', s:yellow, s:sign_column, s:invert_signs) +call s:HL('GruvboxBlueSign', s:blue, s:sign_column, s:invert_signs) +call s:HL('GruvboxPurpleSign', s:purple, s:sign_column, s:invert_signs) +call s:HL('GruvboxAquaSign', s:aqua, s:sign_column, s:invert_signs) +call s:HL('GruvboxOrangeSign', s:orange, s:sign_column, s:invert_signs) + +" }}} + +" Vanilla colorscheme --------------------------------------------------------- +" General UI: {{{ + +" Normal text +call s:HL('Normal', s:fg1, s:bg0) + +" Correct background (see issue #7): +" --- Problem with changing between dark and light on 256 color terminal +" --- https://github.com/morhetz/gruvbox/issues/7 +if s:is_dark + set background=dark +else + set background=light +endif + +if version >= 700 + " Screen line that the cursor is + call s:HL('CursorLine', s:none, s:bg1) + " Screen column that the cursor is + hi! link CursorColumn CursorLine + + " Tab pages line filler + call s:HL('TabLineFill', s:bg4, s:bg1, s:invert_tabline) + " Active tab page label + call s:HL('TabLineSel', s:green, s:bg1, s:invert_tabline) + " Not active tab page label + hi! link TabLine TabLineFill + + " Match paired bracket under the cursor + call s:HL('MatchParen', s:none, s:bg3, s:bold) +endif + +if version >= 703 + " Highlighted screen columns + call s:HL('ColorColumn', s:none, s:color_column) + + " Concealed element: \lambda → λ + call s:HL('Conceal', s:blue, s:none) + + " Line number of CursorLine + call s:HL('CursorLineNr', s:yellow, s:bg1) +endif + +hi! link NonText GruvboxBg2 +hi! link SpecialKey GruvboxBg2 + +call s:HL('Visual', s:none, s:bg3, s:invert_selection) +hi! link VisualNOS Visual + +call s:HL('Search', s:yellow, s:bg0, s:inverse) +call s:HL('IncSearch', s:hls_cursor, s:bg0, s:inverse) + +call s:HL('Underlined', s:blue, s:none, s:underline) + +call s:HL('StatusLine', s:bg2, s:fg1, s:inverse) +call s:HL('StatusLineNC', s:bg1, s:fg4, s:inverse) + +" The column separating vertically split windows +call s:HL('VertSplit', s:bg3, s:vert_split) + +" Current match in wildmenu completion +call s:HL('WildMenu', s:blue, s:bg2, s:bold) + +" Directory names, special names in listing +hi! link Directory GruvboxGreenBold + +" Titles for output from :set all, :autocmd, etc. +hi! link Title GruvboxGreenBold + +" Error messages on the command line +call s:HL('ErrorMsg', s:bg0, s:red, s:bold) +" More prompt: -- More -- +hi! link MoreMsg GruvboxYellowBold +" Current mode message: -- INSERT -- +hi! link ModeMsg GruvboxYellowBold +" 'Press enter' prompt and yes/no questions +hi! link Question GruvboxOrangeBold +" Warning messages +hi! link WarningMsg GruvboxRedBold + +" }}} +" Gutter: {{{ + +" Line number for :number and :# commands +call s:HL('LineNr', s:bg4, s:number_column) + +" Column where signs are displayed +call s:HL('SignColumn', s:none, s:sign_column) + +" Line used for closed folds +call s:HL('Folded', s:gray, s:bg1, s:italic) +" Column where folds are displayed +call s:HL('FoldColumn', s:gray, s:bg1) + +" }}} +" Cursor: {{{ + +" Character under cursor +call s:HL('Cursor', s:none, s:none, s:inverse) +" Visual mode cursor, selection +hi! link vCursor Cursor +" Input moder cursor +hi! link iCursor Cursor +" Language mapping cursor +hi! link lCursor Cursor + +" }}} +" Syntax Highlighting: {{{ + +if g:gruvbox_improved_strings == 0 + hi! link Special GruvboxOrange +else + call s:HL('Special', s:orange, s:bg1, s:italicize_strings) +endif + +call s:HL('Comment', s:gray, s:none, s:italicize_comments) +call s:HL('Todo', s:vim_fg, s:vim_bg, s:bold . s:italic) +call s:HL('Error', s:red, s:vim_bg, s:bold . s:inverse) + +" Generic statement +hi! link Statement GruvboxRed +" if, then, else, endif, swicth, etc. +hi! link Conditional GruvboxRed +" for, do, while, etc. +hi! link Repeat GruvboxRed +" case, default, etc. +hi! link Label GruvboxRed +" try, catch, throw +hi! link Exception GruvboxRed +" sizeof, "+", "*", etc. +hi! link Operator Normal +" Any other keyword +hi! link Keyword GruvboxRed + +" Variable name +hi! link Identifier GruvboxBlue +" Function name +hi! link Function GruvboxGreenBold + +" Generic preprocessor +hi! link PreProc GruvboxAqua +" Preprocessor #include +hi! link Include GruvboxAqua +" Preprocessor #define +hi! link Define GruvboxAqua +" Same as Define +hi! link Macro GruvboxAqua +" Preprocessor #if, #else, #endif, etc. +hi! link PreCondit GruvboxAqua + +" Generic constant +hi! link Constant GruvboxPurple +" Character constant: 'c', '/n' +hi! link Character GruvboxPurple +" String constant: "this is a string" +if g:gruvbox_improved_strings == 0 + call s:HL('String', s:green, s:none, s:italicize_strings) +else + call s:HL('String', s:fg1, s:bg1, s:italicize_strings) +endif +" Boolean constant: TRUE, false +hi! link Boolean GruvboxPurple +" Number constant: 234, 0xff +hi! link Number GruvboxPurple +" Floating point constant: 2.3e10 +hi! link Float GruvboxPurple + +" Generic type +hi! link Type GruvboxYellow +" static, register, volatile, etc +hi! link StorageClass GruvboxOrange +" struct, union, enum, etc. +hi! link Structure GruvboxAqua +" typedef +hi! link Typedef GruvboxYellow + +" }}} +" Completion Menu: {{{ + +if version >= 700 + " Popup menu: normal item + call s:HL('Pmenu', s:fg1, s:bg2) + " Popup menu: selected item + call s:HL('PmenuSel', s:bg2, s:blue, s:bold) + " Popup menu: scrollbar + call s:HL('PmenuSbar', s:none, s:bg2) + " Popup menu: scrollbar thumb + call s:HL('PmenuThumb', s:none, s:bg4) +endif + +" }}} +" Diffs: {{{ + +call s:HL('DiffDelete', s:red, s:bg0, s:inverse) +call s:HL('DiffAdd', s:green, s:bg0, s:inverse) +"call s:HL('DiffChange', s:bg0, s:blue) +"call s:HL('DiffText', s:bg0, s:yellow) + +" Alternative setting +call s:HL('DiffChange', s:aqua, s:bg0, s:inverse) +call s:HL('DiffText', s:yellow, s:bg0, s:inverse) + +" }}} +" Spelling: {{{ + +if has("spell") + " Not capitalised word, or compile warnings + if g:gruvbox_improved_warnings == 0 + call s:HL('SpellCap', s:none, s:none, s:undercurl, s:red) + else + call s:HL('SpellCap', s:green, s:none, s:bold . s:italic) + endif + " Not recognized word + call s:HL('SpellBad', s:none, s:none, s:undercurl, s:blue) + " Wrong spelling for selected region + call s:HL('SpellLocal', s:none, s:none, s:undercurl, s:aqua) + " Rare word + call s:HL('SpellRare', s:none, s:none, s:undercurl, s:purple) +endif + +" }}} + +" Plugin specific ------------------------------------------------------------- +" EasyMotion: {{{ + +hi! link EasyMotionTarget Search +hi! link EasyMotionShade Comment + +" }}} +" Sneak: {{{ + +hi! link Sneak Search +hi! link SneakLabel Search + +" }}} +" Indent Guides: {{{ + +if !exists('g:indent_guides_auto_colors') + let g:indent_guides_auto_colors = 0 +endif + +if g:indent_guides_auto_colors == 0 + if g:gruvbox_invert_indent_guides == 0 + call s:HL('IndentGuidesOdd', s:vim_bg, s:bg2) + call s:HL('IndentGuidesEven', s:vim_bg, s:bg1) + else + call s:HL('IndentGuidesOdd', s:vim_bg, s:bg2, s:inverse) + call s:HL('IndentGuidesEven', s:vim_bg, s:bg3, s:inverse) + endif +endif + +" }}} +" IndentLine: {{{ + +if !exists('g:indentLine_color_term') + let g:indentLine_color_term = s:bg2[1] +endif +if !exists('g:indentLine_color_gui') + let g:indentLine_color_gui = s:bg2[0] +endif + +" }}} +" Rainbow Parentheses: {{{ + +if !exists('g:rbpt_colorpairs') + let g:rbpt_colorpairs = + \ [ + \ ['blue', '#458588'], ['magenta', '#b16286'], + \ ['red', '#cc241d'], ['166', '#d65d0e'] + \ ] +endif + +let g:rainbow_guifgs = [ '#d65d0e', '#cc241d', '#b16286', '#458588' ] +let g:rainbow_ctermfgs = [ '166', 'red', 'magenta', 'blue' ] + +if !exists('g:rainbow_conf') + let g:rainbow_conf = {} +endif +if !has_key(g:rainbow_conf, 'guifgs') + let g:rainbow_conf['guifgs'] = g:rainbow_guifgs +endif +if !has_key(g:rainbow_conf, 'ctermfgs') + let g:rainbow_conf['ctermfgs'] = g:rainbow_ctermfgs +endif + +let g:niji_dark_colours = g:rbpt_colorpairs +let g:niji_light_colours = g:rbpt_colorpairs + +"}}} +" GitGutter: {{{ + +hi! link GitGutterAdd GruvboxGreenSign +hi! link GitGutterChange GruvboxAquaSign +hi! link GitGutterDelete GruvboxRedSign +hi! link GitGutterChangeDelete GruvboxAquaSign + +" }}} +" GitCommit: "{{{ + +hi! link gitcommitSelectedFile GruvboxGreen +hi! link gitcommitDiscardedFile GruvboxRed + +" }}} +" Signify: {{{ + +hi! link SignifySignAdd GruvboxGreenSign +hi! link SignifySignChange GruvboxAquaSign +hi! link SignifySignDelete GruvboxRedSign + +" }}} +" Syntastic: {{{ + +call s:HL('SyntasticError', s:none, s:none, s:undercurl, s:red) +call s:HL('SyntasticWarning', s:none, s:none, s:undercurl, s:yellow) + +hi! link SyntasticErrorSign GruvboxRedSign +hi! link SyntasticWarningSign GruvboxYellowSign + +" }}} +" Signature: {{{ +hi! link SignatureMarkText GruvboxBlueSign +hi! link SignatureMarkerText GruvboxPurpleSign + +" }}} +" ShowMarks: {{{ + +hi! link ShowMarksHLl GruvboxBlueSign +hi! link ShowMarksHLu GruvboxBlueSign +hi! link ShowMarksHLo GruvboxBlueSign +hi! link ShowMarksHLm GruvboxBlueSign + +" }}} +" CtrlP: {{{ + +hi! link CtrlPMatch GruvboxYellow +hi! link CtrlPNoEntries GruvboxRed +hi! link CtrlPPrtBase GruvboxBg2 +hi! link CtrlPPrtCursor GruvboxBlue +hi! link CtrlPLinePre GruvboxBg2 + +call s:HL('CtrlPMode1', s:blue, s:bg2, s:bold) +call s:HL('CtrlPMode2', s:bg0, s:blue, s:bold) +call s:HL('CtrlPStats', s:fg4, s:bg2, s:bold) + +" }}} +" Startify: {{{ + +hi! link StartifyBracket GruvboxFg3 +hi! link StartifyFile GruvboxFg1 +hi! link StartifyNumber GruvboxBlue +hi! link StartifyPath GruvboxGray +hi! link StartifySlash GruvboxGray +hi! link StartifySection GruvboxYellow +hi! link StartifySpecial GruvboxBg2 +hi! link StartifyHeader GruvboxOrange +hi! link StartifyFooter GruvboxBg2 + +" }}} +" Vimshell: {{{ + +let g:vimshell_escape_colors = [ + \ s:bg4[0], s:red[0], s:green[0], s:yellow[0], + \ s:blue[0], s:purple[0], s:aqua[0], s:fg4[0], + \ s:bg0[0], s:red[0], s:green[0], s:orange[0], + \ s:blue[0], s:purple[0], s:aqua[0], s:fg0[0] + \ ] + +" }}} +" BufTabLine: {{{ + +call s:HL('BufTabLineCurrent', s:bg0, s:fg4) +call s:HL('BufTabLineActive', s:fg4, s:bg2) +call s:HL('BufTabLineHidden', s:bg4, s:bg1) +call s:HL('BufTabLineFill', s:bg0, s:bg0) + +" }}} +" Asynchronous Lint Engine: {{{ + +call s:HL('ALEError', s:none, s:none, s:undercurl, s:red) +call s:HL('ALEWarning', s:none, s:none, s:undercurl, s:yellow) +call s:HL('ALEInfo', s:none, s:none, s:undercurl, s:blue) + +hi! link ALEErrorSign GruvboxRedSign +hi! link ALEWarningSign GruvboxYellowSign +hi! link ALEInfoSign GruvboxBlueSign + +" }}} +" Dirvish: {{{ + +hi! link DirvishPathTail GruvboxAqua +hi! link DirvishArg GruvboxYellow + +" }}} +" Netrw: {{{ + +hi! link netrwDir GruvboxAqua +hi! link netrwClassify GruvboxAqua +hi! link netrwLink GruvboxGray +hi! link netrwSymLink GruvboxFg1 +hi! link netrwExe GruvboxYellow +hi! link netrwComment GruvboxGray +hi! link netrwList GruvboxBlue +hi! link netrwHelpCmd GruvboxAqua +hi! link netrwCmdSep GruvboxFg3 +hi! link netrwVersion GruvboxGreen + +" }}} +" NERDTree: {{{ + +hi! link NERDTreeDir GruvboxAqua +hi! link NERDTreeDirSlash GruvboxAqua + +hi! link NERDTreeOpenable GruvboxOrange +hi! link NERDTreeClosable GruvboxOrange + +hi! link NERDTreeFile GruvboxFg1 +hi! link NERDTreeExecFile GruvboxYellow + +hi! link NERDTreeUp GruvboxGray +hi! link NERDTreeCWD GruvboxGreen +hi! link NERDTreeHelp GruvboxFg1 + +hi! link NERDTreeToggleOn GruvboxGreen +hi! link NERDTreeToggleOff GruvboxRed + +" }}} +" Vim Multiple Cursors: {{{ + +call s:HL('multiple_cursors_cursor', s:none, s:none, s:inverse) +call s:HL('multiple_cursors_visual', s:none, s:bg2) + +" }}} +" coc.nvim: {{{ + +hi! link CocErrorSign GruvboxRedSign +hi! link CocWarningSign GruvboxOrangeSign +hi! link CocInfoSign GruvboxYellowSign +hi! link CocHintSign GruvboxBlueSign +hi! link CocErrorFloat GruvboxRed +hi! link CocWarningFloat GruvboxOrange +hi! link CocInfoFloat GruvboxYellow +hi! link CocHintFloat GruvboxBlue +hi! link CocDiagnosticsError GruvboxRed +hi! link CocDiagnosticsWarning GruvboxOrange +hi! link CocDiagnosticsInfo GruvboxYellow +hi! link CocDiagnosticsHint GruvboxBlue + +hi! link CocSelectedText GruvboxRed +hi! link CocCodeLens GruvboxGray + +call s:HL('CocErrorHighlight', s:none, s:none, s:undercurl, s:red) +call s:HL('CocWarningHighlight', s:none, s:none, s:undercurl, s:orange) +call s:HL('CocInfoHighlight', s:none, s:none, s:undercurl, s:yellow) +call s:HL('CocHintHighlight', s:none, s:none, s:undercurl, s:blue) + +" }}} + +" Filetype specific ----------------------------------------------------------- +" Diff: {{{ + +hi! link diffAdded GruvboxGreen +hi! link diffRemoved GruvboxRed +hi! link diffChanged GruvboxAqua + +hi! link diffFile GruvboxOrange +hi! link diffNewFile GruvboxYellow + +hi! link diffLine GruvboxBlue + +" }}} +" Html: {{{ + +hi! link htmlTag GruvboxBlue +hi! link htmlEndTag GruvboxBlue + +hi! link htmlTagName GruvboxAquaBold +hi! link htmlArg GruvboxAqua + +hi! link htmlScriptTag GruvboxPurple +hi! link htmlTagN GruvboxFg1 +hi! link htmlSpecialTagName GruvboxAquaBold + +call s:HL('htmlLink', s:fg4, s:none, s:underline) + +hi! link htmlSpecialChar GruvboxOrange + +call s:HL('htmlBold', s:vim_fg, s:vim_bg, s:bold) +call s:HL('htmlBoldUnderline', s:vim_fg, s:vim_bg, s:bold . s:underline) +call s:HL('htmlBoldItalic', s:vim_fg, s:vim_bg, s:bold . s:italic) +call s:HL('htmlBoldUnderlineItalic', s:vim_fg, s:vim_bg, s:bold . s:underline . s:italic) + +call s:HL('htmlUnderline', s:vim_fg, s:vim_bg, s:underline) +call s:HL('htmlUnderlineItalic', s:vim_fg, s:vim_bg, s:underline . s:italic) +call s:HL('htmlItalic', s:vim_fg, s:vim_bg, s:italic) + +" }}} +" Xml: {{{ + +hi! link xmlTag GruvboxBlue +hi! link xmlEndTag GruvboxBlue +hi! link xmlTagName GruvboxBlue +hi! link xmlEqual GruvboxBlue +hi! link docbkKeyword GruvboxAquaBold + +hi! link xmlDocTypeDecl GruvboxGray +hi! link xmlDocTypeKeyword GruvboxPurple +hi! link xmlCdataStart GruvboxGray +hi! link xmlCdataCdata GruvboxPurple +hi! link dtdFunction GruvboxGray +hi! link dtdTagName GruvboxPurple + +hi! link xmlAttrib GruvboxAqua +hi! link xmlProcessingDelim GruvboxGray +hi! link dtdParamEntityPunct GruvboxGray +hi! link dtdParamEntityDPunct GruvboxGray +hi! link xmlAttribPunct GruvboxGray + +hi! link xmlEntity GruvboxOrange +hi! link xmlEntityPunct GruvboxOrange +" }}} +" Vim: {{{ + +call s:HL('vimCommentTitle', s:fg4_256, s:none, s:bold . s:italicize_comments) + +hi! link vimNotation GruvboxOrange +hi! link vimBracket GruvboxOrange +hi! link vimMapModKey GruvboxOrange +hi! link vimFuncSID GruvboxFg3 +hi! link vimSetSep GruvboxFg3 +hi! link vimSep GruvboxFg3 +hi! link vimContinue GruvboxFg3 + +" }}} +" Clojure: {{{ + +hi! link clojureKeyword GruvboxBlue +hi! link clojureCond GruvboxOrange +hi! link clojureSpecial GruvboxOrange +hi! link clojureDefine GruvboxOrange + +hi! link clojureFunc GruvboxYellow +hi! link clojureRepeat GruvboxYellow +hi! link clojureCharacter GruvboxAqua +hi! link clojureStringEscape GruvboxAqua +hi! link clojureException GruvboxRed + +hi! link clojureRegexp GruvboxAqua +hi! link clojureRegexpEscape GruvboxAqua +call s:HL('clojureRegexpCharClass', s:fg3, s:none, s:bold) +hi! link clojureRegexpMod clojureRegexpCharClass +hi! link clojureRegexpQuantifier clojureRegexpCharClass + +hi! link clojureParen GruvboxFg3 +hi! link clojureAnonArg GruvboxYellow +hi! link clojureVariable GruvboxBlue +hi! link clojureMacro GruvboxOrange + +hi! link clojureMeta GruvboxYellow +hi! link clojureDeref GruvboxYellow +hi! link clojureQuote GruvboxYellow +hi! link clojureUnquote GruvboxYellow + +" }}} +" C: {{{ + +hi! link cOperator GruvboxPurple +hi! link cStructure GruvboxOrange + +" }}} +" Python: {{{ + +hi! link pythonBuiltin GruvboxOrange +hi! link pythonBuiltinObj GruvboxOrange +hi! link pythonBuiltinFunc GruvboxOrange +hi! link pythonFunction GruvboxAqua +hi! link pythonDecorator GruvboxRed +hi! link pythonInclude GruvboxBlue +hi! link pythonImport GruvboxBlue +hi! link pythonRun GruvboxBlue +hi! link pythonCoding GruvboxBlue +hi! link pythonOperator GruvboxRed +hi! link pythonException GruvboxRed +hi! link pythonExceptions GruvboxPurple +hi! link pythonBoolean GruvboxPurple +hi! link pythonDot GruvboxFg3 +hi! link pythonConditional GruvboxRed +hi! link pythonRepeat GruvboxRed +hi! link pythonDottedName GruvboxGreenBold + +" }}} +" CSS: {{{ + +hi! link cssBraces GruvboxBlue +hi! link cssFunctionName GruvboxYellow +hi! link cssIdentifier GruvboxOrange +hi! link cssClassName GruvboxGreen +hi! link cssColor GruvboxBlue +hi! link cssSelectorOp GruvboxBlue +hi! link cssSelectorOp2 GruvboxBlue +hi! link cssImportant GruvboxGreen +hi! link cssVendor GruvboxFg1 + +hi! link cssTextProp GruvboxAqua +hi! link cssAnimationProp GruvboxAqua +hi! link cssUIProp GruvboxYellow +hi! link cssTransformProp GruvboxAqua +hi! link cssTransitionProp GruvboxAqua +hi! link cssPrintProp GruvboxAqua +hi! link cssPositioningProp GruvboxYellow +hi! link cssBoxProp GruvboxAqua +hi! link cssFontDescriptorProp GruvboxAqua +hi! link cssFlexibleBoxProp GruvboxAqua +hi! link cssBorderOutlineProp GruvboxAqua +hi! link cssBackgroundProp GruvboxAqua +hi! link cssMarginProp GruvboxAqua +hi! link cssListProp GruvboxAqua +hi! link cssTableProp GruvboxAqua +hi! link cssFontProp GruvboxAqua +hi! link cssPaddingProp GruvboxAqua +hi! link cssDimensionProp GruvboxAqua +hi! link cssRenderProp GruvboxAqua +hi! link cssColorProp GruvboxAqua +hi! link cssGeneratedContentProp GruvboxAqua + +" }}} +" JavaScript: {{{ + +hi! link javaScriptBraces GruvboxFg1 +hi! link javaScriptFunction GruvboxAqua +hi! link javaScriptIdentifier GruvboxRed +hi! link javaScriptMember GruvboxBlue +hi! link javaScriptNumber GruvboxPurple +hi! link javaScriptNull GruvboxPurple +hi! link javaScriptParens GruvboxFg3 + +" }}} +" YAJS: {{{ + +hi! link javascriptImport GruvboxAqua +hi! link javascriptExport GruvboxAqua +hi! link javascriptClassKeyword GruvboxAqua +hi! link javascriptClassExtends GruvboxAqua +hi! link javascriptDefault GruvboxAqua + +hi! link javascriptClassName GruvboxYellow +hi! link javascriptClassSuperName GruvboxYellow +hi! link javascriptGlobal GruvboxYellow + +hi! link javascriptEndColons GruvboxFg1 +hi! link javascriptFuncArg GruvboxFg1 +hi! link javascriptGlobalMethod GruvboxFg1 +hi! link javascriptNodeGlobal GruvboxFg1 +hi! link javascriptBOMWindowProp GruvboxFg1 +hi! link javascriptArrayMethod GruvboxFg1 +hi! link javascriptArrayStaticMethod GruvboxFg1 +hi! link javascriptCacheMethod GruvboxFg1 +hi! link javascriptDateMethod GruvboxFg1 +hi! link javascriptMathStaticMethod GruvboxFg1 + +" hi! link javascriptProp GruvboxFg1 +hi! link javascriptURLUtilsProp GruvboxFg1 +hi! link javascriptBOMNavigatorProp GruvboxFg1 +hi! link javascriptDOMDocMethod GruvboxFg1 +hi! link javascriptDOMDocProp GruvboxFg1 +hi! link javascriptBOMLocationMethod GruvboxFg1 +hi! link javascriptBOMWindowMethod GruvboxFg1 +hi! link javascriptStringMethod GruvboxFg1 + +hi! link javascriptVariable GruvboxOrange +" hi! link javascriptVariable GruvboxRed +" hi! link javascriptIdentifier GruvboxOrange +" hi! link javascriptClassSuper GruvboxOrange +hi! link javascriptIdentifier GruvboxOrange +hi! link javascriptClassSuper GruvboxOrange + +" hi! link javascriptFuncKeyword GruvboxOrange +" hi! link javascriptAsyncFunc GruvboxOrange +hi! link javascriptFuncKeyword GruvboxAqua +hi! link javascriptAsyncFunc GruvboxAqua +hi! link javascriptClassStatic GruvboxOrange + +hi! link javascriptOperator GruvboxRed +hi! link javascriptForOperator GruvboxRed +hi! link javascriptYield GruvboxRed +hi! link javascriptExceptions GruvboxRed +hi! link javascriptMessage GruvboxRed + +hi! link javascriptTemplateSB GruvboxAqua +hi! link javascriptTemplateSubstitution GruvboxFg1 + +" hi! link javascriptLabel GruvboxBlue +" hi! link javascriptObjectLabel GruvboxBlue +" hi! link javascriptPropertyName GruvboxBlue +hi! link javascriptLabel GruvboxFg1 +hi! link javascriptObjectLabel GruvboxFg1 +hi! link javascriptPropertyName GruvboxFg1 + +hi! link javascriptLogicSymbols GruvboxFg1 +hi! link javascriptArrowFunc GruvboxYellow + +hi! link javascriptDocParamName GruvboxFg4 +hi! link javascriptDocTags GruvboxFg4 +hi! link javascriptDocNotation GruvboxFg4 +hi! link javascriptDocParamType GruvboxFg4 +hi! link javascriptDocNamedParamType GruvboxFg4 + +hi! link javascriptBrackets GruvboxFg1 +hi! link javascriptDOMElemAttrs GruvboxFg1 +hi! link javascriptDOMEventMethod GruvboxFg1 +hi! link javascriptDOMNodeMethod GruvboxFg1 +hi! link javascriptDOMStorageMethod GruvboxFg1 +hi! link javascriptHeadersMethod GruvboxFg1 + +hi! link javascriptAsyncFuncKeyword GruvboxRed +hi! link javascriptAwaitFuncKeyword GruvboxRed + +" }}} +" PanglossJS: {{{ + +hi! link jsClassKeyword GruvboxAqua +hi! link jsExtendsKeyword GruvboxAqua +hi! link jsExportDefault GruvboxAqua +hi! link jsTemplateBraces GruvboxAqua +hi! link jsGlobalNodeObjects GruvboxFg1 +hi! link jsGlobalObjects GruvboxFg1 +hi! link jsFunction GruvboxAqua +hi! link jsFuncParens GruvboxFg3 +hi! link jsParens GruvboxFg3 +hi! link jsNull GruvboxPurple +hi! link jsUndefined GruvboxPurple +hi! link jsClassDefinition GruvboxYellow + +" }}} +" TypeScript: {{{ + +hi! link typeScriptReserved GruvboxAqua +hi! link typeScriptLabel GruvboxAqua +hi! link typeScriptFuncKeyword GruvboxAqua +hi! link typeScriptIdentifier GruvboxOrange +hi! link typeScriptBraces GruvboxFg1 +hi! link typeScriptEndColons GruvboxFg1 +hi! link typeScriptDOMObjects GruvboxFg1 +hi! link typeScriptAjaxMethods GruvboxFg1 +hi! link typeScriptLogicSymbols GruvboxFg1 +hi! link typeScriptDocSeeTag Comment +hi! link typeScriptDocParam Comment +hi! link typeScriptDocTags vimCommentTitle +hi! link typeScriptGlobalObjects GruvboxFg1 +hi! link typeScriptParens GruvboxFg3 +hi! link typeScriptOpSymbols GruvboxFg3 +hi! link typeScriptHtmlElemProperties GruvboxFg1 +hi! link typeScriptNull GruvboxPurple +hi! link typeScriptInterpolationDelimiter GruvboxAqua + +" }}} +" PureScript: {{{ + +hi! link purescriptModuleKeyword GruvboxAqua +hi! link purescriptModuleName GruvboxFg1 +hi! link purescriptWhere GruvboxAqua +hi! link purescriptDelimiter GruvboxFg4 +hi! link purescriptType GruvboxFg1 +hi! link purescriptImportKeyword GruvboxAqua +hi! link purescriptHidingKeyword GruvboxAqua +hi! link purescriptAsKeyword GruvboxAqua +hi! link purescriptStructure GruvboxAqua +hi! link purescriptOperator GruvboxBlue + +hi! link purescriptTypeVar GruvboxFg1 +hi! link purescriptConstructor GruvboxFg1 +hi! link purescriptFunction GruvboxFg1 +hi! link purescriptConditional GruvboxOrange +hi! link purescriptBacktick GruvboxOrange + +" }}} +" CoffeeScript: {{{ + +hi! link coffeeExtendedOp GruvboxFg3 +hi! link coffeeSpecialOp GruvboxFg3 +hi! link coffeeCurly GruvboxOrange +hi! link coffeeParen GruvboxFg3 +hi! link coffeeBracket GruvboxOrange + +" }}} +" Ruby: {{{ + +hi! link rubyStringDelimiter GruvboxGreen +hi! link rubyInterpolationDelimiter GruvboxAqua + +" }}} +" ObjectiveC: {{{ + +hi! link objcTypeModifier GruvboxRed +hi! link objcDirective GruvboxBlue + +" }}} +" Go: {{{ + +hi! link goDirective GruvboxAqua +hi! link goConstants GruvboxPurple +hi! link goDeclaration GruvboxRed +hi! link goDeclType GruvboxBlue +hi! link goBuiltins GruvboxOrange + +" }}} +" Lua: {{{ + +hi! link luaIn GruvboxRed +hi! link luaFunction GruvboxAqua +hi! link luaTable GruvboxOrange + +" }}} +" MoonScript: {{{ + +hi! link moonSpecialOp GruvboxFg3 +hi! link moonExtendedOp GruvboxFg3 +hi! link moonFunction GruvboxFg3 +hi! link moonObject GruvboxYellow + +" }}} +" Java: {{{ + +hi! link javaAnnotation GruvboxBlue +hi! link javaDocTags GruvboxAqua +hi! link javaCommentTitle vimCommentTitle +hi! link javaParen GruvboxFg3 +hi! link javaParen1 GruvboxFg3 +hi! link javaParen2 GruvboxFg3 +hi! link javaParen3 GruvboxFg3 +hi! link javaParen4 GruvboxFg3 +hi! link javaParen5 GruvboxFg3 +hi! link javaOperator GruvboxOrange + +hi! link javaVarArg GruvboxGreen + +" }}} +" Elixir: {{{ + +hi! link elixirDocString Comment + +hi! link elixirStringDelimiter GruvboxGreen +hi! link elixirInterpolationDelimiter GruvboxAqua + +hi! link elixirModuleDeclaration GruvboxYellow + +" }}} +" Scala: {{{ + +" NB: scala vim syntax file is kinda horrible +hi! link scalaNameDefinition GruvboxFg1 +hi! link scalaCaseFollowing GruvboxFg1 +hi! link scalaCapitalWord GruvboxFg1 +hi! link scalaTypeExtension GruvboxFg1 + +hi! link scalaKeyword GruvboxRed +hi! link scalaKeywordModifier GruvboxRed + +hi! link scalaSpecial GruvboxAqua +hi! link scalaOperator GruvboxFg1 + +hi! link scalaTypeDeclaration GruvboxYellow +hi! link scalaTypeTypePostDeclaration GruvboxYellow + +hi! link scalaInstanceDeclaration GruvboxFg1 +hi! link scalaInterpolation GruvboxAqua + +" }}} +" Markdown: {{{ + +call s:HL('markdownItalic', s:fg3, s:none, s:italic) + +hi! link markdownH1 GruvboxGreenBold +hi! link markdownH2 GruvboxGreenBold +hi! link markdownH3 GruvboxYellowBold +hi! link markdownH4 GruvboxYellowBold +hi! link markdownH5 GruvboxYellow +hi! link markdownH6 GruvboxYellow + +hi! link markdownCode GruvboxAqua +hi! link markdownCodeBlock GruvboxAqua +hi! link markdownCodeDelimiter GruvboxAqua + +hi! link markdownBlockquote GruvboxGray +hi! link markdownListMarker GruvboxGray +hi! link markdownOrderedListMarker GruvboxGray +hi! link markdownRule GruvboxGray +hi! link markdownHeadingRule GruvboxGray + +hi! link markdownUrlDelimiter GruvboxFg3 +hi! link markdownLinkDelimiter GruvboxFg3 +hi! link markdownLinkTextDelimiter GruvboxFg3 + +hi! link markdownHeadingDelimiter GruvboxOrange +hi! link markdownUrl GruvboxPurple +hi! link markdownUrlTitleDelimiter GruvboxGreen + +call s:HL('markdownLinkText', s:gray, s:none, s:underline) +hi! link markdownIdDeclaration markdownLinkText + +" }}} +" Haskell: {{{ + +" hi! link haskellType GruvboxYellow +" hi! link haskellOperators GruvboxOrange +" hi! link haskellConditional GruvboxAqua +" hi! link haskellLet GruvboxOrange +" +hi! link haskellType GruvboxFg1 +hi! link haskellIdentifier GruvboxFg1 +hi! link haskellSeparator GruvboxFg1 +hi! link haskellDelimiter GruvboxFg4 +hi! link haskellOperators GruvboxBlue +" +hi! link haskellBacktick GruvboxOrange +hi! link haskellStatement GruvboxOrange +hi! link haskellConditional GruvboxOrange + +hi! link haskellLet GruvboxAqua +hi! link haskellDefault GruvboxAqua +hi! link haskellWhere GruvboxAqua +hi! link haskellBottom GruvboxAqua +hi! link haskellBlockKeywords GruvboxAqua +hi! link haskellImportKeywords GruvboxAqua +hi! link haskellDeclKeyword GruvboxAqua +hi! link haskellDeriving GruvboxAqua +hi! link haskellAssocType GruvboxAqua + +hi! link haskellNumber GruvboxPurple +hi! link haskellPragma GruvboxPurple + +hi! link haskellString GruvboxGreen +hi! link haskellChar GruvboxGreen + +" }}} +" Json: {{{ + +hi! link jsonKeyword GruvboxGreen +hi! link jsonQuote GruvboxGreen +hi! link jsonBraces GruvboxFg1 +hi! link jsonString GruvboxFg1 + +" }}} + + +" Functions ------------------------------------------------------------------- +" Search Highlighting Cursor {{{ + +function! GruvboxHlsShowCursor() + call s:HL('Cursor', s:bg0, s:hls_cursor) +endfunction + +function! GruvboxHlsHideCursor() + call s:HL('Cursor', s:none, s:none, s:inverse) +endfunction + +" }}} + +" vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker: diff --git a/sources_non_forked/gruvbox/gruvbox_256palette.sh b/sources_non_forked/gruvbox/gruvbox_256palette.sh new file mode 100644 index 00000000..c7fd190e --- /dev/null +++ b/sources_non_forked/gruvbox/gruvbox_256palette.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +if [ "${TERM%%-*}" = "screen" ]; then + if [ -n "$TMUX" ]; then + printf "\033Ptmux;\033\033]4;236;rgb:32/30/2f\007\033\\" + printf "\033Ptmux;\033\033]4;234;rgb:1d/20/21\007\033\\" + + printf "\033Ptmux;\033\033]4;235;rgb:28/28/28\007\033\\" + printf "\033Ptmux;\033\033]4;237;rgb:3c/38/36\007\033\\" + printf "\033Ptmux;\033\033]4;239;rgb:50/49/45\007\033\\" + printf "\033Ptmux;\033\033]4;241;rgb:66/5c/54\007\033\\" + printf "\033Ptmux;\033\033]4;243;rgb:7c/6f/64\007\033\\" + + printf "\033Ptmux;\033\033]4;244;rgb:92/83/74\007\033\\" + printf "\033Ptmux;\033\033]4;245;rgb:92/83/74\007\033\\" + + printf "\033Ptmux;\033\033]4;228;rgb:f2/e5/bc\007\033\\" + printf "\033Ptmux;\033\033]4;230;rgb:f9/f5/d7\007\033\\" + + printf "\033Ptmux;\033\033]4;229;rgb:fb/f1/c7\007\033\\" + printf "\033Ptmux;\033\033]4;223;rgb:eb/db/b2\007\033\\" + printf "\033Ptmux;\033\033]4;250;rgb:d5/c4/a1\007\033\\" + printf "\033Ptmux;\033\033]4;248;rgb:bd/ae/93\007\033\\" + printf "\033Ptmux;\033\033]4;246;rgb:a8/99/84\007\033\\" + + printf "\033Ptmux;\033\033]4;167;rgb:fb/49/34\007\033\\" + printf "\033Ptmux;\033\033]4;142;rgb:b8/bb/26\007\033\\" + printf "\033Ptmux;\033\033]4;214;rgb:fa/bd/2f\007\033\\" + printf "\033Ptmux;\033\033]4;109;rgb:83/a5/98\007\033\\" + printf "\033Ptmux;\033\033]4;175;rgb:d3/86/9b\007\033\\" + printf "\033Ptmux;\033\033]4;108;rgb:8e/c0/7c\007\033\\" + printf "\033Ptmux;\033\033]4;208;rgb:fe/80/19\007\033\\" + + printf "\033Ptmux;\033\033]4;88;rgb:9d/00/06\007\033\\" + printf "\033Ptmux;\033\033]4;100;rgb:79/74/0e\007\033\\" + printf "\033Ptmux;\033\033]4;136;rgb:b5/76/14\007\033\\" + printf "\033Ptmux;\033\033]4;24;rgb:07/66/78\007\033\\" + printf "\033Ptmux;\033\033]4;96;rgb:8f/3f/71\007\033\\" + printf "\033Ptmux;\033\033]4;66;rgb:42/7b/58\007\033\\" + printf "\033Ptmux;\033\033]4;130;rgb:af/3a/03\007\033\\" + else + printf "\033P\033]4;236;rgb:32/30/2f\007\033\\" + printf "\033P\033]4;234;rgb:1d/20/21\007\033\\" + + printf "\033P\033]4;235;rgb:28/28/28\007\033\\" + printf "\033P\033]4;237;rgb:3c/38/36\007\033\\" + printf "\033P\033]4;239;rgb:50/49/45\007\033\\" + printf "\033P\033]4;241;rgb:66/5c/54\007\033\\" + printf "\033P\033]4;243;rgb:7c/6f/64\007\033\\" + + printf "\033P\033]4;244;rgb:92/83/74\007\033\\" + printf "\033P\033]4;245;rgb:92/83/74\007\033\\" + + printf "\033P\033]4;228;rgb:f2/e5/bc\007\033\\" + printf "\033P\033]4;230;rgb:f9/f5/d7\007\033\\" + + printf "\033P\033]4;229;rgb:fb/f1/c7\007\033\\" + printf "\033P\033]4;223;rgb:eb/db/b2\007\033\\" + printf "\033P\033]4;250;rgb:d5/c4/a1\007\033\\" + printf "\033P\033]4;248;rgb:bd/ae/93\007\033\\" + printf "\033P\033]4;246;rgb:a8/99/84\007\033\\" + + printf "\033P\033]4;167;rgb:fb/49/34\007\033\\" + printf "\033P\033]4;142;rgb:b8/bb/26\007\033\\" + printf "\033P\033]4;214;rgb:fa/bd/2f\007\033\\" + printf "\033P\033]4;109;rgb:83/a5/98\007\033\\" + printf "\033P\033]4;175;rgb:d3/86/9b\007\033\\" + printf "\033P\033]4;108;rgb:8e/c0/7c\007\033\\" + printf "\033P\033]4;208;rgb:fe/80/19\007\033\\" + + printf "\033P\033]4;88;rgb:9d/00/06\007\033\\" + printf "\033P\033]4;100;rgb:79/74/0e\007\033\\" + printf "\033P\033]4;136;rgb:b5/76/14\007\033\\" + printf "\033P\033]4;24;rgb:07/66/78\007\033\\" + printf "\033P\033]4;96;rgb:8f/3f/71\007\033\\" + printf "\033P\033]4;66;rgb:42/7b/58\007\033\\" + printf "\033P\033]4;130;rgb:af/3a/03\007\033\\" + fi + +elif [ "$TERM" != "linux" ] && [ "$TERM" != "vt100" ] && [ "$TERM" != "vt220" ]; then + + printf "\033]4;236;rgb:32/30/2f\033\\" + printf "\033]4;234;rgb:1d/20/21\033\\" + + printf "\033]4;235;rgb:28/28/28\033\\" + printf "\033]4;237;rgb:3c/38/36\033\\" + printf "\033]4;239;rgb:50/49/45\033\\" + printf "\033]4;241;rgb:66/5c/54\033\\" + printf "\033]4;243;rgb:7c/6f/64\033\\" + + printf "\033]4;244;rgb:92/83/74\033\\" + printf "\033]4;245;rgb:92/83/74\033\\" + + printf "\033]4;228;rgb:f2/e5/bc\033\\" + printf "\033]4;230;rgb:f9/f5/d7\033\\" + + printf "\033]4;229;rgb:fb/f1/c7\033\\" + printf "\033]4;223;rgb:eb/db/b2\033\\" + printf "\033]4;250;rgb:d5/c4/a1\033\\" + printf "\033]4;248;rgb:bd/ae/93\033\\" + printf "\033]4;246;rgb:a8/99/84\033\\" + + printf "\033]4;167;rgb:fb/49/34\033\\" + printf "\033]4;142;rgb:b8/bb/26\033\\" + printf "\033]4;214;rgb:fa/bd/2f\033\\" + printf "\033]4;109;rgb:83/a5/98\033\\" + printf "\033]4;175;rgb:d3/86/9b\033\\" + printf "\033]4;108;rgb:8e/c0/7c\033\\" + printf "\033]4;208;rgb:fe/80/19\033\\" + + printf "\033]4;88;rgb:9d/00/06\033\\" + printf "\033]4;100;rgb:79/74/0e\033\\" + printf "\033]4;136;rgb:b5/76/14\033\\" + printf "\033]4;24;rgb:07/66/78\033\\" + printf "\033]4;96;rgb:8f/3f/71\033\\" + printf "\033]4;66;rgb:42/7b/58\033\\" + printf "\033]4;130;rgb:af/3a/03\033\\" +fi diff --git a/sources_non_forked/gruvbox/gruvbox_256palette_osx.sh b/sources_non_forked/gruvbox/gruvbox_256palette_osx.sh new file mode 100644 index 00000000..ad5111a1 --- /dev/null +++ b/sources_non_forked/gruvbox/gruvbox_256palette_osx.sh @@ -0,0 +1,116 @@ +#!/bin/sh + +if [ "${TERM%%-*}" = "screen" ]; then + if [ -n "$TMUX" ]; then + printf "\033Ptmux;\033\033]4;236;rgb:26/24/23\007\033\\" + printf "\033Ptmux;\033\033]4;234;rgb:16/18/19\007\033\\" + + printf "\033Ptmux;\033\033]4;235;rgb:1e/1e/1e\007\033\\" + printf "\033Ptmux;\033\033]4;237;rgb:2e/2a/29\007\033\\" + printf "\033Ptmux;\033\033]4;239;rgb:3f/39/35\007\033\\" + printf "\033Ptmux;\033\033]4;241;rgb:53/4a/42\007\033\\" + printf "\033Ptmux;\033\033]4;243;rgb:68/5c/51\007\033\\" + + printf "\033Ptmux;\033\033]4;244;rgb:7f/70/61\007\033\\" + printf "\033Ptmux;\033\033]4;245;rgb:7f/70/61\007\033\\" + + printf "\033Ptmux;\033\033]4;228;rgb:ef/df/ae\007\033\\" + printf "\033Ptmux;\033\033]4;230;rgb:f8/f4/cd\007\033\\" + + printf "\033Ptmux;\033\033]4;229;rgb:fa/ee/bb\007\033\\" + printf "\033Ptmux;\033\033]4;223;rgb:e6/d4/a3\007\033\\" + printf "\033Ptmux;\033\033]4;250;rgb:cb/b8/90\007\033\\" + printf "\033Ptmux;\033\033]4;248;rgb:af/9f/81\007\033\\" + printf "\033Ptmux;\033\033]4;246;rgb:97/87/71\007\033\\" + + printf "\033Ptmux;\033\033]4;167;rgb:f7/30/28\007\033\\" + printf "\033Ptmux;\033\033]4;142;rgb:aa/b0/1e\007\033\\" + printf "\033Ptmux;\033\033]4;214;rgb:f7/b1/25\007\033\\" + printf "\033Ptmux;\033\033]4;109;rgb:71/95/86\007\033\\" + printf "\033Ptmux;\033\033]4;175;rgb:c7/70/89\007\033\\" + printf "\033Ptmux;\033\033]4;108;rgb:7d/b6/69\007\033\\" + printf "\033Ptmux;\033\033]4;208;rgb:fb/6a/16\007\033\\" + + printf "\033Ptmux;\033\033]4;88;rgb:89/00/09\007\033\\" + printf "\033Ptmux;\033\033]4;100;rgb:66/62/0d\007\033\\" + printf "\033Ptmux;\033\033]4;136;rgb:a5/63/11\007\033\\" + printf "\033Ptmux;\033\033]4;24;rgb:0e/53/65\007\033\\" + printf "\033Ptmux;\033\033]4;96;rgb:7b/2b/5e\007\033\\" + printf "\033Ptmux;\033\033]4;66;rgb:35/6a/46\007\033\\" + printf "\033Ptmux;\033\033]4;130;rgb:9d/28/07\007\033\\" + else + printf "\033P\033]4;236;rgb:26/24/23\007\033\\" + printf "\033P\033]4;234;rgb:16/18/19\007\033\\" + + printf "\033P\033]4;235;rgb:1e/1e/1e\007\033\\" + printf "\033P\033]4;237;rgb:2e/2a/29\007\033\\" + printf "\033P\033]4;239;rgb:3f/39/35\007\033\\" + printf "\033P\033]4;241;rgb:53/4a/42\007\033\\" + printf "\033P\033]4;243;rgb:68/5c/51\007\033\\" + + printf "\033P\033]4;244;rgb:7f/70/61\007\033\\" + printf "\033P\033]4;245;rgb:7f/70/61\007\033\\" + + printf "\033P\033]4;228;rgb:ef/df/ae\007\033\\" + printf "\033P\033]4;230;rgb:f8/f4/cd\007\033\\" + + printf "\033P\033]4;229;rgb:fa/ee/bb\007\033\\" + printf "\033P\033]4;223;rgb:e6/d4/a3\007\033\\" + printf "\033P\033]4;250;rgb:cb/b8/90\007\033\\" + printf "\033P\033]4;248;rgb:af/9f/81\007\033\\" + printf "\033P\033]4;246;rgb:97/87/71\007\033\\" + + printf "\033P\033]4;167;rgb:f7/30/28\007\033\\" + printf "\033P\033]4;142;rgb:aa/b0/1e\007\033\\" + printf "\033P\033]4;214;rgb:f7/b1/25\007\033\\" + printf "\033P\033]4;109;rgb:71/95/86\007\033\\" + printf "\033P\033]4;175;rgb:c7/70/89\007\033\\" + printf "\033P\033]4;108;rgb:7d/b6/69\007\033\\" + printf "\033P\033]4;208;rgb:fb/6a/16\007\033\\" + + printf "\033P\033]4;88;rgb:89/00/09\007\033\\" + printf "\033P\033]4;100;rgb:66/62/0d\007\033\\" + printf "\033P\033]4;136;rgb:a5/63/11\007\033\\" + printf "\033P\033]4;24;rgb:0e/53/65\007\033\\" + printf "\033P\033]4;96;rgb:7b/2b/5e\007\033\\" + printf "\033P\033]4;66;rgb:35/6a/46\007\033\\" + printf "\033P\033]4;130;rgb:9d/28/07\007\033\\" + fi +else + printf "\033]4;236;rgb:26/24/23\033\\" + printf "\033]4;234;rgb:16/18/19\033\\" + + printf "\033]4;235;rgb:1e/1e/1e\033\\" + printf "\033]4;237;rgb:2e/2a/29\033\\" + printf "\033]4;239;rgb:3f/39/35\033\\" + printf "\033]4;241;rgb:53/4a/42\033\\" + printf "\033]4;243;rgb:68/5c/51\033\\" + + printf "\033]4;244;rgb:7f/70/61\033\\" + printf "\033]4;245;rgb:7f/70/61\033\\" + + printf "\033]4;228;rgb:ef/df/ae\033\\" + printf "\033]4;230;rgb:f8/f4/cd\033\\" + + printf "\033]4;229;rgb:fa/ee/bb\033\\" + printf "\033]4;223;rgb:e6/d4/a3\033\\" + printf "\033]4;250;rgb:cb/b8/90\033\\" + printf "\033]4;248;rgb:af/9f/81\033\\" + printf "\033]4;246;rgb:97/87/71\033\\" + + printf "\033]4;167;rgb:f7/30/28\033\\" + printf "\033]4;142;rgb:aa/b0/1e\033\\" + printf "\033]4;214;rgb:f7/b1/25\033\\" + printf "\033]4;109;rgb:71/95/86\033\\" + printf "\033]4;175;rgb:c7/70/89\033\\" + printf "\033]4;108;rgb:7d/b6/69\033\\" + printf "\033]4;208;rgb:fb/6a/16\033\\" + + printf "\033]4;88;rgb:89/00/09\033\\" + printf "\033]4;100;rgb:66/62/0d\033\\" + printf "\033]4;136;rgb:a5/63/11\033\\" + printf "\033]4;24;rgb:0e/53/65\033\\" + printf "\033]4;96;rgb:7b/2b/5e\033\\" + printf "\033]4;66;rgb:35/6a/46\033\\" + printf "\033]4;130;rgb:9d/28/07\033\\" +fi diff --git a/sources_non_forked/gruvbox/package.json b/sources_non_forked/gruvbox/package.json new file mode 100644 index 00000000..355c1808 --- /dev/null +++ b/sources_non_forked/gruvbox/package.json @@ -0,0 +1,10 @@ +{ + "name": "gruvbox", + "version": "2.0.0", + "repository": "git@github.com:morhetz/gruvbox.git", + "author": "Pavel Pertsev ", + "license": "MIT", + "vim": { + "opt": true + } +} diff --git a/sources_non_forked/lightline-ale/LICENSE b/sources_non_forked/lightline-ale/LICENSE new file mode 100644 index 00000000..ef1d8a84 --- /dev/null +++ b/sources_non_forked/lightline-ale/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2017-2021, Maxim Baz + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/sources_non_forked/lightline-ale/README.md b/sources_non_forked/lightline-ale/README.md new file mode 100644 index 00000000..78a1e853 --- /dev/null +++ b/sources_non_forked/lightline-ale/README.md @@ -0,0 +1,122 @@ +# lightline-ale + +This plugin provides [ALE](https://github.com/w0rp/ale) indicator for the [lightline](https://github.com/itchyny/lightline.vim) vim plugin. + +![screenshot](./screenshot.png) + +## Table Of Contents + +- [Installation](#installation) +- [Integration](#integration) +- [Configuration](#configuration) +- [License](#license) + +## Installation + +Install using a plugin manager of your choice, for example: + +```viml +call dein#add('dense-analysis/ale') " Dependency: linter +call dein#add('itchyny/lightline.vim') " Dependency: status line +call dein#add('maximbaz/lightline-ale') +``` + +## Integration + +1. Register the components: + +```viml +let g:lightline = {} + +let g:lightline.component_expand = { + \ 'linter_checking': 'lightline#ale#checking', + \ 'linter_infos': 'lightline#ale#infos', + \ 'linter_warnings': 'lightline#ale#warnings', + \ 'linter_errors': 'lightline#ale#errors', + \ 'linter_ok': 'lightline#ale#ok', + \ } +``` + +2. Set color to the components: + +```viml +let g:lightline.component_type = { + \ 'linter_checking': 'right', + \ 'linter_infos': 'right', + \ 'linter_warnings': 'warning', + \ 'linter_errors': 'error', + \ 'linter_ok': 'right', + \ } +``` + +3. Add the components to the lightline, for example to the right side: + +```viml +let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ]] } +``` + +3.1. Lineinfo, fileformat, etc. have to be added additionaly. Final example: + +```viml +let g:lightline.active = { + \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], + \ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype'] ] } + +``` + +## Configuration + +##### `g:lightline#ale#indicator_checking` + +The indicator to use when ALE is in progress. Default is `Linting...`. + +##### `g:lightline#ale#indicator_infos` + +The indicator to use when there are infos. Default is `I:`. + +##### `g:lightline#ale#indicator_warnings` + +The indicator to use when there are warnings. Default is `W:`. + +##### `g:lightline#ale#indicator_errors` + +The indicator to use when there are errors. Default is `E:`. + +##### `g:lightline#ale#indicator_ok` + +The indicator to use when there are no warnings or errors. Default is `OK`. + +### Using icons as indicators + +If you would like to replace the default indicators with symbols like on the screenshot, then you'll need to ensure you have some "iconic fonts" installed, such as [Font Awesome](https://fontawesome.com). A common alternative is to replace your primary font with one of the [Patched Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), which saves you from having to install multiple fonts. + +The following icons from the Font Awesome font are used in the screenshot: + +- Checking: [f110](https://fontawesome.com/icons/spinner) +- Infos: [f129](https://fontawesome.com/icons/info) +- Warnings: [f071](https://fontawesome.com/icons/exclamation-triangle) +- Errors: [f05e](https://fontawesome.com/icons/ban) +- OK: [f00c](https://fontawesome.com/icons/check) (although I prefer to disable this component) + +To specify icons in the configuration, use their unicode codes as `"\uXXXX"` (make sure to wrap them in double quotes). Alternatively copy the icons from a font website, or type \u\<4-digit-unicode\> or \U\<8-digit-unicode\> to insert the literal characters. + +See the code points here: + +- Font Awesome: https://fontawesome.com/icons +- Nerd Fonts: https://github.com/ryanoasis/nerd-fonts#glyph-sets + +Here's the configuration snippet used in the screenshot: + +```viml +let g:lightline#ale#indicator_checking = "\uf110" +let g:lightline#ale#indicator_infos = "\uf129" +let g:lightline#ale#indicator_warnings = "\uf071" +let g:lightline#ale#indicator_errors = "\uf05e" +let g:lightline#ale#indicator_ok = "\uf00c" +``` + +## License + +Released under the [ISC License](LICENSE) diff --git a/sources_non_forked/lightline-ale/autoload/lightline/ale.vim b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim new file mode 100644 index 00000000..c04f5ab7 --- /dev/null +++ b/sources_non_forked/lightline-ale/autoload/lightline/ale.vim @@ -0,0 +1,58 @@ +let s:indicator_infos = get(g:, 'lightline#ale#indicator_infos', 'I: ') +let s:indicator_warnings = get(g:, 'lightline#ale#indicator_warnings', 'W: ') +let s:indicator_errors = get(g:, 'lightline#ale#indicator_errors', 'E: ') +let s:indicator_ok = get(g:, 'lightline#ale#indicator_ok', 'OK') +let s:indicator_checking = get(g:, 'lightline#ale#indicator_checking', 'Linting...') + + +"""""""""""""""""""""" +" Lightline components + +function! lightline#ale#infos() abort + if !lightline#ale#linted() + return '' + endif + let l:counts = ale#statusline#Count(bufnr('')) + return l:counts.info == 0 ? '' : printf(s:indicator_infos . '%d', l:counts.info) +endfunction + +function! lightline#ale#warnings() abort + if !lightline#ale#linted() + return '' + endif + let l:counts = ale#statusline#Count(bufnr('')) + let l:all_warnings = l:counts.warning + l:counts.style_warning + return l:all_warnings == 0 ? '' : printf(s:indicator_warnings . '%d', all_warnings) +endfunction + +function! lightline#ale#errors() abort + if !lightline#ale#linted() + return '' + endif + let l:counts = ale#statusline#Count(bufnr('')) + let l:all_errors = l:counts.error + l:counts.style_error + return l:all_errors == 0 ? '' : printf(s:indicator_errors . '%d', all_errors) +endfunction + +function! lightline#ale#ok() abort + if !lightline#ale#linted() + return '' + endif + let l:counts = ale#statusline#Count(bufnr('')) + return l:counts.total == 0 ? s:indicator_ok : '' +endfunction + +function! lightline#ale#checking() abort + return ale#engine#IsCheckingBuffer(bufnr('')) ? s:indicator_checking : '' +endfunction + + +"""""""""""""""""" +" Helper functions + +function! lightline#ale#linted() abort + return get(g:, 'ale_enabled', 0) == 1 + \ && getbufvar(bufnr(''), 'ale_enabled', 1) + \ && getbufvar(bufnr(''), 'ale_linted', 0) > 0 + \ && ale#engine#IsCheckingBuffer(bufnr('')) == 0 +endfunction diff --git a/sources_non_forked/lightline-ale/plugin/lightline/ale.vim b/sources_non_forked/lightline-ale/plugin/lightline/ale.vim new file mode 100644 index 00000000..fe0237cb --- /dev/null +++ b/sources_non_forked/lightline-ale/plugin/lightline/ale.vim @@ -0,0 +1,6 @@ +augroup lightline#ale + autocmd! + autocmd User ALEJobStarted call lightline#update() + autocmd User ALELintPost call lightline#update() + autocmd User ALEFixPost call lightline#update() +augroup END diff --git a/sources_non_forked/lightline-ale/screenshot.png b/sources_non_forked/lightline-ale/screenshot.png new file mode 100644 index 00000000..642caea4 Binary files /dev/null and b/sources_non_forked/lightline-ale/screenshot.png differ diff --git a/sources_non_forked/lightline.vim/.github/workflows/ci.yaml b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml new file mode 100644 index 00000000..d1ccd883 --- /dev/null +++ b/sources_non_forked/lightline.vim/.github/workflows/ci.yaml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + vim: + - v9.0.0000 + - v8.2.0000 + - v8.1.0000 + - v8.0.0000 + - v7.4 + - v7.3 + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Checkout vim-themis + uses: actions/checkout@v3 + with: + repository: thinca/vim-themis + path: vim-themis + ref: v1.6.0 + - name: Setup Vim + uses: rhysd/action-setup-vim@v1 + id: vim + with: + version: ${{ matrix.vim }} + - name: Test + env: + THEMIS_VIM: ${{ steps.vim.outputs.executable }} + run: ./vim-themis/bin/themis --reporter spec diff --git a/sources_non_forked/lightline.vim/.gitignore b/sources_non_forked/lightline.vim/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/lightline.vim/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/lightline.vim/LICENSE b/sources_non_forked/lightline.vim/LICENSE new file mode 100644 index 00000000..93dc399e --- /dev/null +++ b/sources_non_forked/lightline.vim/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013-2022 itchyny + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sources_non_forked/lightline.vim/README.md b/sources_non_forked/lightline.vim/README.md new file mode 100644 index 00000000..c2975e05 --- /dev/null +++ b/sources_non_forked/lightline.vim/README.md @@ -0,0 +1,433 @@ +# lightline.vim +A light and configurable statusline/tabline plugin for Vim + +https://github.com/itchyny/lightline.vim + +### powerline (default) + +![lightline.vim - powerline](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerline.png) + +### wombat + +![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) + +### solarized (`background=dark`) + +![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) + +### solarized (`background=light`) + +![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) + +### PaperColor (`background=dark`) + +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) + +### PaperColor (`background=light`) + +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) + +### one (`background=dark`) + +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) + +### one (`background=light`) + +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) + +For screenshots of all available colorshemes, see [this file](colorscheme.md). + +## Why yet another clone of powerline? ++ [vim-powerline](https://github.com/Lokaltog/vim-powerline) is a nice plugin, but deprecated. ++ [powerline](https://github.com/powerline/powerline) is a nice plugin, but difficult to configure. ++ [vim-airline](https://github.com/vim-airline/vim-airline) is a nice plugin, but it uses too many functions of other plugins, which should be done by users in `.vimrc`. + +## Spirit of this plugin ++ Minimalism. The core script is very small to achieve enough functions as a statusline plugin. ++ Configurability. You can create your own component and easily add to the statusline and the tabline. ++ Orthogonality. The plugin does not rely on the implementation of other plugins. Such plugin crossing settings should be configured by users. + +## Installation +### [Vim packages](https://vimhelp.org/repeat.txt.html#packages) (since Vim 7.4.1528) +1. Clone the plugin with the following command. + + git clone https://github.com/itchyny/lightline.vim ~/.vim/pack/plugins/start/lightline + +### [Pathogen](https://github.com/tpope/vim-pathogen) +1. Install with the following command. + + git clone https://github.com/itchyny/lightline.vim ~/.vim/bundle/lightline.vim + +2. Generate help tags with `:Helptags`. + +### [Vundle](https://github.com/VundleVim/Vundle.vim) +1. Add the following configuration to your `.vimrc`. + + Plugin 'itchyny/lightline.vim' + +2. Install with `:PluginInstall`. + +### [NeoBundle](https://github.com/Shougo/neobundle.vim) +1. Add the following configuration to your `.vimrc`. + + NeoBundle 'itchyny/lightline.vim' + +2. Install with `:NeoBundleInstall`. + +### [vim-plug](https://github.com/junegunn/vim-plug) +1. Add the following configuration to your `.vimrc`. + + Plug 'itchyny/lightline.vim' + +2. Install with `:PlugInstall`. + +### [dein.vim](https://github.com/Shougo/dein.vim) +1. Add the following configuration to your `.vimrc`. + + call dein#add('itchyny/lightline.vim') + +2. Install with `:call dein#install()` + +## Introduction +After installing this plugin, you restart the editor and will get a cool statusline. +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/1.png) + +The color of the statusline changes due to the mode of Vim. Try typing something, selecting in visual mode and replacing some texts. + +If the statusline looks like +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/21.png) + +add the following configuration to your `.vimrc`. +```vim +set laststatus=2 +``` + +If the statusline is not coloured like +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/20.png) + +then modify `TERM` in your shell configuration (`.zshrc` for example) +```sh +export TERM=xterm-256color +``` +and then add the following configuration to your `.vimrc`. +```vim +if !has('gui_running') + set t_Co=256 +endif +``` + +Your statusline appears to work correctly? If yes, great, thanks for choosing lightline.vim! If no, please file an issue report to the [issue tracker](https://github.com/itchyny/lightline.vim/issues). + +By the way, `-- INSERT --` is unnecessary anymore because the mode information is displayed in the statusline. +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/13.png) +If you want to get rid of it, configure as follows. +```vim +set noshowmode +``` + +## Colorscheme configuration +The lightline.vim plugin provides multiple colorschemes to meet your editor colorscheme. +Do not be confused, editor colorscheme rules how codes look like in buffers and lightline.vim has independent colorscheme feature, which rules how the statusline looks like. + +If you are using wombat colorscheme, add the following setting to your `.vimrc`, +```vim +let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +``` +restart Vim and the statusline looks like: + +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/2.png) + +If the colors of the statusline do not change, move the settings of `g:lightline` before setting the editor colorscheme. + +There are many lightline colorschemes available as screenshots shown above. See `:h g:lightline.colorscheme` for the complete list. + +## Advanced configuration +The default appearance of lightline.vim is carefully designed that the tutorial is enough here for most people. +So please read this section if you really want to configure and enjoy the configurability of lightline.vim. + +Sometimes people want to display information of other plugins. +For example git branch information, syntax check errors and some statuses of plugins. + +The lightline.vim plugin does not provide any plugin integration by default. +This plugin considers orthogonality to be one of the important ideas, which means that the plugin does not rely on implementation of other plugins. +Once a plugin starts to integrate with some famous plugins, it should be kept updated to follow the changes of the plugins, and should accept integration requests with new plugins and it will suffer from performance regression due to plugin availability checks. + +Instead, lightline.vim provides a simple API that user can easily integrate with other plugins. +Once you understand how to configure and how it will be displayed in the statusline, you can also tell how to integrate with your favorite plugins. + +Let's start to configure the appearance. +The statusline is composed of multiple components. +It shows the current mode, filename, modified status on the left, and file format, encoding, filetype and cursor positions on the right. +So in order to add something in the statusline, you firstly create a new component and specify the place. + +This is the hello world of lightline.vim component. +```vim +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'readonly', 'filename', 'modified', 'helloworld' ] ] + \ }, + \ 'component': { + \ 'helloworld': 'Hello, world!' + \ }, + \ } +``` +The statusline will look like: +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/3.png) + +You have succeeded in displaying `Hello, world!` in the statusline. +The `helloworld` component is added to `g:lightline.active.left` and its content is configured in `g:lightline.component`. +The component contents are simply added to `&statusline`. +Try `:echo &statusline`, it might be a little bit complicated, but you will find `Hello, world!` somewhere. + +You can use `'statusline'` syntax for lightline.vim components. +Consult `:h 'statusline'` to see what's available here. +For example, if you want to print the value of character under the cursor in hexadecimal, configure as +```vim +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'readonly', 'filename', 'modified', 'charvaluehex' ] ] + \ }, + \ 'component': { + \ 'charvaluehex': '0x%B' + \ }, + \ } +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/4.png) + +You want the character value information on the right hand side? OK, configure as +```vim +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype', 'charvaluehex' ] ] + \ }, + \ 'component': { + \ 'charvaluehex': '0x%B' + \ }, + \ } +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/5.png) + +We have learned how to add a simple component. + +- See `:h 'statusline'` to check the statusline flags. +- Add a new component to `g:lightline.component`. +- Add the component name to `g:lightline.active.left` or `g:lightline.active.right`. + +You can also configure the statusline of inactive buffers by adding the component to `g:lightline.inactive.left` or `g:lightline.inactive.right`. + + +Now let's add some integrations with other plugin. +The name of the git branch is important these days. +But lightline.vim does not provide this information by default because it is also one of plugin crossing configurations, and not all people want the integration. + +In order to show the branch name in the statusline, install some plugins which provide the branch information. +The [vim-fugitive](https://github.com/tpope/vim-fugitive) plugin is a famous plugin so let's integrate lightline.vim with it. +If you don't like to install full git integration but just want to display the branch name in the statusline, you can use the [vim-gitbranch](https://github.com/itchyny/vim-gitbranch) plugin which provides `gitbranch#name` function. +```vim +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/6.png) + +Okay, now the statusline shows that we are coding at the master branch. +What do we learn from this example? + +- Find out the function which is suitable to use in the statusline. +- Create a function component. The previous `charvaluehex` component has `'statusline'` item configuration and registered in `g:lightline.component`. In the current example, we register the name of the function in `g:lightline.component_function`. It should return the string to be displayed in the statusline. +- Add the component name `gitbranch` to `g:lightline.active.left` or `g:lightline.active.right`. + + +Here we have leaned two kinds of components. + +- component: it has a `%`-prefixed item which you can find the meaning at `:h 'statusline'`. All the default components of lightline.vim are components in this style. See the default components at `:h g:lightline.component`. +- function component: the name of functions are registered. The function is called again and again so be careful not to register a heavy function. See the help with `:h g:lightline.component_function`. + + +The function component is an important design for the configurability of lightline.vim. +By providing the configuration interface via functions, you can adjust the statusline information as you wish. +For the proof, let's look into some configuration examples in Q&A style. + +### Can I hide the readonly component in the help buffer? +Yes, create a function component for `readonly`. +The configuration of function component has priority over the default component. +```vim +let g:lightline = { + \ 'component_function': { + \ 'readonly': 'LightlineReadonly', + \ }, + \ } + +function! LightlineReadonly() + return &readonly && &filetype !=# 'help' ? 'RO' : '' +endfunction +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/7.png) + +### Can I hide the readonly component in other plugins buffer? +Yes, modify the `LightlineReadonly` function as you wish. +```vim +function! LightlineReadonly() + return &readonly && &filetype !~# '\v(help|vimfiler|unite)' ? 'RO' : '' +endfunction + +let g:unite_force_overwrite_statusline = 0 +let g:vimfiler_force_overwrite_statusline = 0 +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/8.png) + +### Can I display the plugin information at the filename component? +Yes, overwrite the filename component. +```vim +let g:lightline = { + \ 'component_function': { + \ 'filename': 'LightlineFilename', + \ }, + \ } + +function! LightlineFilename() + return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &filetype ==# 'unite' ? unite#get_status_string() : + \ &filetype ==# 'vimshell' ? vimshell#get_status_string() : + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]' +endfunction + +let g:unite_force_overwrite_statusline = 0 +let g:vimfiler_force_overwrite_statusline = 0 +let g:vimshell_force_overwrite_statusline = 0 +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/9.png) + +### Can I display the plugin name at the mode component? +Yes, overwrite the mode component. +```vim +let g:lightline = { + \ 'component_function': { + \ 'mode': 'LightlineMode', + \ }, + \ } + +function! LightlineMode() + return expand('%:t') =~# '^__Tagbar__' ? 'Tagbar': + \ expand('%:t') ==# 'ControlP' ? 'CtrlP' : + \ &filetype ==# 'unite' ? 'Unite' : + \ &filetype ==# 'vimfiler' ? 'VimFiler' : + \ &filetype ==# 'vimshell' ? 'VimShell' : + \ lightline#mode() +endfunction +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/10.png) + +### Can I trim the file format and encoding information on narrow windows? +Yes, check `winwidth(0)` and return empty string with some threshold. +```vim +let g:lightline = { + \ 'component_function': { + \ 'fileformat': 'LightlineFileformat', + \ 'filetype': 'LightlineFiletype', + \ }, + \ } + +function! LightlineFileformat() + return winwidth(0) > 70 ? &fileformat : '' +endfunction + +function! LightlineFiletype() + return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : '' +endfunction +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/11.png) + +### Can I trim the bar between the filename and modified sign? +Yes, by joining the two components. +```vim +let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'readonly', 'filename' ] ], + \ }, + \ 'component_function': { + \ 'filename': 'LightlineFilename', + \ }, + \ } + +function! LightlineFilename() + let filename = expand('%:t') !=# '' ? expand('%:t') : '[No Name]' + let modified = &modified ? ' +' : '' + return filename . modified +endfunction +``` +![lightline.vim - tutorial](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/tutorial/12.png) + +You can control the visibility and contents by writing simple functions. +Now you notice how much function component is important for the configurability of lightline.vim. + +### more tips +#### Mode names are too long. Can I use shorter mode names? +Yes, configure `g:lightline.mode_map`. +```vim +let g:lightline = { + \ 'mode_map': { + \ 'n' : 'N', + \ 'i' : 'I', + \ 'R' : 'R', + \ 'v' : 'V', + \ 'V' : 'VL', + \ "\": 'VB', + \ 'c' : 'C', + \ 's' : 'S', + \ 'S' : 'SL', + \ "\": 'SB', + \ 't': 'T', + \ }, + \ } +``` + +#### How can I truncate the components from the right in narrow windows? +Please include `%<` to one of the right components. +```vim +let g:lightline = { + \ 'component': { + \ 'lineinfo': '%3l:%-2v%<', + \ }, + \ } +``` + +#### Where can I find the default components? +See `:h g:lightline.component`. + +## Note for developers of other plugins +Appearance consistency matters. + +The statusline is an important space for Vim users. +Overwriting the statusline forcibly in your plugin is not a good idea. +It is not hospitality, but just an annoying feature. +If your plugin has such a feature, add an option to be modest. + +A good design is as follows. +Firstly, give the users a clue to judge which buffer is the one your plugin creates. +The filename is a manner and the filetype is another. +Then, export a function which is useful to be shown in the statusline. +Lastly, for advanced users, set important information in buffer variables so that the users can obtain the condition of the plugin easily. + +## Author +itchyny (https://github.com/itchyny) + +## License +This software is released under the MIT License, see LICENSE. diff --git a/sources_non_forked/lightline.vim/autoload/lightline.vim b/sources_non_forked/lightline.vim/autoload/lightline.vim new file mode 100644 index 00000000..e1f09ca4 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline.vim @@ -0,0 +1,485 @@ +" ============================================================================= +" Filename: autoload/lightline.vim +" Author: itchyny +" License: MIT License +" Last Change: 2021/11/21 22:54:46. +" ============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:_ = 1 " 1: uninitialized, 2: disabled + +function! lightline#update() abort + if s:skip() | return | endif + if s:_ + if s:_ == 2 | return | endif + call lightline#init() + call lightline#colorscheme() + endif + if s:lightline.enable.statusline + let w = winnr() + let s = winnr('$') == 1 && w > 0 ? [lightline#statusline(0)] : [lightline#statusline(0), lightline#statusline(1)] + for n in range(1, winnr('$')) + call setwinvar(n, '&statusline', s[n!=w]) + endfor + endif +endfunction + +if exists('*win_gettype') + function! s:skip() abort " Vim 8.2.0257 (00f3b4e007), 8.2.0991 (0fe937fd86), 8.2.0996 (40a019f157) + return win_gettype() ==# 'popup' || win_gettype() ==# 'autocmd' + endfunction +else + function! s:skip() abort + return &buftype ==# 'popup' + endfunction +endif + +function! lightline#update_disable() abort + if s:lightline.enable.statusline + call setwinvar(0, '&statusline', '') + endif +endfunction + +function! lightline#enable() abort + let s:_ = 1 + call lightline#update() + augroup lightline + autocmd! + autocmd WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost * call lightline#update() + if !has('patch-8.1.1715') + autocmd FileType qf call lightline#update() + endif + autocmd SessionLoadPost * call lightline#highlight() + autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' + \ | call lightline#update() | call lightline#highlight() | endif + augroup END + augroup lightline-disable + autocmd! + augroup END + augroup! lightline-disable +endfunction + +function! lightline#disable() abort + let [&statusline, &tabline] = [get(s:, '_statusline', ''), get(s:, '_tabline', '')] + for t in range(1, tabpagenr('$')) + for n in range(1, tabpagewinnr(t, '$')) + call settabwinvar(t, n, '&statusline', '') + endfor + endfor + augroup lightline + autocmd! + augroup END + augroup! lightline + augroup lightline-disable + autocmd! + autocmd WinEnter * call lightline#update_disable() + augroup END + let s:_ = 2 +endfunction + +function! lightline#toggle() abort + if exists('#lightline') + call lightline#disable() + else + call lightline#enable() + endif +endfunction + +let s:_lightline = { + \ 'active': { + \ 'left': [['mode', 'paste'], ['readonly', 'filename', 'modified']], + \ 'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding', 'filetype']] + \ }, + \ 'inactive': { + \ 'left': [['filename']], + \ 'right': [['lineinfo'], ['percent']] + \ }, + \ 'tabline': { + \ 'left': [['tabs']], + \ 'right': [['close']] + \ }, + \ 'tab': { + \ 'active': ['tabnum', 'filename', 'modified'], + \ 'inactive': ['tabnum', 'filename', 'modified'] + \ }, + \ 'component': { + \ 'mode': '%{lightline#mode()}', + \ 'absolutepath': '%F', 'relativepath': '%f', 'filename': '%t', 'modified': '%M', 'bufnum': '%n', + \ 'paste': '%{&paste?"PASTE":""}', 'readonly': '%R', 'charvalue': '%b', 'charvaluehex': '%B', + \ 'spell': '%{&spell?&spelllang:""}', 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', 'fileformat': '%{&ff}', + \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', 'percent': '%3p%%', 'percentwin': '%P', + \ 'lineinfo': '%3l:%-2c', 'line': '%l', 'column': '%c', 'close': '%999X X ', 'winnr': '%{winnr()}' + \ }, + \ 'component_visible_condition': { + \ 'modified': '&modified||!&modifiable', 'readonly': '&readonly', 'paste': '&paste', 'spell': '&spell' + \ }, + \ 'component_function': {}, + \ 'component_function_visible_condition': {}, + \ 'component_expand': { + \ 'tabs': 'lightline#tabs' + \ }, + \ 'component_type': { + \ 'tabs': 'tabsel', 'close': 'raw' + \ }, + \ 'component_raw': {}, + \ 'tab_component': {}, + \ 'tab_component_function': { + \ 'filename': 'lightline#tab#filename', 'modified': 'lightline#tab#modified', + \ 'readonly': 'lightline#tab#readonly', 'tabnum': 'lightline#tab#tabnum' + \ }, + \ 'colorscheme': 'default', + \ 'mode_map': { + \ 'n': 'NORMAL', 'i': 'INSERT', 'R': 'REPLACE', 'v': 'VISUAL', 'V': 'V-LINE', "\": 'V-BLOCK', + \ 'c': 'COMMAND', 's': 'SELECT', 'S': 'S-LINE', "\": 'S-BLOCK', 't': 'TERMINAL' + \ }, + \ 'separator': { 'left': '', 'right': '' }, + \ 'subseparator': { 'left': '|', 'right': '|' }, + \ 'tabline_separator': {}, + \ 'tabline_subseparator': {}, + \ 'enable': { 'statusline': 1, 'tabline': 1 }, + \ '_mode_': { + \ 'n': 'normal', 'i': 'insert', 'R': 'replace', 'v': 'visual', 'V': 'visual', "\": 'visual', + \ 'c': 'command', 's': 'select', 'S': 'select', "\": 'select', 't': 'terminal' + \ }, + \ 'mode_fallback': { 'replace': 'insert', 'terminal': 'insert', 'select': 'visual' }, + \ 'palette': {}, + \ } +function! lightline#init() abort + let s:lightline = deepcopy(get(g:, 'lightline', {})) + for [key, value] in items(s:_lightline) + if type(value) == 4 + if !has_key(s:lightline, key) + let s:lightline[key] = {} + endif + call extend(s:lightline[key], value, 'keep') + elseif !has_key(s:lightline, key) + let s:lightline[key] = value + endif + unlet value + endfor + call extend(s:lightline.tabline_separator, s:lightline.separator, 'keep') + call extend(s:lightline.tabline_subseparator, s:lightline.subseparator, 'keep') + let s:lightline.tabline_configured = has_key(get(get(g:, 'lightline', {}), 'component_expand', {}), 'tabs') + for components in deepcopy(s:lightline.tabline.left + s:lightline.tabline.right) + if len(filter(components, 'v:val !=# "tabs" && v:val !=# "close"')) > 0 + let s:lightline.tabline_configured = 1 + break + endif + endfor + if !exists('s:_statusline') + let s:_statusline = &statusline + endif + if !exists('s:_tabline') + let s:_tabline = &tabline + endif + if s:lightline.enable.tabline + set tabline=%!lightline#tabline() + else + let &tabline = get(s:, '_tabline', '') + endif + for f in values(s:lightline.component_function) + silent! call call(f, []) + endfor + for f in values(s:lightline.tab_component_function) + silent! call call(f, [1]) + endfor + let s:mode = '' +endfunction + +function! lightline#colorscheme() abort + try + let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette + catch + call lightline#error('Could not load colorscheme ' . s:lightline.colorscheme . '.') + let s:lightline.colorscheme = 'default' + let s:lightline.palette = g:lightline#colorscheme#{s:lightline.colorscheme}#palette + finally + if has('win32') && !has('gui_running') && &t_Co < 256 + call lightline#colortable#gui2cui_palette(s:lightline.palette) + endif + let s:highlight = {} + call lightline#highlight('normal') + call lightline#link() + let s:_ = 0 + endtry +endfunction + +function! lightline#palette() abort + return s:lightline.palette +endfunction + +function! lightline#mode() abort + return get(s:lightline.mode_map, mode(), '') +endfunction + +let s:mode = '' +function! lightline#link(...) abort + let mode = get(s:lightline._mode_, a:0 ? a:1 : mode(), 'normal') + if s:mode ==# mode + return '' + endif + let s:mode = mode + if !has_key(s:highlight, mode) + call lightline#highlight(mode) + endif + let types = map(s:uniq(sort(filter(values(s:lightline.component_type), 'v:val !=# "raw"'))), '[v:val, 1]') + for [p, l] in [['Left', len(s:lightline.active.left)], ['Right', len(s:lightline.active.right)]] + for [i, t] in map(range(0, l), '[v:val, 0]') + types + if i != l + exec printf('hi link Lightline%s_active_%s Lightline%s_%s_%s', p, i, p, mode, i) + endif + for [j, s] in map(range(0, l), '[v:val, 0]') + types + if i + 1 == j || t || s && i != l + exec printf('hi link Lightline%s_active_%s_%s Lightline%s_%s_%s_%s', p, i, j, p, mode, i, j) + endif + endfor + endfor + endfor + exec printf('hi link LightlineMiddle_active LightlineMiddle_%s', mode) + return '' +endfunction + +function! s:term(p) abort + return get(a:p, 4) !=# '' ? 'term='.a:p[4].' cterm='.a:p[4].' gui='.a:p[4] : '' +endfunction + +if exists('*uniq') + let s:uniq = function('uniq') +else + function! s:uniq(xs) abort + let i = len(a:xs) - 1 + while i > 0 + if a:xs[i] ==# a:xs[i - 1] + call remove(a:xs, i) + endif + let i -= 1 + endwhile + return a:xs + endfunction +endif + +function! lightline#highlight(...) abort + let [c, f] = [s:lightline.palette, s:lightline.mode_fallback] + let [s:lightline.llen, s:lightline.rlen] = [len(c.normal.left), len(c.normal.right)] + let [s:lightline.tab_llen, s:lightline.tab_rlen] = [len(has_key(get(c, 'tabline', {}), 'left') ? c.tabline.left : c.normal.left), len(has_key(get(c, 'tabline', {}), 'right') ? c.tabline.right : c.normal.right)] + let types = map(s:uniq(sort(filter(values(s:lightline.component_type), 'v:val !=# "raw"'))), '[v:val, 1]') + let modes = a:0 ? [a:1] : extend(['normal', 'insert', 'replace', 'visual', 'inactive', 'command', 'select', 'tabline'], exists(':terminal') == 2 ? ['terminal'] : []) + for mode in modes + let s:highlight[mode] = 1 + let d = has_key(c, mode) ? mode : has_key(f, mode) && has_key(c, f[mode]) ? f[mode] : 'normal' + let left = d ==# 'tabline' ? s:lightline.tabline.left : d ==# 'inactive' ? s:lightline.inactive.left : s:lightline.active.left + let right = d ==# 'tabline' ? s:lightline.tabline.right : d ==# 'inactive' ? s:lightline.inactive.right : s:lightline.active.right + let ls = has_key(get(c, d, {}), 'left') ? c[d].left : has_key(f, d) && has_key(get(c, f[d], {}), 'left') ? c[f[d]].left : c.normal.left + let ms = has_key(get(c, d, {}), 'middle') ? c[d].middle[0] : has_key(f, d) && has_key(get(c, f[d], {}), 'middle') ? c[f[d]].middle[0] : c.normal.middle[0] + let rs = has_key(get(c, d, {}), 'right') ? c[d].right : has_key(f, d) && has_key(get(c, f[d], {}), 'right') ? c[f[d]].right : c.normal.right + for [p, l, zs] in [['Left', len(left), ls], ['Right', len(right), rs]] + for [i, t] in map(range(0, l), '[v:val, 0]') + types + if i < l || i < 1 + let r = t ? (has_key(get(c, d, []), i) ? c[d][i][0] : has_key(get(c, 'tabline', {}), i) ? c.tabline[i][0] : get(c.normal, i, zs)[0]) : get(zs, i, ms) + exec printf('hi Lightline%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', p, mode, i, r[0], r[1], r[2], r[3], s:term(r)) + endif + for [j, s] in map(range(0, l), '[v:val, 0]') + types + if i + 1 == j || t || s && i != l + let q = s ? (has_key(get(c, d, []), j) ? c[d][j][0] : has_key(get(c, 'tabline', {}), j) ? c.tabline[j][0] : get(c.normal, j, zs)[0]) : (j != l ? get(zs, j, ms) :ms) + exec printf('hi Lightline%s_%s_%s_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s', p, mode, i, j, r[1], q[1], r[3], q[3]) + endif + endfor + endfor + endfor + exec printf('hi LightlineMiddle_%s guifg=%s guibg=%s ctermfg=%s ctermbg=%s %s', mode, ms[0], ms[1], ms[2], ms[3], s:term(ms)) + endfor + if !a:0 | let s:mode = '' | endif +endfunction + +function! s:subseparator(components, subseparator, expanded) abort + let [a, c, f, v, u] = [a:components, s:lightline.component, s:lightline.component_function, s:lightline.component_visible_condition, s:lightline.component_function_visible_condition] + let xs = map(range(len(a:components)), 'a:expanded[v:val] ? "1" : + \ has_key(f, a[v:val]) ? (has_key(u, a[v:val]) ? "(".u[a[v:val]].")" : (exists("*".f[a[v:val]]) ? "" : "exists(\"*".f[a[v:val]]."\")&&").f[a[v:val]]."()!=#\"\"") : + \ has_key(v, a[v:val]) ? "(".v[a[v:val]].")" : has_key(c, a[v:val]) ? "1" : "0"') + return '%{' . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : xs[0] . '&&(') . join(xs[1:], '||') . (xs[0] ==# '1' || xs[0] ==# '(1)' ? '' : ')') . '?"' . a:subseparator . '":""}' +endfunction + +function! lightline#concatenate(xs, right) abort + let separator = a:right ? s:lightline.subseparator.right : s:lightline.subseparator.left + return join(filter(copy(a:xs), 'v:val !=# ""'), ' ' . separator . ' ') +endfunction + +function! lightline#statusline(inactive) abort + if a:inactive && !has_key(s:highlight, 'inactive') + call lightline#highlight('inactive') + endif + return s:line(0, a:inactive) +endfunction + +function! s:normalize(result) abort + if type(a:result) == 3 + return map(a:result, 'type(v:val) == 1 ? v:val : string(v:val)') + elseif type(a:result) == 1 + return [a:result] + else + return [string(a:result)] + endif +endfunction + +function! s:evaluate_expand(component) abort + try + let result = eval(a:component . '()') + if type(result) == 1 && result ==# '' + return [] + endif + catch + return [] + endtry + return map(type(result) == 3 ? (result + [[], [], []])[:2] : [[], [result], []], 'filter(s:normalize(v:val), "v:val !=# ''''")') +endfunction + +function! s:convert(name, index) abort + if !has_key(s:lightline.component_expand, a:name) + return [[[a:name], 0, a:index, a:index]] + else + let type = get(s:lightline.component_type, a:name, a:index) + let is_raw = get(s:lightline.component_raw, a:name) || type ==# 'raw' + return filter(map(s:evaluate_expand(s:lightline.component_expand[a:name]), + \ '[v:val, 1 + ' . is_raw . ', v:key == 1 && ' . (type !=# 'raw') . ' ? "' . type . '" : "' . a:index . '", "' . a:index . '"]'), 'v:val[0] != []') + endif +endfunction + +function! s:expand(components) abort + let components = [] + let expanded = [] + let indices = [] + let prevtype = '' + let previndex = -1 + let xs = [] + call map(deepcopy(a:components), 'map(v:val, "extend(xs, s:convert(v:val, ''" . v:key . "''))")') + for [component, expand, type, index] in xs + if prevtype !=# type + for i in range(previndex + 1, max([previndex, index - 1])) + call add(indices, string(i)) + call add(components, []) + call add(expanded, []) + endfor + call add(indices, type) + call add(components, []) + call add(expanded, []) + endif + call extend(components[-1], component) + call extend(expanded[-1], repeat([expand], len(component))) + let prevtype = type + let previndex = index + endfor + for i in range(previndex + 1, max([previndex, len(a:components) - 1])) + call add(indices, string(i)) + call add(components, []) + call add(expanded, []) + endfor + call add(indices, string(len(a:components))) + return [components, expanded, indices] +endfunction + +function! s:func(name) abort + return exists('*' . a:name) ? '%{' . a:name . '()}' : '%{exists("*' . a:name . '")?' . a:name . '():""}' +endfunction + +function! s:line(tabline, inactive) abort + let _ = a:tabline ? '' : '%{lightline#link()}' + if s:lightline.palette == {} + call lightline#colorscheme() + endif + let [l, r] = a:tabline ? [s:lightline.tab_llen, s:lightline.tab_rlen] : [s:lightline.llen, s:lightline.rlen] + let [p, s] = a:tabline ? [s:lightline.tabline_separator, s:lightline.tabline_subseparator] : [s:lightline.separator, s:lightline.subseparator] + let [c, f, t, w] = [s:lightline.component, s:lightline.component_function, s:lightline.component_type, s:lightline.component_raw] + let mode = a:tabline ? 'tabline' : a:inactive ? 'inactive' : 'active' + let ls = has_key(s:lightline, mode) ? s:lightline[mode].left : s:lightline.active.left + let [lc, le, li] = s:expand(ls) + let rs = has_key(s:lightline, mode) ? s:lightline[mode].right : s:lightline.active.right + let [rc, re, ri] = s:expand(rs) + for i in range(len(lc)) + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '#' + for j in range(len(lc[i])) + let x = le[i][j] ? lc[i][j] : has_key(f, lc[i][j]) ? s:func(f[lc[i][j]]) : get(c, lc[i][j], '') + let _ .= has_key(t, lc[i][j]) && t[lc[i][j]] ==# 'raw' || get(w, lc[i][j]) || le[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(lc[i]) - 1 && s.left !=# '' + let _ .= s:subseparator(lc[i][(j):], s.left, le[i][(j):]) + endif + endfor + let _ .= '%#LightlineLeft_' . mode . '_' . li[i] . '_' . li[i + 1] . '#' + let _ .= i < l + len(lc) - len(ls) && li[i] < l || li[i] != li[i + 1] ? p.left : len(lc[i]) ? s.left : '' + endfor + let _ .= '%#LightlineMiddle_' . mode . '#%=' + for i in range(len(rc) - 1, 0, -1) + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '_' . ri[i + 1] . '#' + let _ .= i < r + len(rc) - len(rs) && ri[i] < r || ri[i] != ri[i + 1] ? p.right : len(rc[i]) ? s.right : '' + let _ .= '%#LightlineRight_' . mode . '_' . ri[i] . '#' + for j in range(len(rc[i])) + let x = re[i][j] ? rc[i][j] : has_key(f, rc[i][j]) ? s:func(f[rc[i][j]]) : get(c, rc[i][j], '') + let _ .= has_key(t, rc[i][j]) && t[rc[i][j]] ==# 'raw' || get(w, rc[i][j]) || re[i][j] ==# 2 || x ==# '' ? x : '%( ' . x . ' %)' + if j < len(rc[i]) - 1 && s.right !=# '' + let _ .= s:subseparator(rc[i][(j):], s.right, re[i][(j):]) + endif + endfor + endfor + return _ +endfunction + +let s:tabnr = -1 +let s:tabcnt = -1 +let s:columns = -1 +let s:tabline = '' +function! lightline#tabline() abort + if !has_key(s:highlight, 'tabline') + call lightline#highlight('tabline') + endif + if s:lightline.tabline_configured || s:tabnr != tabpagenr() || s:tabcnt != tabpagenr('$') || s:columns != &columns + let s:tabnr = tabpagenr() + let s:tabcnt = tabpagenr('$') + let s:columns = &columns + let s:tabline = s:line(1, 0) + endif + return s:tabline +endfunction + +function! lightline#tabs() abort + let [x, y, z] = [[], [], []] + let nr = tabpagenr() + let cnt = tabpagenr('$') + for i in range(1, cnt) + call add(i < nr ? x : i == nr ? y : z, (i > nr + 3 ? '%<' : '') . '%' . i . 'T%{lightline#onetab(' . i . ',' . (i == nr) . ')}' . (i == cnt ? '%T' : '')) + endfor + let abbr = '...' + let n = min([max([&columns / 40, 2]), 8]) + if len(x) > n && len(z) > n + let x = extend(add(x[:n/2-1], abbr), x[-(n+1)/2:]) + let z = extend(add(z[:(n+1)/2-1], abbr), z[-n/2:]) + elseif len(x) + len(z) > 2 * n + if len(x) > n + let x = extend(add(x[:(2*n-len(z))/2-1], abbr), x[-(2*n-len(z)+1)/2:]) + elseif len(z) > n + let z = extend(add(z[:(2*n-len(x)+1)/2-1], abbr), z[-(2*n-len(x))/2:]) + endif + endif + return [x, y, z] +endfunction + +function! lightline#onetab(n, active) abort + let _ = [] + for name in a:active ? s:lightline.tab.active : s:lightline.tab.inactive + if has_key(s:lightline.tab_component_function, name) + call add(_, call(s:lightline.tab_component_function[name], [a:n])) + else + call add(_, get(s:lightline.tab_component, name, '')) + endif + endfor + return join(filter(_, 'v:val !=# ""'), ' ') +endfunction + +function! lightline#error(msg) abort + echohl ErrorMsg + echomsg 'lightline.vim: '.a:msg + echohl None +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim new file mode 100644 index 00000000..9cd7fa4d --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme.vim @@ -0,0 +1,257 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme.vim +" Author: itchyny +" License: MIT License +" Last Change: 2019/09/07 11:20:37. +" ============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +let s:cuicolor = { + \ 'black' : 16, + \ 'white' : 231, + \ + \ 'darkestgreen' : 22, + \ 'darkgreen' : 28, + \ 'mediumgreen' : 70, + \ 'brightgreen' : 148, + \ + \ 'darkestcyan' : 23, + \ 'mediumcyan' : 117, + \ + \ 'darkestblue' : 24, + \ 'darkblue' : 31, + \ + \ 'darkestred' : 52, + \ 'darkred' : 88, + \ 'mediumred' : 124, + \ 'brightred' : 160, + \ 'brightestred' : 196, + \ + \ 'darkestpurple' : 55, + \ 'mediumpurple' : 98, + \ 'brightpurple' : 189, + \ + \ 'brightorange' : 208, + \ 'brightestorange': 214, + \ + \ 'gray0' : 233, + \ 'gray1' : 235, + \ 'gray2' : 236, + \ 'gray3' : 239, + \ 'gray4' : 240, + \ 'gray5' : 241, + \ 'gray6' : 244, + \ 'gray7' : 245, + \ 'gray8' : 247, + \ 'gray9' : 250, + \ 'gray10' : 252, + \ + \ 'yellow' : 136, + \ 'orange' : 166, + \ 'red' : 160, + \ 'magenta' : 125, + \ 'violet' : 61, + \ 'blue' : 33, + \ 'cyan' : 37, + \ 'green' : 64, + \ } + +let s:guicolor = { + \ 'black' : '#000000', + \ 'white' : '#ffffff', + \ + \ 'darkestgreen' : '#005f00', + \ 'darkgreen' : '#008700', + \ 'mediumgreen' : '#5faf00', + \ 'brightgreen' : '#afdf00', + \ + \ 'darkestcyan' : '#005f5f', + \ 'mediumcyan' : '#87dfff', + \ + \ 'darkestblue' : '#005f87', + \ 'darkblue' : '#0087af', + \ + \ 'darkestred' : '#5f0000', + \ 'darkred' : '#870000', + \ 'mediumred' : '#af0000', + \ 'brightred' : '#df0000', + \ 'brightestred' : '#ff0000', + \ + \ 'darkestpurple' : '#5f00af', + \ 'mediumpurple' : '#875fdf', + \ 'brightpurple' : '#dfdfff', + \ + \ 'brightorange' : '#ff8700', + \ 'brightestorange': '#ffaf00', + \ + \ 'gray0' : '#121212', + \ 'gray1' : '#262626', + \ 'gray2' : '#303030', + \ 'gray3' : '#4e4e4e', + \ 'gray4' : '#585858', + \ 'gray5' : '#606060', + \ 'gray6' : '#808080', + \ 'gray7' : '#8a8a8a', + \ 'gray8' : '#9e9e9e', + \ 'gray9' : '#bcbcbc', + \ 'gray10' : '#d0d0d0', + \ + \ 'yellow' : '#b58900', + \ 'orange' : '#cb4b16', + \ 'red' : '#dc322f', + \ 'magenta' : '#d33682', + \ 'violet' : '#6c71c4', + \ 'blue' : '#268bd2', + \ 'cyan' : '#2aa198', + \ 'green' : '#859900', + \ } + +function! s:convert(rgb) abort + let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)') + if len(rgb) == 0 + return 0 + endif + if rgb[0] == 0xc0 && rgb[1] == 0xc0 && rgb[2] == 0xc0 + return 7 + elseif rgb[0] == 0x80 && rgb[1] == 0x80 && rgb[2] == 0x80 + return 8 + elseif (rgb[0] == 0x80 || rgb[0] == 0x00) && (rgb[1] == 0x80 || rgb[1] == 0x00) && (rgb[2] == 0x80 || rgb[2] == 0x00) + return (rgb[0] / 0x80) + (rgb[1] / 0x80) * 2 + (rgb[1] / 0x80) * 4 + elseif abs(rgb[0]-rgb[1]) < 3 && abs(rgb[1]-rgb[2]) < 3 && abs(rgb[2]-rgb[0]) < 3 + return s:black((rgb[0] + rgb[1] + rgb[2]) / 3) + else + return 16 + ((s:nr(rgb[0]) * 6) + s:nr(rgb[1])) * 6 + s:nr(rgb[2]) + endif +endfunction + +function! s:black(x) abort + if a:x < 0x04 + return 16 + elseif a:x > 0xf4 + return 231 + elseif index([0x00, 0x5f, 0x87, 0xaf, 0xdf, 0xff], a:x) >= 0 + let l = a:x / 0x30 + return ((l * 6) + l) * 6 + l + 16 + else + return 232 + (a:x < 8 ? 0 : a:x < 0x60 ? (a:x-8)/10 : a:x < 0x76 ? (a:x-0x60)/6+9 : (a:x-8)/10) + endif +endfunction + +function! s:nr(x) abort + return a:x < 0x2f ? 0 : a:x < 0x73 ? 1 : a:x < 0x9b ? 2 : a:x < 0xc7 ? 3 : a:x < 0xef ? 4 : 5 +endfunction + +function! s:rgb(r, g, b) abort + return printf('#%02x%02x%02x', a:r, a:g, a:b) +endfunction + +function! s:upconvert(nr) abort + let x = a:nr * 1 + if x < 7 + let [b, rg] = [x / 4, x % 4] + let [g, r] = [rg / 2, rg % 2] + return s:rgb(r * 0x80, g * 0x80, b * 0x80) + elseif x == 7 + return s:rgb(0xc0, 0xc0, 0xc0) + elseif x == 8 + return s:rgb(0x80, 0x80, 0x80) + elseif x < 16 + let y = x - 8 + let [b, rg] = [y / 4, y % 4] + let [g, r] = [rg / 2, rg % 2] + return s:rgb(r * 0xff, g * 0xff, b * 0xff) + elseif x < 232 + let y = x - 16 + let [rg, b] = [y / 6, y % 6] + let [r, g] = [rg / 6, rg % 6] + let l = [0x00, 0x5f, 0x87, 0xaf, 0xdf, 0xff] + return s:rgb(l[r], l[g], l[b]) + elseif x < 241 + let k = (x - 232) * 10 + 8 + return s:rgb(k, k, k) + elseif x < 243 + let k = (x - 241) * 6 + 0x60 + return s:rgb(k, k, k) + else + let k = (x - 232) * 10 + 8 + return s:rgb(k, k, k) + endif +endfunction + +function! lightline#colorscheme#fill(p) abort + for k in values(a:p) + for l in values(k) + for m in l + if len(m) < 4 + if type(m[0]) == 1 && type(m[1]) == 1 + if m[0] =~# '^\d\+$' && m[1] =~# '^\d\+$' + call insert(m, s:upconvert(m[1]), 0) + call insert(m, s:upconvert(m[1]), 0) + else + call insert(m, get(s:cuicolor, m[0], s:convert(m[0])), 2) + call insert(m, get(s:cuicolor, m[1], s:convert(m[1])), 3) + let m[0] = get(s:guicolor, m[0], m[0]) + let m[1] = get(s:guicolor, m[1], m[1]) + endif + elseif type(m[0]) == 0 && type(m[1]) == 0 + call insert(m, s:upconvert(m[1]), 0) + call insert(m, s:upconvert(m[1]), 0) + endif + endif + endfor + endfor + endfor + return a:p +endfunction + +function! lightline#colorscheme#flatten(p) abort + for k in values(a:p) + for l in values(k) + for m in range(len(l)) + let attr = '' + if len(l[m]) == 3 && type(l[m][2]) == 1 + let attr = l[m][2] + endif + let l[m] = [l[m][0][0], l[m][1][0], l[m][0][1], l[m][1][1]] + if !empty(attr) + call add(l[m], attr) + endif + endfor + endfor + endfor + return a:p +endfunction + +if has('gui_running') || (has('termguicolors') && &termguicolors) + function! lightline#colorscheme#background() abort + return &background + endfunction +else + " &background is set inappropriately when the colorscheme sets ctermbg of the Normal group + function! lightline#colorscheme#background() abort + let bg_color = synIDattr(synIDtrans(hlID('Normal')), 'bg', 'cterm') + if bg_color !=# '' + if bg_color < 16 + return &background + elseif 232 <= bg_color && bg_color < 244 + return 'dark' + elseif 244 <= bg_color + return 'light' + endif + endif + let fg_color = synIDattr(synIDtrans(hlID('Normal')), 'fg', 'cterm') + if fg_color !=# '' + if fg_color < 7 || 232 <= fg_color && fg_color < 244 + return 'light' + elseif 8 <= fg_color && fg_color < 16 || 244 <= fg_color + return 'dark' + endif + endif + return &background + endfunction +endif + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim new file mode 100644 index 00000000..19591024 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/16color.vim @@ -0,0 +1,53 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/16color.vim +" Author: itchyny, jackno +" License: MIT License +" ============================================================================= + +let s:black = [ '#000000', 0 ] +let s:maroon = [ '#800000', 1 ] +let s:green = [ '#008000', 2 ] +let s:olive = [ '#808000', 3 ] +let s:navy = [ '#000080', 4 ] +let s:purple = [ '#800080', 5 ] +let s:teal = [ '#008080', 6 ] +let s:silver = [ '#c0c0c0', 7 ] +let s:gray = [ '#808080', 8] +let s:red = [ '#ff0000', 9 ] +let s:lime = [ '#00ff00', 10 ] +let s:yellow = [ '#ffff00', 11 ] +let s:blue = [ '#0000ff', 12 ] +let s:fuchsia = [ '#ff00ff', 13 ] +let s:aqua = [ '#00ffff', 14 ] +let s:white = [ '#ffffff', 15 ] + +if lightline#colorscheme#background() ==# 'light' + let [s:black, s:white] = [s:white, s:black] + let [s:silver, s:gray] = [s:gray, s:silver] + let [s:blue, s:aqua] = [s:aqua, s:blue] + let [s:purple, s:fuchsia] = [s:fuchsia, s:purple] + let [s:green, s:lime] = [s:lime, s:green] + let [s:red, s:yellow] = [s:yellow, s:red] +endif + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.middle = [ [ s:silver, s:black ] ] +let s:p.normal.right = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.normal.error = [ [ s:black, s:red ] ] +let s:p.normal.warning = [ [ s:black, s:yellow ] ] +let s:p.inactive.left = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:silver, s:black ] ] +let s:p.inactive.right = [ [ s:silver, s:gray ], [ s:gray, s:black ] ] +let s:p.insert.left = [ [ s:white, s:green ], [ s:white, s:gray ] ] +let s:p.insert.right = copy(s:p.insert.left) +let s:p.replace.left = [ [ s:white, s:red ], [ s:white, s:gray ] ] +let s:p.replace.right = copy(s:p.replace.left) +let s:p.visual.left = [ [ s:white, s:purple ], [ s:white, s:gray ] ] +let s:p.visual.right = copy(s:p.visual.left) +let s:p.tabline.left = [ [ s:silver, s:black ] ] +let s:p.tabline.tabsel = copy(s:p.normal.right) +let s:p.tabline.middle = [ [ s:silver, s:black ] ] +let s:p.tabline.right = copy(s:p.normal.right) + +let g:lightline#colorscheme#16color#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/OldHope.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/OldHope.vim new file mode 100644 index 00000000..ff78290c --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/OldHope.vim @@ -0,0 +1,44 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/OldHope.vim +" Author: tomb0y +" License: MIT License +" Last Change: 2017/10/15 06:20:54. +" ============================================================================= + +let s:yellow = [ '#e5cd52' , 221 ] +let s:blue = [ '#4fb4d8' , 39 ] +let s:red = [ '#f92672' , 161 ] +let s:green = [ '#78bd65' , 41 ] +let s:orange = [ '#ef7c2a' , 202 ] +let s:white = [ '#ffffff' , 15 ] +let s:lightGray = [ '#848794' , 245 ] +let s:gray = [ '#686b78' , 242 ] +let s:darkGray = [ '#45474f' , 238 ] +let s:veryDarkGray = [ '#1c1d21' , 234 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ s:white, s:blue ], [ s:white, s:gray ] ] +let s:p.insert.left = [ [ s:white, s:green ], [ s:white, s:gray ] ] +let s:p.visual.left = [ [ s:white, s:orange ], [ s:white, s:gray ] ] +let s:p.replace.left = [ [ s:white, s:red ], [ s:white, s:gray ] ] + +let s:p.inactive.right = [ [ s:darkGray, s:gray ], [ s:darkGray, s:gray ] ] +let s:p.inactive.left = [ [ s:lightGray, s:darkGray ], [ s:white, s:darkGray ] ] +let s:p.inactive.middle = [ [ s:white, s:darkGray ] ] + +let s:p.normal.middle = [ [ s:white, s:darkGray ] ] +let s:p.normal.error = [ [ s:red, s:darkGray ] ] +let s:p.normal.warning = [ [ s:orange, s:darkGray ] ] + +let s:p.tabline.left = [ [ s:lightGray, s:darkGray ] ] +let s:p.tabline.tabsel = [ [ s:darkGray, s:yellow ] ] +let s:p.tabline.middle = [ [ s:yellow, s:veryDarkGray ] ] + +let s:p.normal.right = copy(s:p.normal.left) +let s:p.insert.right = copy(s:p.insert.left) +let s:p.visual.right = copy(s:p.visual.left) +let s:p.replace.right = copy(s:p.replace.left) +let s:p.tabline.right = copy(s:p.tabline.left) + +let g:lightline#colorscheme#OldHope#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim new file mode 100644 index 00000000..90aa426b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor.vim @@ -0,0 +1,12 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/PaperColor.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2017/11/25 11:13:35. +" ============================================================================= + +if lightline#colorscheme#background() ==# 'light' + let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_light#palette +else + let g:lightline#colorscheme#PaperColor#palette = g:lightline#colorscheme#PaperColor_dark#palette +endif diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim new file mode 100644 index 00000000..0a70b348 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_dark.vim @@ -0,0 +1,60 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/PaperColor_dark.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2015-07-27 06:01 +" ============================================================================= + +let s:red = '#df0000' +let s:green = '#008700' +let s:blue = '#00afaf' + +let s:pink = '#afdf00' +let s:olive = '#dfaf5f' +let s:navy = '#df875f' + +let s:orange = '#d75f00' +let s:purple = '#8959a8' +let s:aqua = '#3e999f' + +" Basics: +let s:foreground = '#d0d0d0' +let s:background = '#444444' +let s:window = '#efefef' +let s:status = '#c6c6c6' +let s:error = '#5f0000' + +" Tabline: +let s:tabline_bg = '#3a3a3a' +let s:tabline_active_fg = '#1c1c1c' +let s:tabline_active_bg = '#00afaf' +let s:tabline_inactive_fg = '#c6c6c6' +let s:tabline_inactive_bg = '#585858' + +" Statusline: +let s:statusline_active_fg = '#1c1c1c' +let s:statusline_active_bg = '#5f8787' +let s:statusline_inactive_fg = '#c6c6c6' +let s:statusline_inactive_bg = '#444444' + +" Visual: +let s:visual_fg = '#000000' +let s:visual_bg = '#8787af' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] +let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:foreground, s:background ], ] +let s:p.insert.left = [ [ s:background, s:blue], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.visual.left = [ [ s:visual_fg, s:visual_bg ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] +let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] +let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:background, s:error ] ] + +let g:lightline#colorscheme#PaperColor_dark#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim new file mode 100644 index 00000000..aef0b865 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/PaperColor_light.vim @@ -0,0 +1,55 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/PaperColor_light.vim +" Author: TKNGUE +" License: MIT License +" Last Change: 2015/07/28 07:46:40. +" ============================================================================= + +let s:red = '#df0000' +let s:green = '#008700' +let s:blue = '#4271ae' +let s:pink = '#d7005f' +let s:olive = '#718c00' +let s:navy = '#005f87' +let s:orange = '#d75f00' +let s:purple = '#8959a8' +let s:aqua = '#3e999f' + +" Basics: +let s:foreground = '#4d4d4c' +let s:background = '#F5F5F5' +let s:window = '#efefef' +let s:status = s:aqua +let s:error = '#ffafdf' + +" Tabline: +let s:tabline_bg = s:navy +let s:tabline_active_fg = s:foreground +let s:tabline_active_bg = s:window +let s:tabline_inactive_fg = s:background +let s:tabline_inactive_bg = s:aqua + +" Statusline: +let s:statusline_active_fg = s:window +let s:statusline_active_bg = s:navy +let s:statusline_inactive_fg = s:foreground +let s:statusline_inactive_bg = '#dadada' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.right = [ [ s:foreground, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.normal.middle = [ [ s:statusline_active_fg, s:statusline_active_bg ]] +let s:p.inactive.right = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.left = [ [ s:foreground, s:background ], [ s:foreground, s:background ] ] +let s:p.inactive.middle = [ [ s:foreground, s:background ], ] +let s:p.insert.left = [ [ s:blue, s:background ], [ s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.replace.left = [ [ s:background, s:pink ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.visual.left = [ [ s:background, s:orange ], [s:statusline_active_fg, s:status ], [ s:statusline_active_fg, s:statusline_active_bg ] ] +let s:p.tabline.left = [ [s:tabline_inactive_fg, s:tabline_inactive_bg ]] +let s:p.tabline.tabsel = [ [s:tabline_active_fg, s:tabline_active_bg ] ] +let s:p.tabline.middle = [ [s:tabline_bg, s:tabline_bg]] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:background, s:error ] ] +let s:p.normal.warning = [ [ s:background, s:olive ] ] + +let g:lightline#colorscheme#PaperColor_light#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim new file mode 100644 index 00000000..87b9ff04 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Tomorrow.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:57:37. +" ============================================================================= + +let s:base03 = '#fafafa' +let s:base023 = '#dfdfdf' +let s:base02 = '#c8c8c8' +let s:base01 = '#b4b4b4' +let s:base00 = '#808080' +let s:base0 = '#666666' +let s:base1 = '#555555' +let s:base2 = '#4f4f4f' +let s:base3 = '#4d4d4c' +let s:red = '#c82829' +let s:orange = '#f5871f' +let s:yellow = '#eab700' +let s:green = '#718c00' +let s:cyan = '#3e999f' +let s:blue = '#4271ae' +let s:magenta = '#8959a8' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base00, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base03 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base02, s:orange ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.left = [ [ s:base2, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base00 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:base01 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base0 ] ] + +let g:lightline#colorscheme#Tomorrow#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim new file mode 100644 index 00000000..568dc51a --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Tomorrow_Night.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:57:43. +" ============================================================================= + +let s:base3 = '#c5c8c6' +let s:base2 = '#bababa' +let s:base1 = '#a0a0a0' +let s:base0 = '#909090' +let s:base00 = '#666666' +let s:base01 = '#555555' +let s:base02 = '#434343' +let s:base023 = '#303030' +let s:base03 = '#1d1f21' +let s:red = '#cc6666' +let s:orange = '#de935f' +let s:yellow = '#f0c674' +let s:green = '#b5bd68' +let s:cyan = '#8abeb7' +let s:blue = '#81a2be' +let s:magenta = '#b294bb' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base00, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base03 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base02, s:orange ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.left = [ [ s:base2, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base0 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:base023 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base02 ] ] + +let g:lightline#colorscheme#Tomorrow_Night#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim new file mode 100644 index 00000000..016bbd41 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Blue.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:57:49. +" ============================================================================= + +let s:base3 = '#ffffff' +let s:base23 = '#ffffff' +let s:base2 = '#ffffff' +let s:base1 = '#ffffff' +let s:base0 = '#ffffff' +let s:base00 = '#6060df' +let s:base01 = '#6060af' +let s:base02 = '#606087' +let s:base023 = '#202087' +let s:base03 = '#002451' +let s:red = '#ff9da4' +let s:orange = '#ffc58f' +let s:yellow = '#ffeead' +let s:green = '#d1f1a9' +let s:cyan = '#99ffff' +let s:blue = '#bbdaff' +let s:magenta = '#ebbbff' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ] +let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.left = [ [ s:base2, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:base023, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#Tomorrow_Night_Blue#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim new file mode 100644 index 00000000..d59517b9 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Bright.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:57:52. +" ============================================================================= + +let s:base3 = '#eaeaea' +let s:base23 = '#d0d0d0' +let s:base2 = '#c6c6c6' +let s:base1 = '#b2b2b2' +let s:base0 = '#949494' +let s:base00 = '#767676' +let s:base01 = '#606060' +let s:base02 = '#4e4e4e' +let s:base023 = '#262626' +let s:base03 = '#12124c' +let s:red = '#d54e53' +let s:orange = '#e78c45' +let s:yellow = '#e7c547' +let s:green = '#b9ca4a' +let s:cyan = '#70c0b1' +let s:blue = '#7aa6da' +let s:magenta = '#c397d8' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ] +let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.left = [ [ s:base2, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base2, s:base023 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:base023 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base02 ] ] + +let g:lightline#colorscheme#Tomorrow_Night_Bright#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim new file mode 100644 index 00000000..993d16a3 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/Tomorrow_Night_Eighties.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:57:56. +" ============================================================================= + +let s:base3 = '#cccccc' +let s:base23 = '#bbbbbb' +let s:base2 = '#aaaaaa' +let s:base1 = '#999999' +let s:base0 = '#777777' +let s:base00 = '#666666' +let s:base01 = '#555555' +let s:base02 = '#444444' +let s:base023 = '#333333' +let s:base03 = '#2d2d2d' +let s:red = '#f2777a' +let s:orange = '#f99157' +let s:yellow = '#ffcc66' +let s:green = '#99cc99' +let s:cyan = '#009999' +let s:blue = '#99cccc' +let s:magenta = '#cc99cc' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base023, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base02, s:base0 ], [ s:base00, s:base03 ] ] +let s:p.insert.left = [ [ s:base023, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:orange ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base023, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.left = [ [ s:base2, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base2, s:base03 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:base023, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#Tomorrow_Night_Eighties#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim new file mode 100644 index 00000000..77d40bad --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/apprentice.vim @@ -0,0 +1,46 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/apprentice.vim +" Author: pt307 (based on work by romainl) +" License: MIT License +" Last Change: 2021/03/02 18:25:22. +" ============================================================================= + +" For the Apprentice colorscheme + +let s:almost_black = [ '#1c1c1c', 234 ] +let s:darker_grey = [ '#262626', 235 ] +let s:medium_grey = [ '#585858', 240 ] +let s:lighter_grey = [ '#bcbcbc', 250 ] +let s:green = [ '#5f875f', 65 ] +let s:red = [ '#af5f5f', 131 ] +let s:orange = [ '#ff8700', 208 ] +let s:ocre = [ '#87875f', 101 ] +let s:yellow = [ '#ffffaf', 229 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.normal.right = [ [ s:darker_grey, s:ocre ], [ s:darker_grey, s:medium_grey ] ] +let s:p.normal.warning = [ [ s:almost_black, s:orange ] ] +let s:p.normal.error = [ [ s:almost_black, s:red ] ] + +let s:p.inactive.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.inactive.middle = [ [ s:medium_grey, s:darker_grey ] ] +let s:p.inactive.right = [ [ s:darker_grey, s:medium_grey ] ] + +let s:p.insert.left = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] +let s:p.insert.right = [ [ s:darker_grey, s:green ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.replace.left = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] +let s:p.replace.right = [ [ s:darker_grey, s:red ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.visual.left = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] +let s:p.visual.right = [ [ s:darker_grey, s:yellow ], [ s:darker_grey, s:medium_grey ] ] + +let s:p.tabline.left = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.middle = [ [ s:lighter_grey, s:darker_grey ] ] +let s:p.tabline.right = [ [ s:darker_grey, s:medium_grey ] ] +let s:p.tabline.tabsel = [ [ s:darker_grey, s:ocre ] ] + +let g:lightline#colorscheme#apprentice#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim new file mode 100644 index 00000000..cb10a258 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_dark.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_dark.vim +" Author: danielpeng2 +" License: MIT License +" Last Change: 2020/05/01 19:37:33. +" ============================================================================= + +let s:base0 = '#e6e1cf' +let s:base1 = '#e6e1cf' +let s:base2 = '#3e4b59' +let s:base3 = '#e6e1cf' +let s:base00 = '#14191f' +let s:base01 = '#14191f' +let s:base02 = '#0f1419' +let s:base023 = '#0f1419' +let s:base03 = '#e6b673' +let s:yellow = '#e6b673' +let s:orange = '#ff7733' +let s:red = '#f07178' +let s:magenta = '#ffee99' +let s:blue = '#36a3d9' +let s:cyan = s:blue +let s:green = '#b8cc52' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_dark#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim new file mode 100644 index 00000000..d1f781aa --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_light.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_light.vim +" Author: christalib +" License: MIT License +" Last Change: 2020/05/01 19:38:21. +" ============================================================================= + +let s:base0 = '#5C6773' +let s:base1 = '#5C6773' +let s:base2 = '#828C99' +let s:base3 = '#5C6773' +let s:base00 = '#FFFFFF' +let s:base01 = '#FFFFFF' +let s:base02 = '#FAFAFA' +let s:base023 = '#FAFAFA' +let s:base03 = '#E6B673' +let s:yellow = '#E6B673' +let s:orange = '#FF7733' +let s:red = '#f07178' +let s:magenta = '#A37ACC' +let s:blue = '#59c2ff' +let s:cyan = s:blue +let s:green = '#86B300' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_light#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim new file mode 100644 index 00000000..fe7506fb --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/ayu_mirage.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/ayu_mirage.vim +" Author: impulse +" License: MIT License +" Last Change: 2020/05/01 19:37:21. +" ============================================================================= + +let s:base0 = '#d9d7ce' +let s:base1 = '#d9d7ce' +let s:base2 = '#607080' +let s:base3 = '#d9d7ce' +let s:base00 = '#272d38' +let s:base01 = '#272d38' +let s:base02 = '#212733' +let s:base023 = '#212733' +let s:base03 = '#ffc44c' +let s:yellow = '#ffc44c' +let s:orange = '#ffae57' +let s:red = '#f07178' +let s:magenta = '#d4bfff' +let s:blue = '#59c2ff' +let s:cyan = s:blue +let s:green = '#bbe67e' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.left = [ [ s:base1, s:base01 ], [ s:base3, s:base01 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.inactive.right = [ [ s:base1, s:base01 ], [ s:base2, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.tabline.tabsel = [ [ s:base02, s:base03 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#ayu_mirage#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/darcula.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/darcula.vim new file mode 100644 index 00000000..928e8b76 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/darcula.vim @@ -0,0 +1,37 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/darcula.vim +" Author: kkopec +" License: MIT License +" Last Change: 2017/02/11 21:18:54. +" ============================================================================= + +let s:black = [ '#2b2b2b', 235 ] +let s:gray = [ '#323232', 236 ] +let s:white = [ '#a9b7c6', 250 ] +let s:blue = [ '#6897bb' , 67 ] +let s:green = [ '#629755', 71 ] +let s:purple = [ '#9876aa', 104 ] +let s:red = [ '#ff6b68', 204 ] +let s:yellow = [ '#ffc66d', 222 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:black, s:purple ], [ s:purple, s:gray ] ] +let s:p.normal.right = [ [ s:black, s:purple ], [ s:purple, s:gray ] ] +let s:p.inactive.left = [ [ s:black, s:blue ], [ s:blue, s:gray ] ] +let s:p.inactive.right = [ [ s:black, s:blue ], [ s:blue, s:gray ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:green, s:gray ] ] +let s:p.insert.right = [ [ s:black, s:green ], [ s:green, s:gray ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:red, s:gray ] ] +let s:p.replace.right = [ [ s:black, s:red ], [ s:red, s:gray ] ] +let s:p.visual.left = [ [ s:black, s:yellow ], [ s:yellow, s:gray ] ] +let s:p.visual.right = [ [ s:black, s:yellow ], [ s:yellow, s:gray ] ] +let s:p.normal.middle = [ [ s:white, s:gray ] ] +let s:p.inactive.middle = [ [ s:white, s:gray ] ] +let s:p.tabline.left = [ [ s:blue, s:gray ] ] +let s:p.tabline.tabsel = [ [ s:black, s:blue ] ] +let s:p.tabline.middle = [ [ s:blue, s:gray ] ] +let s:p.tabline.right = [ [ s:black, s:blue ] ] +let s:p.normal.error = [ [ s:red, s:black ] ] +let s:p.normal.warning = [ [ s:yellow, s:black ] ] + +let g:lightline#colorscheme#darcula#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim new file mode 100644 index 00000000..ee9835c8 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/default.vim @@ -0,0 +1,8 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/default.vim +" Author: itchyny +" License: MIT License +" Last Change: 2013/08/22 06:05:52. +" ============================================================================= + +let g:lightline#colorscheme#default#palette = g:lightline#colorscheme#powerline#palette diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim new file mode 100644 index 00000000..3f9f2265 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/deus.vim @@ -0,0 +1,39 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/deus.vim +" Author: nikersify +" License: MIT License +" Last Change: 2020/02/15 20:56:45. +" ============================================================================= + +let s:term_red = 204 +let s:term_green = 114 +let s:term_yellow = 180 +let s:term_blue = 39 +let s:term_purple = 170 +let s:term_white = 145 +let s:term_black = 235 +let s:term_grey = 236 + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.left = [ [ '#292c33', '#98c379', s:term_black, s:term_green, 'bold' ], [ '#98c379', '#292c33', s:term_green, s:term_black ] ] +let s:p.normal.right = [ [ '#292c33', '#98c379', s:term_black, s:term_green ], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ], [ '#98c379', '#292c33', s:term_green, s:term_black ] ] +let s:p.inactive.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue], [ '#abb2bf', '#3e4452', s:term_white, s:term_grey ] ] +let s:p.inactive.left = s:p.inactive.right[1:] +let s:p.insert.left = [ [ '#292c33', '#61afef', s:term_black, s:term_blue, 'bold' ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] +let s:p.insert.right = [ [ '#292c33', '#61afef', s:term_black, s:term_blue ], [ '#ABB2BF', '#3E4452', s:term_white, s:term_grey ], [ '#61afef', '#292c33', s:term_blue, s:term_black ] ] +let s:p.replace.left = [ [ '#292c33', '#e06c75', s:term_black, s:term_red, 'bold' ], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] +let s:p.replace.right = [ [ '#292c33', '#e06c75', s:term_black, s:term_red ], s:p.normal.right[1], [ '#e06c75', '#292c33', s:term_red, s:term_black ] ] +let s:p.visual.left = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple, 'bold' ], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] +let s:p.visual.right = [ [ '#292c33', '#c678dd', s:term_black, s:term_purple ], s:p.normal.right[1], [ '#c678dd', '#292c33', s:term_purple, s:term_black ] ] +let s:p.normal.middle = [ [ '#abb2bf', '#292c33', s:term_white, s:term_black ] ] +let s:p.insert.middle = s:p.normal.middle +let s:p.replace.middle = s:p.normal.middle +let s:p.tabline.left = [ s:p.normal.left[1] ] +let s:p.tabline.tabsel = [ s:p.normal.left[0] ] +let s:p.tabline.middle = s:p.normal.middle +let s:p.tabline.right = [ s:p.normal.left[1] ] +let s:p.normal.error = [ [ '#292c33', '#e06c75', s:term_black, s:term_red ] ] +let s:p.normal.warning = [ [ '#292c33', '#e5c07b', s:term_black, s:term_yellow ] ] + +let g:lightline#colorscheme#deus#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim new file mode 100644 index 00000000..b70711d1 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/jellybeans.vim @@ -0,0 +1,41 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/jellybeans.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:59:15. +" ============================================================================= + +let s:base03 = [ '#151513', 233 ] +let s:base02 = [ '#30302c', 236 ] +let s:base01 = [ '#4e4e43', 239 ] +let s:base00 = [ '#666656', 242 ] +let s:base0 = [ '#808070', 244 ] +let s:base1 = [ '#949484', 246 ] +let s:base2 = [ '#a8a897', 248 ] +let s:base3 = [ '#e8e8d3', 253 ] +let s:yellow = [ '#ffb964', 215 ] +let s:orange = [ '#fad07a', 222 ] +let s:red = [ '#cf6a4c', 167 ] +let s:magenta = [ '#f0a0c0', 217 ] +let s:blue = [ '#8197bf', 103 ] +let s:cyan = [ '#8fbfdc', 110 ] +let s:green = [ '#99ad6a', 107 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base02, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base0, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base00, s:base02 ] ] +let s:p.tabline.left = copy(s:p.normal.middle) +let s:p.tabline.tabsel = [ [ s:base3, s:base00 ] ] +let s:p.tabline.middle = copy(s:p.normal.middle) +let s:p.tabline.right = copy(s:p.tabline.middle) +let s:p.normal.error = [ [ s:red, s:base02 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] + +let g:lightline#colorscheme#jellybeans#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim new file mode 100644 index 00000000..68d09209 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/landscape.vim @@ -0,0 +1,25 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/landscape.vim +" Author: itchyny +" License: MIT License +" Last Change: 2015/11/26 21:49:44. +" ============================================================================= + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ ['#0000ff', '#ffffff', 21, 231, 'bold' ], [ '#ffffff', '#0000ff', 231, 21 ] ] +let s:p.normal.right = [ [ '#303030', '#d0d0d0', 236, 252 ], [ '#303030', '#8a8a8a', 236, 245 ], [ '#bcbcbc', '#585858', 250, 240 ] ] +let s:p.inactive.right = [ [ '#121212', '#606060', 233, 241 ], [ '#121212', '#3a3a3a', 233, 237 ], [ '#121212', '#262626', 233, 235 ] ] +let s:p.inactive.left = s:p.inactive.right[1:] +let s:p.insert.left = [ ['#005f00', '#ffffff', 22, 231, 'bold' ], [ '#ffffff', '#005f00', 231, 22 ] ] +let s:p.replace.left = [ [ '#af0000', '#ffffff', 124, 231, 'bold' ], [ '#ffffff', '#af0000', 231, 124 ] ] +let s:p.visual.left = [ [ '#5f00ff', '#ffffff', 57, 231, 'bold' ], [ '#ffffff', '#5f00ff', 231, 57 ] ] +let s:p.normal.middle = [ [ '#8a8a8a', '#303030', 245, 236 ] ] +let s:p.inactive.middle = [ [ '#303030', '#121212', 236, 233 ] ] +let s:p.tabline.left = [ [ '#d0d0d0', '#666666', 252, 242 ] ] +let s:p.tabline.tabsel = [ [ '#dadada', '#121212', 253, 233 ] ] +let s:p.tabline.middle = [ [ '#8a8a8a', '#3a3a3a', 245, 237 ] ] +let s:p.tabline.right = [ [ '#d0d0d0', '#666666', 252, 242 ] ] +let s:p.normal.error = [ [ '#d0d0d0', '#ff0000', 252, 196 ] ] +let s:p.normal.warning = [ [ '#262626', '#ffff00', 235, 226 ] ] + +let g:lightline#colorscheme#landscape#palette = s:p diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/materia.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/materia.vim new file mode 100644 index 00000000..fdab2cbb --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/materia.vim @@ -0,0 +1,63 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/materia.vim +" Author: Lokesh Krishna +" License: MIT License +" Last Change: 2017/11/25 11:13:40. +" ============================================================================= + +" Common colors +let s:fg = '#d5dbe5' +let s:blue = '#89ddff' +let s:green = '#8bd649' +let s:purple = '#82aaff' +let s:red1 = '#ec5f67' +let s:red2 = '#ec5f67' +let s:yellow = '#ffcc00' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +if lightline#colorscheme#background() ==# 'light' + " Light variant + let s:bg = '#ffffff' + let s:gray1 = '#2c393f' + let s:gray2 = '#d5dbe5' + let s:gray3 = '#707880' + + let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ] + let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] + let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ] + let s:p.inactive.right = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] + let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ] +else + " Dark variant + let s:bg = '#263238' + let s:gray1 = '#37474f' + let s:gray2 = '#2c393f' + let s:gray3 = '#37474f' + + let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] + let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] + let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ] + let s:p.inactive.right = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] + let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +endif + +" Common +let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:bg, s:green, 'bold' ] ] +let s:p.normal.error = [ [ s:red2, s:bg ] ] +let s:p.normal.warning = [ [ s:yellow, s:bg ] ] +let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:bg, s:blue, 'bold' ] ] +let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:bg, s:red1, 'bold' ] ] +let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:bg, s:purple, 'bold' ] ] +let s:p.tabline.left = [ [ s:bg, s:gray3 ] ] +let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ] +let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ] +let s:p.tabline.right = copy(s:p.normal.right) + +let g:lightline#colorscheme#materia#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/material.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/material.vim new file mode 100644 index 00000000..0d704b7d --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/material.vim @@ -0,0 +1,63 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/material.vim +" Author: Lokesh Krishna +" License: MIT License +" Last Change: 2017/11/25 11:13:42. +" ============================================================================= + +" Common colors +let s:fg = '#eeffff' +let s:blue = '#82aaff' +let s:green = '#c3e88d' +let s:purple = '#c792ea' +let s:red1 = '#f07178' +let s:red2 = '#ff5370' +let s:yellow = '#ffcb6b' + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +if lightline#colorscheme#background() ==# 'light' + " Light variant + let s:bg = '#ffffff' + let s:gray1 = '#2e3c43' + let s:gray2 = '#eeffff' + let s:gray3 = '#546e7a' + + let s:p.normal.left = [ [ s:bg, s:blue, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.normal.middle = [ [ s:gray1, s:gray2 ] ] + let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] + let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ] + let s:p.inactive.right = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] + let s:p.insert.left = [ [ s:bg, s:green, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:gray1, s:gray3 ] ] + let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:gray1, s:gray3 ] ] +else + " Dark variant + let s:bg = '#263238' + let s:gray1 = '#314549' + let s:gray2 = '#2E3C43' + let s:gray3 = '#314549' + + let s:p.normal.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] + let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] + let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ] + let s:p.inactive.right = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] + let s:p.insert.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] + let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +endif + +" Common +let s:p.normal.right = [ [ s:bg, s:blue, 'bold' ], [ s:bg, s:blue, 'bold' ] ] +let s:p.normal.error = [ [ s:red2, s:bg ] ] +let s:p.normal.warning = [ [ s:yellow, s:bg ] ] +let s:p.insert.right = [ [ s:bg, s:green, 'bold' ], [ s:bg, s:green, 'bold' ] ] +let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:bg, s:red1, 'bold' ] ] +let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:bg, s:purple, 'bold' ] ] +let s:p.tabline.left = [ [ s:fg, s:gray3 ] ] +let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ] +let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ] +let s:p.tabline.right = [ [ s:bg, s:red1, 'bold' ] ] + +let g:lightline#colorscheme#material#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim new file mode 100644 index 00000000..ed67adb9 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/molokai.vim @@ -0,0 +1,35 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/molokai.vim +" Author: challsted +" License: MIT License +" Last Change: 2022/03/15 23:58:40. +" ============================================================================= + +let s:black = [ '#232526', 233 ] +let s:gray = [ '#808080', 244 ] +let s:white = [ '#f8f8f2', 234 ] +let s:cyan = [ '#66d9ef', 81 ] +let s:green = [ '#a6e22e', 118 ] +let s:orange = [ '#ef5939', 166 ] +let s:pink = [ '#f92672', 161 ] +let s:red = [ '#ff0000', 160 ] +let s:yellow = [ '#e6db74', 229 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:black, s:cyan ], [ s:orange, s:black ] ] +let s:p.normal.middle = [ [ s:orange, s:black ] ] +let s:p.normal.right = [ [ s:pink, s:black ], [ s:black, s:pink ] ] +let s:p.normal.error = [ [ s:pink, s:black ] ] +let s:p.normal.warning = [ [ s:yellow, s:black ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:green, s:black ] ] +let s:p.visual.left = [ [ s:black, s:yellow ], [ s:yellow, s:black ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:red, s:black ] ] +let s:p.inactive.left = [ [ s:pink, s:black ], [ s:white, s:black ] ] +let s:p.inactive.middle = [ [ s:gray, s:black ] ] +let s:p.inactive.right = [ [ s:white, s:pink ], [ s:pink, s:black ] ] +let s:p.tabline.left = [ [ s:pink, s:black ] ] +let s:p.tabline.middle = [ [ s:pink, s:black] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.tabline.tabsel = [ [ s:black, s:pink ] ] + +let g:lightline#colorscheme#molokai#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/nord.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/nord.vim new file mode 100644 index 00000000..96d24aee --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/nord.vim @@ -0,0 +1,46 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/nord.vim +" Author: arcticicestudio +" License: MIT +" Last Change: 2017/11/12 20:27:51 +" ============================================================================= + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:nord0 = ["#2E3440", "NONE"] +let s:nord1 = ["#3B4252", 0] +let s:nord2 = ["#434C5E", "NONE"] +let s:nord3 = ["#4C566A", 8] +let s:nord4 = ["#D8DEE9", "NONE"] +let s:nord5 = ["#E5E9F0", 7] +let s:nord6 = ["#ECEFF4", 15] +let s:nord7 = ["#8FBCBB", 14] +let s:nord8 = ["#88C0D0", 6] +let s:nord9 = ["#81A1C1", 4] +let s:nord10 = ["#5E81AC", 12] +let s:nord11 = ["#BF616A", 1] +let s:nord12 = ["#D08770", 11] +let s:nord13 = ["#EBCB8B", 3] +let s:nord14 = ["#A3BE8C", 2] +let s:nord15 = ["#B48EAD", 5] + +let s:p.normal.left = [ [ s:nord1, s:nord8 ], [ s:nord5, s:nord1 ] ] +let s:p.normal.middle = [ [ s:nord5, s:nord3 ] ] +let s:p.normal.right = [ [ s:nord5, s:nord1 ], [ s:nord5, s:nord1 ] ] +let s:p.normal.warning = [ [ s:nord1, s:nord13 ] ] +let s:p.normal.error = [ [ s:nord1, s:nord11 ] ] + +let s:p.inactive.left = [ [ s:nord1, s:nord8 ], [ s:nord5, s:nord1 ] ] +let s:p.inactive.middle = [ [ s:nord5, s:nord1 ] ] +let s:p.inactive.right = [ [ s:nord5, s:nord1 ], [ s:nord5, s:nord1 ] ] + +let s:p.insert.left = [ [ s:nord1, s:nord6 ], [ s:nord5, s:nord1 ] ] +let s:p.replace.left = [ [ s:nord1, s:nord13 ], [ s:nord5, s:nord1 ] ] +let s:p.visual.left = [ [ s:nord1, s:nord7 ], [ s:nord5, s:nord1 ] ] + +let s:p.tabline.left = [ [ s:nord5, s:nord3 ] ] +let s:p.tabline.middle = [ [ s:nord5, s:nord3 ] ] +let s:p.tabline.right = [ [ s:nord5, s:nord3 ] ] +let s:p.tabline.tabsel = [ [ s:nord1, s:nord8 ] ] + +let g:lightline#colorscheme#nord#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim new file mode 100644 index 00000000..b986acf6 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/one.vim @@ -0,0 +1,60 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/one.vim +" Author: Zoltan Dalmadi +" License: MIT License +" Last Change: 2019/09/09 22:42:48. +" ============================================================================= + +" Common colors +let s:blue = [ '#61afef', 75 ] +let s:green = [ '#98c379', 76 ] +let s:purple = [ '#c678dd', 176 ] +let s:red1 = [ '#e06c75', 168 ] +let s:red2 = [ '#be5046', 168 ] +let s:yellow = [ '#e5c07b', 180 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +if lightline#colorscheme#background() ==# 'light' + " Light variant + let s:fg = [ '#494b53', 238 ] + let s:bg = [ '#fafafa', 255 ] + let s:gray1 = [ '#494b53', 238 ] + let s:gray2 = [ '#f0f0f0', 255 ] + let s:gray3 = [ '#d0d0d0', 250 ] + let s:green = [ '#98c379', 35 ] + + let s:p.inactive.left = [ [ s:bg, s:gray3 ], [ s:bg, s:gray3 ] ] + let s:p.inactive.middle = [ [ s:gray3, s:gray2 ] ] + let s:p.inactive.right = [ [ s:bg, s:gray3 ] ] +else + " Dark variant + let s:fg = [ '#abb2bf', 145 ] + let s:bg = [ '#282c34', 235 ] + let s:gray1 = [ '#5c6370', 241 ] + let s:gray2 = [ '#2c323d', 235 ] + let s:gray3 = [ '#3e4452', 240 ] + + let s:p.inactive.left = [ [ s:gray1, s:bg ], [ s:gray1, s:bg ] ] + let s:p.inactive.middle = [ [ s:gray1, s:gray2 ] ] + let s:p.inactive.right = [ [ s:gray1, s:bg ] ] +endif + +" Common +let s:p.normal.left = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.normal.middle = [ [ s:fg, s:gray2 ] ] +let s:p.normal.right = [ [ s:bg, s:green, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.normal.error = [ [ s:red2, s:bg ] ] +let s:p.normal.warning = [ [ s:yellow, s:bg ] ] +let s:p.insert.right = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.insert.left = [ [ s:bg, s:blue, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.replace.right = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.replace.left = [ [ s:bg, s:red1, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.visual.right = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.visual.left = [ [ s:bg, s:purple, 'bold' ], [ s:fg, s:gray3 ] ] +let s:p.tabline.left = [ [ s:fg, s:gray3 ] ] +let s:p.tabline.tabsel = [ [ s:bg, s:purple, 'bold' ] ] +let s:p.tabline.middle = [ [ s:gray3, s:gray2 ] ] +let s:p.tabline.right = copy(s:p.normal.right) + +let g:lightline#colorscheme#one#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim new file mode 100644 index 00000000..40e48d43 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerline.vim @@ -0,0 +1,28 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/powerline.vim +" Author: itchyny +" License: MIT License +" Last Change: 2013/09/07 15:54:41. +" ============================================================================= + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ ['darkestgreen', 'brightgreen', 'bold'], ['white', 'gray4'] ] +let s:p.normal.right = [ ['gray5', 'gray10'], ['gray9', 'gray4'], ['gray8', 'gray2'] ] +let s:p.inactive.right = [ ['gray1', 'gray5'], ['gray4', 'gray1'], ['gray4', 'gray0'] ] +let s:p.inactive.left = s:p.inactive.right[1:] +let s:p.insert.left = [ ['darkestcyan', 'white', 'bold'], ['white', 'darkblue'] ] +let s:p.insert.right = [ [ 'darkestcyan', 'mediumcyan' ], [ 'mediumcyan', 'darkblue' ], [ 'mediumcyan', 'darkestblue' ] ] +let s:p.replace.left = [ ['white', 'brightred', 'bold'], ['white', 'gray4'] ] +let s:p.visual.left = [ ['darkred', 'brightorange', 'bold'], ['white', 'gray4'] ] +let s:p.normal.middle = [ [ 'gray7', 'gray2' ] ] +let s:p.insert.middle = [ [ 'mediumcyan', 'darkestblue' ] ] +let s:p.replace.middle = s:p.normal.middle +let s:p.replace.right = s:p.normal.right +let s:p.tabline.left = [ [ 'gray9', 'gray4' ] ] +let s:p.tabline.tabsel = [ [ 'gray9', 'gray1' ] ] +let s:p.tabline.middle = [ [ 'gray2', 'gray8' ] ] +let s:p.tabline.right = [ [ 'gray9', 'gray3' ] ] +let s:p.normal.error = [ [ 'gray9', 'brightestred' ] ] +let s:p.normal.warning = [ [ 'gray1', 'yellow' ] ] + +let g:lightline#colorscheme#powerline#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerlineish.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerlineish.vim new file mode 100644 index 00000000..34058a87 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/powerlineish.vim @@ -0,0 +1,28 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/powerlineish.vim +" Author: itchyny +" License: MIT License +" Last Change: 2019/06/12 18:47:00. +" ============================================================================= + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ ['darkestgreen', 'brightgreen', 'bold'], ['white', 'gray0'] ] +let s:p.normal.right = [ ['gray10', 'gray2'], ['white', 'gray1'], ['white', 'gray0'] ] +let s:p.inactive.right = [ ['gray1', 'gray5'], ['gray4', 'gray1'], ['gray4', 'gray0'] ] +let s:p.inactive.left = s:p.inactive.right[1:] +let s:p.insert.left = [ ['darkestcyan', 'white', 'bold'], ['mediumcyan', 'darkestblue'] ] +let s:p.insert.right = [ [ 'darkestblue', 'mediumcyan' ], [ 'mediumcyan', 'darkblue' ], [ 'mediumcyan', 'darkestblue' ] ] +let s:p.replace.left = [ ['white', 'brightred', 'bold'], ['white', 'gray0'] ] +let s:p.visual.left = [ ['black', 'brightestorange', 'bold'], ['white', 'gray0'] ] +let s:p.normal.middle = [ [ 'white', 'gray0' ] ] +let s:p.insert.middle = [ [ 'mediumcyan', 'darkestblue' ] ] +let s:p.replace.middle = s:p.normal.middle +let s:p.replace.right = s:p.normal.right +let s:p.tabline.left = [ [ 'gray9', 'gray0' ] ] +let s:p.tabline.tabsel = [ [ 'gray9', 'gray2' ] ] +let s:p.tabline.middle = [ [ 'gray2', 'gray0' ] ] +let s:p.tabline.right = [ [ 'gray9', 'gray1' ] ] +let s:p.normal.error = [ [ 'gray9', 'brightestred' ] ] +let s:p.normal.warning = [ [ 'gray1', 'yellow' ] ] + +let g:lightline#colorscheme#powerlineish#palette = lightline#colorscheme#fill(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim new file mode 100644 index 00000000..fcea1e53 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/rosepine.vim @@ -0,0 +1,58 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/rosepine.vim +" Author: sheruost +" License: MIT License +" Last Change: 2022/05/09 23:27:50. +" ============================================================================= + +" Reference: https://rosepinetheme.com/palette +if lightline#colorscheme#background() ==# 'light' + " Rosé Pine Dawn + let s:base = [ '#faf4ed', 255 ] + let s:surface = [ '#fffaf3', 255 ] + + let s:overlay = [ '#f2e9e1', 254 ] + let s:highlight_m = [ '#dfdad9', 145 ] + let s:muted = [ '#9893a5', 103 ] + let s:subtle = [ '#797593', 102 ] + + let s:iris = [ '#907aa9', 139 ] + let s:pine = [ '#286983', 24 ] + let s:foam = [ '#56949f', 67 ] + let s:rose = [ '#d7827e', 174 ] + let s:love = [ '#b4637a', 132 ] +else + " Rosé Pine + let s:base = [ '#191724', 233 ] + let s:surface = [ '#1f1d2e', 234 ] + + let s:overlay = [ '#26233a', 235 ] + let s:highlight_m = [ '#403d52', 59 ] + let s:muted = [ '#6e6a86', 60 ] + let s:subtle = [ '#908caa', 103 ] + + let s:iris = [ '#c4a7e7', 182 ] + let s:pine = [ '#31748f', 30 ] + let s:foam = [ '#9ccfd8', 152 ] + let s:rose = [ '#ebbcba', 217 ] + let s:love = [ '#eb6f92', 204 ] +endif + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base, s:pine ], [ s:subtle, s:surface ] ] +let s:p.normal.right = [ [ s:overlay, s:subtle ], [ s:muted, s:overlay ], [ s:highlight_m, s:surface ] ] +let s:p.inactive.right = [ [ s:base, s:surface ], [ s:overlay, s:base ] ] +let s:p.inactive.left = [ [ s:overlay, s:base ], [ s:surface, s:base ] ] +let s:p.insert.left = [ [ s:base, s:foam ], [ s:subtle, s:surface ] ] +let s:p.replace.left = [ [ s:base, s:love ], [ s:subtle, s:surface ] ] +let s:p.visual.left = [ [ s:base, s:iris ], [ s:subtle, s:surface ] ] +let s:p.normal.middle = [ [ s:overlay, s:base ] ] +let s:p.inactive.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.left = [ [ s:subtle, s:base ] ] +let s:p.tabline.tabsel = [ [ s:pine, s:base ] ] +let s:p.tabline.middle = [ [ s:surface, s:base ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:love, s:base ] ] +let s:p.normal.warning = [ [ s:rose, s:surface ] ] + +let g:lightline#colorscheme#rosepine#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim new file mode 100644 index 00000000..dc95139b --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_black.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_black.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:56:50. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-black +let s:bg_1 = ['#252525', 0] +let s:bg_2 = ['#3b3b3b', 8] +let s:dim_0 = ['#777777', 7] +let s:red = ['#ed4a46', 1] +let s:green = ['#70b433', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#368aeb', 4] +let s:magenta = ['#eb6eb7', 5] +let s:cyan = ['#3fc5b7', 6] +let s:brred = ['#ff5e56', 9] +let s:brgreen = ['#83c746', 10] +let s:bryellow = ['#efc541', 11] +let s:brblue = ['#4f9cfe', 12] +let s:brmagenta = ['#ff81ca', 13] +let s:brcyan = ['#56d8c9', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_black#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim new file mode 100644 index 00000000..c3238384 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_dark.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_dark.vim +" Author: Charles Hall +" License: MIT License +" Last Change: 2020/05/02 16:53:17. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-dark +let s:bg_1 = ['#184956', 0] +let s:bg_2 = ['#2d5b69', 8] +let s:dim_0 = ['#72898f', 7] +let s:red = ['#fa5750', 1] +let s:green = ['#75b938', 2] +let s:yellow = ['#dbb32d', 3] +let s:blue = ['#4695f7', 4] +let s:magenta = ['#f275be', 5] +let s:cyan = ['#41c7b9', 6] +let s:brred = ['#ff665c', 9] +let s:brgreen = ['#84c747', 10] +let s:bryellow = ['#ebc13d', 11] +let s:brblue = ['#58a3ff', 12] +let s:brmagenta = ['#ff84cd', 13] +let s:brcyan = ['#53d6c7', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_dark#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim new file mode 100644 index 00000000..979149d2 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_light.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/selenized_light.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/02 16:58:00. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-light +let s:bg_1 = ['#ece3cc', 0] +let s:bg_2 = ['#d5cdb6', 8] +let s:dim_0 = ['#909995', 7] +let s:red = ['#d2212d', 1] +let s:green = ['#489100', 2] +let s:yellow = ['#ad8900', 3] +let s:blue = ['#0072d4', 4] +let s:magenta = ['#ca4898', 5] +let s:cyan = ['#009c8f', 6] +let s:brred = ['#cc1729', 9] +let s:brgreen = ['#428b00', 10] +let s:bryellow = ['#a78300', 11] +let s:brblue = ['#006dce', 12] +let s:brmagenta = ['#c44392', 13] +let s:brcyan = ['#00978a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_light#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim new file mode 100644 index 00000000..9da3a4e3 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/selenized_white.vim @@ -0,0 +1,49 @@ +" ============================================================================= +" Filename: autoload/whiteline/colorscheme/selenized_white.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/05/03 19:34:07. +" ============================================================================= + +" https://github.com/jan-warchol/selenized/blob/master/the-values.md#selenized-white +let s:bg_1 = ['#ebebeb', 0] +let s:bg_2 = ['#cdcdcd', 8] +let s:dim_0 = ['#878787', 7] +let s:red = ['#d6000c', 1] +let s:green = ['#1d9700', 2] +let s:yellow = ['#c49700', 3] +let s:blue = ['#0064e4', 4] +let s:magenta = ['#dd0f9d', 5] +let s:cyan = ['#00ad9c', 6] +let s:brred = ['#bf0000', 9] +let s:brgreen = ['#008400', 10] +let s:bryellow = ['#af8500', 11] +let s:brblue = ['#0054cf', 12] +let s:brmagenta = ['#c7008b', 13] +let s:brcyan = ['#009a8a', 14] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} + +let s:p.normal.right = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.normal.left = [[ s:bg_1, s:blue ], [ s:cyan, s:bg_2 ]] +let s:p.normal.middle = [[ s:dim_0, s:bg_1 ]] +let s:p.normal.error = [[ s:bg_1, s:red ]] +let s:p.normal.warning = [[ s:bg_1, s:yellow ]] + +let s:p.insert.right = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.insert.left = [[ s:bg_1, s:green ], [ s:cyan, s:bg_2 ]] + +let s:p.visual.right = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.visual.left = [[ s:bg_1, s:magenta ], [ s:cyan, s:bg_2 ]] + +let s:p.inactive.left = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] +let s:p.inactive.right = [[ s:brblue, s:bg_2 ], [ s:cyan, s:bg_2 ]] + +let s:p.replace.right = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ], [ s:dim_0, s:bg_1 ]] +let s:p.replace.left = [[ s:bg_1, s:red ], [ s:cyan, s:bg_2 ]] + +let s:p.tabline.right = [[ s:bg_1, s:red ]] +let s:p.tabline.left = [[ s:cyan, s:bg_2 ]] +let s:p.tabline.tabsel = [[ s:bg_1, s:blue ]] + +let g:lightline#colorscheme#selenized_white#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim new file mode 100644 index 00000000..fc2f84d9 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/seoul256.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/seoul256.vim +" Author: atweiden +" License: MIT License +" Last Change: 2022/03/15 23:58:59. +" ============================================================================= + +let s:base03 = [ '#151513', 233 ] +let s:base02 = [ '#30302c', 236 ] +let s:base01 = [ '#4e4e43', 239 ] +let s:base00 = [ '#666656', 242 ] +let s:base0 = [ '#808070', 244 ] +let s:base1 = [ '#949484', 246 ] +let s:base2 = [ '#a8a897', 248 ] +let s:base3 = [ '#e8e8d3', 253 ] +let s:yellow = [ '#d8af5f', 3 ] +let s:orange = [ '#d7875f', 216 ] +let s:red = [ '#d68787', 131 ] +let s:magenta = [ '#df5f87', 168 ] +let s:peach = [ '#d7afaf', 181 ] +let s:blue = [ '#87afaf', 109 ] +let s:cyan = [ '#87d7d7', 23 ] +let s:green = [ '#87af87', 108 ] +let s:white = [ '#d0d0d0', 252 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:peach ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base0, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base00, s:base02 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:base02 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] + +let g:lightline#colorscheme#seoul256#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim new file mode 100644 index 00000000..db2d3758 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/simpleblack.vim @@ -0,0 +1,43 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/simpleblack.vim +" Author: lucasprag +" License: MIT License +" Last Change: 2022/03/15 23:58:35. +" ============================================================================= + +let s:black = [ '#000000', '0' ] +let s:black2 = [ '#121212', '233' ] + +let s:gray = [ '#262626', '235' ] +let s:gray2 = [ '#3a3a3a', '237' ] +let s:gray3 = [ '#4e4e4e', '239' ] +let s:gray4 = [ '#626262', '241' ] + +let s:violet = [ '#cf73e6', '170' ] + +let s:blue = [ '#5f87af', '67' ] +let s:blue2 = [ '#91aadf', '110' ] + +let s:green = [ '#57ba37', '71' ] +let s:gold = [ '#f0d50c', '220' ] +let s:red = [ '#d70000', '160' ] +let s:none = [ 'NONE', 'NONE' ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:black, s:blue ], [ s:gray4, s:black2 ] ] +let s:p.normal.right = [ [ s:gray, s:gray4 ], [ s:gray3, s:gray ], [ s:gray2, s:black2 ] ] +let s:p.inactive.right = [ [ s:black, s:black2 ], [ s:gray, s:black ] ] +let s:p.inactive.left = [ [ s:gray, s:black ], [ s:black2, s:black ] ] +let s:p.insert.left = [ [ s:black, s:green ], [ s:gray4, s:black2 ] ] +let s:p.replace.left = [ [ s:black, s:red ], [ s:gray4, s:black2 ] ] +let s:p.visual.left = [ [ s:black, s:violet ], [ s:gray4, s:black2 ] ] +let s:p.normal.middle = [ [ s:gray, s:black ] ] +let s:p.inactive.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.left = [ [ s:gray4, s:black ] ] +let s:p.tabline.tabsel = [ [ s:blue, s:black ] ] +let s:p.tabline.middle = [ [ s:black2, s:black ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:black ] ] +let s:p.normal.warning = [ [ s:gold, s:black2 ] ] + +let g:lightline#colorscheme#simpleblack#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim new file mode 100644 index 00000000..53788311 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/solarized.vim @@ -0,0 +1,80 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/solarized.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/04/06 19:22:53. +" ============================================================================= + +let s:cuicolors = { + \ 'base03': [ '8', '234', 'DarkGray' ], + \ 'base02': [ '0', '235', 'Black' ], + \ 'base01': [ '10', '239', 'LightGreen' ], + \ 'base00': [ '11', '240', 'LightYellow' ], + \ 'base0': [ '12', '244', 'LightBlue' ], + \ 'base1': [ '14', '245', 'LightCyan' ], + \ 'base2': [ '7', '187', 'LightGray' ], + \ 'base3': [ '15', '230', 'White' ], + \ 'yellow': [ '3', '136', 'DarkYellow' ], + \ 'orange': [ '9', '166', 'LightRed' ], + \ 'red': [ '1', '124', 'DarkRed' ], + \ 'magenta': [ '5', '125', 'DarkMagenta' ], + \ 'violet': [ '13', '61', 'LightMagenta' ], + \ 'blue': [ '4', '33', 'DarkBlue' ], + \ 'cyan': [ '6', '37', 'DarkCyan' ], + \ 'green': [ '2', '64', 'DarkGreen' ], + \ } + +" The following condition only applies for the console and is the same +" condition vim-colors-solarized uses to determine which set of colors +" to use. +let s:solarized_termcolors = get(g:, 'solarized_termcolors', 256) +if s:solarized_termcolors != 256 && &t_Co >= 16 + let s:cuiindex = 0 +elseif s:solarized_termcolors == 256 + let s:cuiindex = 1 +else + let s:cuiindex = 2 +endif + +let s:base03 = [ '#002b36', s:cuicolors.base03[s:cuiindex] ] +let s:base02 = [ '#073642', s:cuicolors.base02[s:cuiindex] ] +let s:base01 = [ '#586e75', s:cuicolors.base01[s:cuiindex] ] +let s:base00 = [ '#657b83', s:cuicolors.base00[s:cuiindex] ] +let s:base0 = [ '#839496', s:cuicolors.base0[s:cuiindex] ] +let s:base1 = [ '#93a1a1', s:cuicolors.base1[s:cuiindex] ] +let s:base2 = [ '#eee8d5', s:cuicolors.base2[s:cuiindex] ] +let s:base3 = [ '#fdf6e3', s:cuicolors.base3[s:cuiindex] ] +let s:yellow = [ '#b58900', s:cuicolors.yellow[s:cuiindex] ] +let s:orange = [ '#cb4b16', s:cuicolors.orange[s:cuiindex] ] +let s:red = [ '#dc322f', s:cuicolors.red[s:cuiindex] ] +let s:magenta = [ '#d33682', s:cuicolors.magenta[s:cuiindex] ] +let s:violet = [ '#6c71c4', s:cuicolors.violet[s:cuiindex] ] +let s:blue = [ '#268bd2', s:cuicolors.blue[s:cuiindex] ] +let s:cyan = [ '#2aa198', s:cuicolors.cyan[s:cuiindex] ] +let s:green = [ '#859900', s:cuicolors.green[s:cuiindex] ] + +if lightline#colorscheme#background() ==# 'light' + let [ s:base03, s:base3 ] = [ s:base3, s:base03 ] + let [ s:base02, s:base2 ] = [ s:base2, s:base02 ] + let [ s:base01, s:base1 ] = [ s:base1, s:base01 ] + let [ s:base00, s:base0 ] = [ s:base0, s:base00 ] +endif + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base03, s:blue ], [ s:base03, s:base00 ] ] +let s:p.normal.right = [ [ s:base03, s:base1 ], [ s:base03, s:base00 ] ] +let s:p.inactive.right = [ [ s:base03, s:base00 ], [ s:base0, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base0, s:base02 ] ] +let s:p.insert.left = [ [ s:base03, s:green ], [ s:base03, s:base00 ] ] +let s:p.replace.left = [ [ s:base03, s:red ], [ s:base03, s:base00 ] ] +let s:p.visual.left = [ [ s:base03, s:magenta ], [ s:base03, s:base00 ] ] +let s:p.normal.middle = [ [ s:base1, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base01, s:base02 ] ] +let s:p.tabline.left = [ [ s:base03, s:base00 ] ] +let s:p.tabline.tabsel = [ [ s:base03, s:base1 ] ] +let s:p.tabline.middle = [ [ s:base0, s:base02 ] ] +let s:p.tabline.right = copy(s:p.tabline.left) +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base03, s:yellow ] ] + +let g:lightline#colorscheme#solarized#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim new file mode 100644 index 00000000..49eadc22 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/srcery_drk.vim @@ -0,0 +1,45 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/srcery_drk.vim +" Author: Christopher Vittal +" License: MIT License +" Last Change: 2018/05/19 +" ============================================================================= + +let s:base03 = [ '#151513', 233 ] +let s:base02 = [ '#30302c', 236 ] +let s:base01 = [ '#4e4e43', 239 ] +let s:base00 = [ '#666656', 242 ] +let s:base0 = [ '#808070', 244 ] +let s:base1 = [ '#949484', 246 ] +let s:base2 = [ '#a8a897', 248 ] +let s:base3 = [ '#e8e8d3', 253 ] +let s:yellow = [ '#fbb829', 3 ] +let s:orange = [ '#d75f00', 166 ] +let s:red = [ '#ff3128', 1 ] +let s:magenta = [ '#e02c6d', 5 ] +let s:bright_magenta = [ '#e35682', 13 ] +let s:blue = [ '#5573a3', 4 ] +let s:bright_blue = [ '#8eb2f7', 12 ] +let s:cyan = [ '#0aaeb3', 6 ] +let s:green = [ '#519f50', 2 ] +let s:bright_green = [ '#98bc37', 10 ] +let s:white = [ '#fce8c3', 15 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:bright_blue, 'bold' ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base1 ], [ s:base2, s:base01 ] ] +let s:p.inactive.right = [ [ s:base02, s:base00 ], [ s:base0, s:base02 ] ] +let s:p.inactive.left = [ [ s:base0, s:base02 ], [ s:base00, s:base02 ] ] +let s:p.insert.left = [ [ s:base02, s:bright_green, 'bold' ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base3, s:red, 'bold' ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base3, s:bright_magenta, 'bold' ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base0, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base00, s:base02 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00, 'bold'] ] +let s:p.tabline.tabsel = [ [ s:base3, s:base02 ] ] +let s:p.tabline.middle = [ [ s:base01, s:base1 ] ] +let s:p.tabline.right = copy(s:p.normal.right) +let s:p.normal.error = [ [ s:red, s:base02 ] ] +let s:p.normal.warning = [ [ s:yellow, s:base01 ] ] + +let g:lightline#colorscheme#srcery_drk#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim new file mode 100644 index 00000000..9d0bdd59 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colorscheme/wombat.vim @@ -0,0 +1,42 @@ +" ============================================================================= +" Filename: autoload/lightline/colorscheme/wombat.vim +" Author: itchyny +" License: MIT License +" Last Change: 2022/03/15 23:59:09. +" ============================================================================= + +let s:base03 = [ '#242424', 235 ] +let s:base023 = [ '#353535', 236 ] +let s:base02 = [ '#444444', 238 ] +let s:base01 = [ '#585858', 240 ] +let s:base00 = [ '#666666', 242 ] +let s:base0 = [ '#808080', 244 ] +let s:base1 = [ '#969696', 247 ] +let s:base2 = [ '#a8a8a8', 248 ] +let s:base3 = [ '#d0d0d0', 252 ] +let s:yellow = [ '#cae682', 180 ] +let s:orange = [ '#e5786d', 173 ] +let s:red = [ '#e5786d', 203 ] +let s:magenta = [ '#f2c68a', 216 ] +let s:blue = [ '#8ac6f2', 117 ] +let s:cyan = s:blue +let s:green = [ '#95e454', 119 ] + +let s:p = {'normal': {}, 'inactive': {}, 'insert': {}, 'replace': {}, 'visual': {}, 'tabline': {}} +let s:p.normal.left = [ [ s:base02, s:blue ], [ s:base3, s:base01 ] ] +let s:p.normal.right = [ [ s:base02, s:base0 ], [ s:base1, s:base01 ] ] +let s:p.inactive.right = [ [ s:base023, s:base01 ], [ s:base00, s:base02 ] ] +let s:p.inactive.left = [ [ s:base1, s:base02 ], [ s:base00, s:base023 ] ] +let s:p.insert.left = [ [ s:base02, s:green ], [ s:base3, s:base01 ] ] +let s:p.replace.left = [ [ s:base023, s:red ], [ s:base3, s:base01 ] ] +let s:p.visual.left = [ [ s:base02, s:magenta ], [ s:base3, s:base01 ] ] +let s:p.normal.middle = [ [ s:base2, s:base02 ] ] +let s:p.inactive.middle = [ [ s:base1, s:base023 ] ] +let s:p.tabline.left = [ [ s:base3, s:base00 ] ] +let s:p.tabline.tabsel = [ [ s:base3, s:base03 ] ] +let s:p.tabline.middle = [ [ s:base2, s:base02 ] ] +let s:p.tabline.right = [ [ s:base2, s:base00 ] ] +let s:p.normal.error = [ [ s:base03, s:red ] ] +let s:p.normal.warning = [ [ s:base023, s:yellow ] ] + +let g:lightline#colorscheme#wombat#palette = lightline#colorscheme#flatten(s:p) diff --git a/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim new file mode 100644 index 00000000..6cdddd8d --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/colortable.vim @@ -0,0 +1,52 @@ +" ============================================================================= +" Filename: autoload/lightline/colortable.vim +" Author: itchyny +" License: MIT License +" Last Change: 2020/06/19 11:07:13. +" ============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! s:load() abort + let rgbfile = $VIMRUNTIME . '/rgb.txt' + let table = {} + if filereadable(rgbfile) + for _ in map(filter(readfile(rgbfile), 'v:val !~# "^!"'), 'matchlist(v:val, "^\\s*\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(\\d\\+\\)\\s\\+\\(.*\\)")[1:4]') + let table[tolower(_[3])] = _[0:2] + endfor + endif + return table +endfunction + +let s:table = s:load() + +function! lightline#colortable#name_to_rgb(name) abort + let name = tolower(a:name) + return has_key(s:table, name) ? s:table[name] : [] +endfunction + +function! lightline#colortable#gui2cui(rgb, fallback) abort + let rgb = map(matchlist(a:rgb, '#\(..\)\(..\)\(..\)')[1:3], '0 + ("0x".v:val)') + if len(rgb) == 0 + let rgb = lightline#colortable#name_to_rgb(a:rgb) + if len(rgb) == 0 + return a:fallback % 128 + endif + endif + let rgb = [rgb[0] > 127 ? 4 : 0, rgb[1] > 127 ? 2 : 0, rgb[2] > 127 ? 1 : 0] + return rgb[0] + rgb[1] + rgb[2] +endfunction + +function! lightline#colortable#gui2cui_palette(palette) abort + for u in values(a:palette) + for v in values(u) + for w in v + let [w[2], w[3]] = [lightline#colortable#gui2cui(w[0], w[2]), lightline#colortable#gui2cui(w[1], w[3])] + endfor + endfor + endfor +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/autoload/lightline/tab.vim b/sources_non_forked/lightline.vim/autoload/lightline/tab.vim new file mode 100644 index 00000000..f2accc11 --- /dev/null +++ b/sources_non_forked/lightline.vim/autoload/lightline/tab.vim @@ -0,0 +1,33 @@ +" ============================================================================= +" Filename: autoload/lightline/tab.vim +" Author: itchyny +" License: MIT License +" Last Change: 2016/05/07 22:31:02. +" ============================================================================= + +let s:save_cpo = &cpo +set cpo&vim + +function! lightline#tab#filename(n) abort + let buflist = tabpagebuflist(a:n) + let winnr = tabpagewinnr(a:n) + let _ = expand('#'.buflist[winnr - 1].':t') + return _ !=# '' ? _ : '[No Name]' +endfunction + +function! lightline#tab#modified(n) abort + let winnr = tabpagewinnr(a:n) + return gettabwinvar(a:n, winnr, '&modified') ? '+' : gettabwinvar(a:n, winnr, '&modifiable') ? '' : '-' +endfunction + +function! lightline#tab#readonly(n) abort + let winnr = tabpagewinnr(a:n) + return gettabwinvar(a:n, winnr, '&readonly') ? 'RO' : '' +endfunction + +function! lightline#tab#tabnum(n) abort + return a:n +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/colorscheme.md b/sources_non_forked/lightline.vim/colorscheme.md new file mode 100644 index 00000000..89a71574 --- /dev/null +++ b/sources_non_forked/lightline.vim/colorscheme.md @@ -0,0 +1,153 @@ +# Available Colorschemes + +### powerline (default) + +![lightline.vim - powerline](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerline.png) + +### powerlineish + +![lightline.vim - powerlineish](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/powerlineish.png) + +### wombat + +![lightline.vim - wombat](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/wombat.png) + +### OldHope + +![lightline.vim - OldHope](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/OldHope.png) + +### PaperColor (`background=dark`) + +![lightline.vim - PaperColor_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_dark.png) + +### PaperColor (`background=light`) + +![lightline.vim - PaperColor_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/PaperColor_light.png) + +### Tomorrow + +![lightline.vim - Tomorrow](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow.png) + +### Tomorrow_Night + +![lightline.vim - Tomorrow_Night](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night.png) + +### Tomorrow_Night_Blue + +![lightline.vim_- Tomorrow_Night_Blue](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Blue.png) + +### Tomorrow_Night_Bright + +![lightline.vim - Tomorrow_Night_Bright](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Bright.png) + +### Tomorrow_Night_Eighties + +![lightline.vim - Tomorrow_Night_Eighties](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/Tomorrow_Night_Eighties.png) + +### ayu_mirage + +![lightline.vim - ayu_mirage](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_mirage.png) + +### ayu_light + +![lightline.vim - ayu_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_light.png) + +### ayu_dark + +![lightline.vim - ayu_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/ayu_dark.png) + +### darcula + +![lightline.vim - darcula](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/darcula.png) + +### deus + +![lightline.vim - deus](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/deus.png) + +### jellybeans + +![lightline.vim - jellybeans](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/jellybeans.png) + +### selenized_dark + +![lightline.vim - selenized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_dark.png) + +### selenized_black + +![lightline.vim - selenized_black](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_black.png) + +### selenized_light + +![lightline.vim - selenized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_light.png) + +### selenized_white + +![lightline.vim - selenized_white](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/selenized_white.png) + +### solarized (`background=dark`) + +![lightline.vim - solarized_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_dark.png) + +### solarized (`background=light`) + +![lightline.vim - solarized_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/solarized_light.png) + +### materia + +![lightline.vim - materia](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/materia.png) + +### material + +![lightline.vim - material](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/material.png) + +### molokai + +![lightline.vim - molokai](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/molokai.png) + +### nord + +![lightline.vim - nord](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/nord.png) + +### seoul256 + +![lightline.vim - seoul256](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/seoul256.png) + +### one (`background=dark`) + +![lightline.vim - one_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_dark.png) + +### one (`background=light`) + +![lightline.vim - one_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/one_light.png) + +### rosepine (`background=dark`) + +![lightline.vim - rosepine_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/rosepine_dark.png) + +### rosepine (`background=light`) + +![lightline.vim - rosepine_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/rosepine_light.png) + +### srcery_drk + +![lightline.vim - srcery_drk](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/srcery_drk.png) + +### simpleblack + +![lightline.vim - simpleblack](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/simpleblack.png) + +### apprentice + +![lightline.vim - apprentice](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/apprentice.png) + +### landscape + +![lightline.vim - landscape](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/landscape.png) + +### 16color (`background=dark`) + +![lightline.vim - 16color_dark](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_dark.png) + +### 16color (`background=light`) + +![lightline.vim - 16color_light](https://raw.githubusercontent.com/wiki/itchyny/lightline.vim/image/16color_light.png) diff --git a/sources_non_forked/lightline.vim/doc/lightline.txt b/sources_non_forked/lightline.vim/doc/lightline.txt new file mode 100644 index 00000000..1e4e7bd0 --- /dev/null +++ b/sources_non_forked/lightline.vim/doc/lightline.txt @@ -0,0 +1,1145 @@ +*lightline.txt* A light and configurable statusline/tabline for Vim + +Author: itchyny (https://github.com/itchyny) +License: MIT License +Repository: https://github.com/itchyny/lightline.vim +Last Change: 2022/03/16 00:15:04. + +CONTENTS *lightline-contents* + +Introduction |lightline-introduction| +Spirit |lightline-spirit| +Option |lightline-option| +Function |lightline-function| +Component Expansion |lightline-component-expansion| +Colorscheme |lightline-colorscheme| +Examples |lightline-examples| +Troubleshooting |lightline-troubleshooting| + +============================================================================== +INTRODUCTION *lightline-introduction* + +The *lightline* plugin is a light and configurable statusline/tabline for Vim. + +------------------------------------------------------------------------------ +SPIRIT *lightline-spirit* + + Minimalism + The core script is very small to achieve enough functions as a + statusline plugin. + + Configurability + You can create your own component and easily add to the statusline + and the tabline. + + Orthogonality + The plugin does not rely on the implementation of other plugins. + Such plugin crossing settings should be configured by users. + + You find this plugin does not integrate with other plugins by default. + This plugin does not provide branch information, which is a basic + component in existing statusline plugins. It is a design of + lightline.vim that such plugin crossing configuration should be + written by users. Once a plugin starts to integrate with some famous + plugins, it should be kept updated to follow the changes of the + plugins and should accept integration requests with new plugins. + Instead, lightline.vim is designed very carefully so that users can + easily integrate with other plugins. Good APIs keep a plugin clean. + +------------------------------------------------------------------------------ +OPTIONS *lightline-option* + + g:lightline *g:lightline* + All the configurations are stored in this global variable. + + g:lightline.active *g:lightline.active* + g:lightline.inactive *g:lightline.inactive* + g:lightline.tabline *g:lightline.tabline* + Dictionaries to store the statusline/tabline components. + Note that right groups of components are stored from right to + left. + The default values are: +> + let g:lightline.active = { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'readonly', 'filename', 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] } + let g:lightline.inactive = { + \ 'left': [ [ 'filename' ] ], + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ] ] } + let g:lightline.tabline = { + \ 'left': [ [ 'tabs' ] ], + \ 'right': [ [ 'close' ] ] } +< + g:lightline.tab *g:lightline.tab* + A dictionary to store the tab components in each tabs. + The default values are: +> + let g:lightline.tab = { + \ 'active': [ 'tabnum', 'filename', 'modified' ], + \ 'inactive': [ 'tabnum', 'filename', 'modified' ] } +< + g:lightline.component *g:lightline.component* + A dictionary for statusline/tabline components. + The default value is: +> + let g:lightline.component = { + \ 'mode': '%{lightline#mode()}', + \ 'absolutepath': '%F', + \ 'relativepath': '%f', + \ 'filename': '%t', + \ 'modified': '%M', + \ 'bufnum': '%n', + \ 'paste': '%{&paste?"PASTE":""}', + \ 'readonly': '%R', + \ 'charvalue': '%b', + \ 'charvaluehex': '%B', + \ 'fileencoding': '%{&fenc!=#""?&fenc:&enc}', + \ 'fileformat': '%{&ff}', + \ 'filetype': '%{&ft!=#""?&ft:"no ft"}', + \ 'percent': '%3p%%', + \ 'percentwin': '%P', + \ 'spell': '%{&spell?&spelllang:""}', + \ 'lineinfo': '%3l:%-2c', + \ 'line': '%l', + \ 'column': '%c', + \ 'close': '%999X X ', + \ 'winnr': '%{winnr()}' } +< + g:lightline.component_visible_condition + *g:lightline.component_visible_condition* + A dictionary to store the visible condition of the components. + Note that this configuration is used to control the visibility + of the subseparators, not to control the visibility of the + components themselves. Each expression should correspond to + the condition on which each component is not empty. + The default value is: +> + let g:lightline.component_visible_condition = { + \ 'modified': '&modified||!&modifiable', + \ 'readonly': '&readonly', + \ 'paste': '&paste', + \ 'spell': '&spell' } +< + g:lightline.component_function *g:lightline.component_function* + A dictionary to store the function components. + This is useful to write a complex component configuration and + to integrate with other plugins. If a component set in both + component and component_function, the configuration of + component_function has priority. + + The default value is: +> + let g:lightline.component_function = {} +< + For example, if you want to display the name of the git branch, + install |vim-fugitive| plugin and then configure as: +> + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } +< + If you simply want to display the branch name instead of + installing a plugin for full git integration, you can use + vim-gitbranch (https://github.com/itchyny/vim-gitbranch). + + g:lightline.component_function_visible_condition + *g:lightline.component_function_visible_condition* + A dictionary to store the visible conditions of the function + components. Each expression should correspond to the condition + each component is not empty. This configuration is used to + control the visibility of the sub-separators. You can use this + configuration to reduce the number of function calls for + performance improvement by setting the value 1 (to tell lightline + that the component is always visible). + The default value is: +> + let g:lightline.component_function_visible_condition = {} +< + g:lightline.component_expand *g:lightline.component_expand* + A dictionary to store expanding components. You can create + warning and critical components. The values should be the name + of functions should return either one of: + + a string + + an array of three elements: + [[ left ], [ middle ], [ right ]] + The component in this dictionary has priority over + |g:lightline.component| and |g:lightline.component_function|. + Note that the return string is appended to the statusline + string without any conversion. So you should replace all the + % signs with %%. Otherwise, lightline will be disabled in case + the text has a % sign. + (example: return substitute(text, '%', '%%', 'g')). + See |lightline-component-expansion| for more detail. +> + let g:lightline.component_expand = { + \ 'tabs': 'lightline#tabs' } +< + g:lightline.component_type *g:lightline.component_type* + A dictionary to specify the types for components in + |g:lightline.component_expand|. The types are used to specify + the color. Specifically, the type raw is used to specify a + component which should not be wrapped by item group: %(...%). + If you want to specify the type of a raw component, please use + |g:lightline.component_raw|. + The default value is: > + + let g:lightline.component_type = { + \ 'tabs': 'tabsel', + \ 'close': 'raw' } +< + g:lightline.component_raw *g:lightline.component_raw* + A dictionary to specify the raw type components. When you + register a component to this dictionary (like > + let g:lightline.component_raw = { 'example': 1 } +< ), the example component is not wrapped by item group: %(...%). + The default value is: > + + let g:lightline.component_raw = {} +< + g:lightline.tab_component *g:lightline.tab_component* + A dictionary for components in one tab. + The default value is: > + + let g:lightline.tab_component = {} +< + g:lightline.tab_component_function *g:lightline.tab_component_function* + Another dictionary for components in one tab. + A function specified as a tab component takes one argument: + the tab [count]. + The default value is: +> + let g:lightline.tab_component_function = { + \ 'filename': 'lightline#tab#filename', + \ 'modified': 'lightline#tab#modified', + \ 'readonly': 'lightline#tab#readonly', + \ 'tabnum': 'lightline#tab#tabnum' } +< + g:lightline.colorscheme *g:lightline.colorscheme* + The colorscheme for lightline.vim. + Currently, wombat, solarized, powerline, powerlineish, + jellybeans, molokai, seoul256, darcula, + selenized_dark, selenized_black, selenized_light, selenized_white, + Tomorrow, Tomorrow_Night, Tomorrow_Night_Blue, + Tomorrow_Night_Bright, Tomorrow_Night_Eighties, PaperColor, + landscape, one, materia, material, OldHope, nord, deus, + simpleblack, srcery_drk, ayu_mirage, ayu_light, ayu_dark, + apprentice, rosepine, and 16color are available. + The default value is: +> + let g:lightline.colorscheme = 'default' +< + Note that the default colorscheme is exactly the same as the + powerline theme. + + g:lightline.mode_map *g:lightline.mode_map* + A dictionary of names for the modes. The keys are the return + values of |mode()|. + The default value is: +> + let g:lightline.mode_map = { + \ 'n' : 'NORMAL', + \ 'i' : 'INSERT', + \ 'R' : 'REPLACE', + \ 'v' : 'VISUAL', + \ 'V' : 'V-LINE', + \ "\": 'V-BLOCK', + \ 'c' : 'COMMAND', + \ 's' : 'SELECT', + \ 'S' : 'S-LINE', + \ "\": 'S-BLOCK', + \ 't': 'TERMINAL', + \ } +< + When you search a word, you get into the command mode. But if + you want to keep the mode indicator as 'NORMAL', add > + let g:lightline = { 'mode_map': { 'c': 'NORMAL' } } +< to your .vimrc. + + g:lightline.separator *g:lightline.separator* + g:lightline.subseparator *g:lightline.subseparator* + Dictionaries to store separators. + The default value is +> + let g:lightline.separator = { 'left': '', 'right': '' } + let g:lightline.subseparator = { 'left': '|', 'right': '|' } +< + g:lightline.tabline_separator *g:lightline.tabline_separator* + g:lightline.tabline_subseparator *g:lightline.tabline_subseparator* + Dictionaries to store separators for the tabline. + The default value is +> + let g:lightline.tabline_separator = g:lightline.separator + let g:lightline.tabline_subseparator = g:lightline.subseparator +< + g:lightline.enable *g:lightline.enable* + A dictionary to specify which feature is turned on. + The default value is +> + let g:lightline.enable = { + \ 'statusline': 1, + \ 'tabline': 1 + \ } +< +============================================================================== +FUNCTION *lightline-function* +Exposed functions for lightline.vim. + + lightline#mode() *lightline#mode()* + Returns the mode of the Vim using |g:lightline.mode_map|. + + lightline#init() *lightline#init()* + Initializes the internal state from |g:lightline|. + + lightline#colorscheme() *lightline#colorscheme()* + Initializes the colorscheme and the highlight groups. + + lightline#update() *lightline#update()* + Updates all the statuslines of existing windows. + + lightline#enable() *lightline#enable()* + Enables |lightline|. + + lightline#disable() *lightline#disable()* + Disables |lightline|. + + lightline#toggle() *lightline#toggle()* + Toggles |lightline|. + + lightline#link([mode]) *lightline#link()* + Creates links of the highlight groups for the active window. + This function accepts an optional argument. It should be one + of the return value of |mode()|. + + lightline#highlight() *lightline#highlight()* + Set the highlight groups. + + lightline#statusline({inactive}) *lightline#statusline()* + Returns |statusline| strings. If the argument is 0, it returns + the statusline for active window, and the statusline for + inactive window otherwise. + + lightline#tabline() *lightline#tabline()* + Returns the tabline string. + + lightline#concatenate({list}, {num}) *lightline#concatenate()* + A string concatenation function. Concatenating all the strings + in {list} using the sub-separator of lightline. If {num} is 0, + then the left sub-separator is used. Otherwise, the right + sub-separator is used. + + lightline#palette() *lightline#palette()* + Returns the palette data. + +============================================================================== +COMPONENT EXPANSION *lightline-component-expansion* +You can create components, which have specific colors. This section gives an +example using |syntastic|. + +If you want to add the |syntastic| flag to the statusline, an easy example is: +> + " Example A + let g:lightline = { + \ 'active': { + \ 'right': [ [ 'lineinfo', 'syntastic' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_function': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ } + \ } + let g:syntastic_mode_map = { 'mode': 'passive', + \ 'active_filetypes': ['c', 'cpp'] } +< +However, the color of the syntastic component is the same as the lineinfo +component. + +In order to change the syntastic component more outstanding, you have to use +|g:lightline.component_expand|. See the following example: +> + " Example B + let g:lightline = { + \ 'active': { + \ 'right': [ [ 'syntastic', 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_expand': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ }, + \ 'component_type': { + \ 'syntastic': 'error', + \ } + \ } + " Syntastic can call a post-check hook, let's update lightline there + " For more information: :help syntastic-loclist-callback + function! SyntasticCheckHook(errors) + call lightline#update() + endfunction +< +In order to understand the above codes, you firstly should know how the +colorschemes work in lightline.vim. Open the following file. + autoload/lightline/colorscheme/powerline.vim +The colorscheme is created by one dictionary: s:p (abbreviation for palette). +See the value of s:p.normal.right. +> + let s:p.normal.right = [ ['gray5', 'gray10'], + \ ['gray9', 'gray4'], + \ ['gray8', 'gray2'] ] +< +This array corresponds to the structure of g:lightline.active.right. Recall +the example A. +> + " Example A + let g:lightline.active.right = [ [ 'lineinfo', 'syntastic' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] +< +The colors are ([fgcolor, bgcolor): +> + (0) [ 'lineinfo', 'syntastic' ] --- s:p.normal.right[0] = ['gray5', 'gray10'] + (1) [ 'percent' ] --- s:p.normal.right[1] = ['gray9', 'gray4'] + (2) [ 'fileformat', 'fileencoding', 'filetype' ] --- s:p.normal.right[2] = ['gray8', 'gray2'] +< +Recall the example B. +> + " Example B + let g:lightline.active.right = [ [ 'syntastic', 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ] ] +< +If a component is specified in |g:lightline.component_expand|, lightline.vim +expands the components before setting to statusline/tabline. In this example, +the syntastic component is expanded using the |SyntasticStatuslineFlag| function. +This function returns a {string}. Let us call it `syntastic_flag`. +> + let syntastic_flag = SyntasticStatuslineFlag() +< +The syntastic component is now expanded, so it go up to one component group. +The type of the syntastic component is error, and the palette has error +colors, the result is: +> + " Expanded result of Example B + (error) [ syntastic_flag ] --- s:p.normal.error[0] = ['gray9', 'brightestred'] + (0) [ 'lineinfo' ] --- s:p.normal.right[0] = ['gray5', 'gray10'] + (1) [ 'percent' ] --- s:p.normal.right[1] = ['gray9', 'gray4'] + (2) [ 'fileformat', 'fileencoding', 'filetype' ] --- s:p.normal.right[2] = ['gray8', 'gray2'] +< +Thus the syntastic component has the red color. + + +Another example for |g:lightline.component_expand| is the tabs component. +Actually, the expand feature is created for the tabs component. +> + let g:lightline.tabline.left = [ [ 'tabs' ] ] + let g:lightline.component_expand = { + \ 'tabs': 'lightline#tabs' } +< +Create three tabs and select the middle tab. Then execute +> + echo lightline#tabs() + " [['%1T%{lightline#onetab(1,0)}'], + " ['%2T%{lightline#onetab(2,1)}'], + " ['%3T%{lightline#onetab(3,0)}%T']] +< +It returns an array of three elements. The expanded result is: +> + " Expanded result of tabline + (0) ['%1T%{lightline#onetab(1,0)}'] --- s:p.tabline.left[0] = ['gray9', 'gray4'] + (tabsel) ['%2T%{lightline#onetab(2,1)}'] --- s:p.tabline.tabsel[0] = ['gray9', 'gray1'] + (0) ['%3T%{lightline#onetab(3,0)}%T'] --- s:p.tabline.left[0] = ['gray9', 'gray4'] +< +If the tabline components are +> + let g:lightline.tabline.left = [ [ 'A', 'B', 'tabs', 'C', 'D' ] ] +< +then the expanded result is: +> + (0) ['A', 'B', '%1T%{lightline#onetab(1,0)}'] --- s:p.tabline.left[0] + (tabsel) ['%2T%{lightline#onetab(2,1)}'] --- s:p.tabline.tabsel[0] + (0) ['%3T%{lightline#onetab(3,0)}%T', 'C', 'D'] --- s:p.tabline.left[0] +< +In summary, when a function in |g:lightline.component_expand| returns an +array of three elements, the first element and the last element remains as a +part of existing component group. And the middle element goes up to new +component group. +------------------------------------------------------------------------------ +COLORSCHEME *lightline-colorscheme* +You can configure the colorscheme of lightline. For example, +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +< +The colorscheme files are found in the directory + + lightline.vim/autoload/lightline/colorscheme/ + +In each file, one global variable is defined. For example, in the landscape.vim +file, you see +> + let g:lightline#colorscheme#landscape#palette = s:p +< +In the file, the colors for the landscape colorscheme are defined. For example, +> + let s:p.normal.left = [ ['#0000ff', '#ffffff', 21, 231, 'bold' ], [ '#ffffff', '#0000ff', 231, 21 ] ] +< +defines the colors for the components on the left hand side, in normal mode. +> + let s:p.tabline.tabsel = [ [ '#dadada', '#121212', 253, 233 ] ] +< +defines the colors for the selected tab in tabline. In general, each palette +follows the following style: +> + let s:p.{mode}.{where} = [ [ {guifg}, {guibg}, {ctermfg}, {ctermbg} ], ... ] +< + + +Now, you can create your own colorscheme for lightline. Create a +yourcolorscheme.vim at + + {one of the paths in &rtp}/autoload/lightline/colorscheme/yourcolorscheme.vim + +The following code gives the minimal palette definition for lightline. +> + let s:p = {'normal': {}} + let s:p.normal.left = [ [ ... ] ] + let s:p.normal.right = [ [ ... ] ] + let s:p.normal.middle = [ [ ... ] ] + let g:lightline#colorscheme#yourcolorscheme#palette = s:p +< +And if you add the colorscheme configuration to your .vimrc(_vimrc), +> + let g:lightline = { + \ 'colorscheme': 'yourcolorscheme', + \ } +< +you find it possible to change the lightline colors as you wish. + +Moreover, if you want to change the colors based on the mode of vim, write +something like this: +> + let s:p.insert.left = [ [ ... ] ] + let s:p.insert.right = [ [ ... ] ] + let s:p.replace.left = [ [ ... ] ] + let s:p.replace.right = [ [ ... ] ] + ... + ... +< +For expanded components, you are recommended to define the following two +colors. +> + let s:p.normal.error = [ [ ... ] ] + let s:p.normal.warning = [ [ ... ] ] +< +For the complete list of components the color of which you should define in +your colorscheme, see the colorscheme files in lightline. + +It is sometimes painful to write all the colors for both gui and cterm. +Actually, lightline has some useful functions for writing colorschemes. For +example, see + lightline.vim/autoload/lightline/colorscheme/Tomorrow_Night.vim +this colorscheme is defined using only gui color numbers. And convert to the +normal colorscheme form using: +> + let g:lightline#colorscheme#Tomorrow_Night#palette = lightline#colorscheme#fill(s:p) +< +This function fills the cterm colors for a palette which has only gui colors, or +vice versa. However, note that using the convenient function sources an +additional Vim script file (autoload/lightline/colorscheme.vim), which causes +a little slow down. If you want to avoid this situation, write all the colors +as done in autoload/lightline/colorscheme/landscape.vim; firstly create the +colorscheme using the fill function, and see the result, in a sense, the +compiled version of your colorscheme. +> + echo g:lightline#colorscheme#yourcolorscheme#palette +< +Then copy and paste the result to the colorscheme file. + +If you want to contribute a new colorscheme that is not currently available +please follow the following rules: + *) All hex codes should be lowercase only + *) Use 2 space soft tabs + *) If your colorscheme has both light and dark variants, use a single file + *) Normal Mode should default to Cyan + *) Insert Mode should default to Green + *) Visual Mode should default to Yellow + *) Replace Mode should default to Red + +============================================================================== +EXAMPLES *lightline-examples* +You can configure the appearance of statusline. +Write the following examples in you .vimrc(_vimrc). + +In order to change the colorscheme: +> + let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +< +In order to define your own component: +> + let g:lightline = { + \ 'component_function': { + \ 'filename': 'LightlineFilename', + \ 'readonly': 'LightlineReadonly', + \ 'modified': 'LightlineModified', + \ } + \ } + function! LightlineFilename() + return &ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]' + endfunction + function! LightlineReadonly() + return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' + endfunction + function! LightlineModified() + return &modifiable && &modified ? '+' : '' + endfunction +< +Separators settings: +> + let g:lightline = { + \ 'separator': { 'left': '', 'right': '' }, + \ 'subseparator': { 'left': '|', 'right': '|' } + \ } +< +An example for fugitive, vimfiler and unite users. +> + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'LightlineFugitive', + \ 'filename': 'LightlineFilename' + \ } + \ } + function! LightlineModified() + return &ft =~# 'help\|vimfiler' ? '' : &modified ? '+' : &modifiable ? '' : '-' + endfunction + function! LightlineReadonly() + return &ft !~? 'help\|vimfiler' && &readonly ? 'RO' : '' + endfunction + function! LightlineFilename() + return (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . + \ (&ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ expand('%:t') !=# '' ? expand('%:t') : '[No Name]') . + \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') + endfunction + function! LightlineFugitive() + if exists('*FugitiveHead') + return FugitiveHead() + endif + return '' + endfunction +< +For users of lots of plugins: +> + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ], + \ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'LightlineFugitive', + \ 'filename': 'LightlineFilename', + \ 'fileformat': 'LightlineFileformat', + \ 'filetype': 'LightlineFiletype', + \ 'fileencoding': 'LightlineFileencoding', + \ 'mode': 'LightlineMode', + \ 'ctrlpmark': 'CtrlPMark', + \ }, + \ 'component_expand': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ }, + \ 'component_type': { + \ 'syntastic': 'error', + \ }, + \ 'subseparator': { 'left': '|', 'right': '|' } + \ } + + function! LightlineModified() + return &ft ==# 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' + endfunction + + function! LightlineReadonly() + return &ft !~? 'help' && &readonly ? 'RO' : '' + endfunction + + function! LightlineFilename() + let fname = expand('%:t') + return fname ==# 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item : + \ fname =~# '^__Tagbar__\|__Gundo\|NERD_tree' ? '' : + \ &ft ==# 'vimfiler' ? vimfiler#get_status_string() : + \ &ft ==# 'unite' ? unite#get_status_string() : + \ &ft ==# 'vimshell' ? vimshell#get_status_string() : + \ (LightlineReadonly() !=# '' ? LightlineReadonly() . ' ' : '') . + \ (fname !=# '' ? fname : '[No Name]') . + \ (LightlineModified() !=# '' ? ' ' . LightlineModified() : '') + endfunction + + function! LightlineFugitive() + try + if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*FugitiveHead') + let mark = '' " edit here for cool mark + let branch = FugitiveHead() + return branch !=# '' ? mark.branch : '' + endif + catch + endtry + return '' + endfunction + + function! LightlineFileformat() + return winwidth(0) > 70 ? &fileformat : '' + endfunction + + function! LightlineFiletype() + return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : '' + endfunction + + function! LightlineFileencoding() + return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : '' + endfunction + + function! LightlineMode() + let fname = expand('%:t') + return fname =~# '^__Tagbar__' ? 'Tagbar' : + \ fname ==# 'ControlP' ? 'CtrlP' : + \ fname ==# '__Gundo__' ? 'Gundo' : + \ fname ==# '__Gundo_Preview__' ? 'Gundo Preview' : + \ fname =~# 'NERD_tree' ? 'NERDTree' : + \ &ft ==# 'unite' ? 'Unite' : + \ &ft ==# 'vimfiler' ? 'VimFiler' : + \ &ft ==# 'vimshell' ? 'VimShell' : + \ winwidth(0) > 60 ? lightline#mode() : '' + endfunction + + function! CtrlPMark() + if expand('%:t') ==# 'ControlP' && has_key(g:lightline, 'ctrlp_item') + call lightline#link('iR'[g:lightline.ctrlp_regex]) + return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item + \ , g:lightline.ctrlp_next], 0) + else + return '' + endif + endfunction + + let g:ctrlp_status_func = { + \ 'main': 'CtrlPStatusFunc_1', + \ 'prog': 'CtrlPStatusFunc_2', + \ } + + function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked) + let g:lightline.ctrlp_regex = a:regex + let g:lightline.ctrlp_prev = a:prev + let g:lightline.ctrlp_item = a:item + let g:lightline.ctrlp_next = a:next + return lightline#statusline(0) + endfunction + + function! CtrlPStatusFunc_2(str) + return lightline#statusline(0) + endfunction + + let g:tagbar_status_func = 'TagbarStatusFunc' + + function! TagbarStatusFunc(current, sort, fname, ...) abort + return lightline#statusline(0) + endfunction + + " Syntastic can call a post-check hook, let's update lightline there + " For more information: :help syntastic-loclist-callback + function! SyntasticCheckHook(errors) + call lightline#update() + endfunction + + let g:unite_force_overwrite_statusline = 0 + let g:vimfiler_force_overwrite_statusline = 0 + let g:vimshell_force_overwrite_statusline = 0 +< +------------------------------------------------------------------------------ +TROUBLESHOOTING *lightline-troubleshooting* + +Problem 1: |lightline-problem-1| + How to install this plugin. + +Problem 2: |lightline-problem-2| + How to update this plugin. + +Problem 3: |lightline-problem-3| + How to uninstall this plugin. + +Problem 4: |lightline-problem-4| + Cool statuslines appear only on |:vsp|. + +Problem 5: |lightline-problem-5| + The statusline does not seem to be correctly colored. + +Problem 6: |lightline-problem-6| + How to use a powerline font and the triangles for separators. + +Problem 10: |lightline-problem-10| + Cool statusline disappears in |unite|, |vimfiler| and |vimshell| + buffers. + +Problem 11: |lightline-problem-11| + Cool statusline disappears in |CtrlP|, |Tagbar| buffers. + +Problem 12: |lightline-problem-12| + How to make the plus sign red like |powerline|? + +Problem 13: |lightline-problem-13| + How to change the lightline colorscheme on the fly. + +Problem 14: |lightline-problem-14| + The 'E541' warning appears on the right hand side. + Many components disable the statusline of lightline. + +Problem 15: |lightline-problem-15| + Do not deal with the tabline. + Do not use the fancy separators in the tabline. + +Problem 16: |lightline-problem-16| + When changed the component to a function component to an expanding + component, the statusline of lightline is sometimes disabled. + +Problem 17: |lightline-problem-17| + Found a bug of this plugin. + Got many errors while using this plugin. + Vim hangs while using this plugin. + Want this plugin to be more configurable. + This troubleshooting is not helpful. + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +Problem 1: *lightline-problem-1* + How to install this plugin. + + If you install this plugin using Vim packages: +> + git clone https://github.com/itchyny/lightline.vim \ + ~/.vim/pack/plugins/start/lightline +< + If you install this plugin using |vim-pathogen|: +> + git clone https://github.com/itchyny/lightline.vim \ + ~/.vim/bundle/lightline.vim +< + If you install this plugin using |Vundle|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + Plugin 'itchyny/lightline.vim' +< + 2. Install with |:PluginInstall|. + + If you install this plugin using |NeoBundle|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + NeoBundle 'itchyny/lightline.vim' +< + 2. Install with |:NeoBundleInstall|. + + If you install this plugin using |vim-plug|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + Plug 'itchyny/lightline.vim' +< + 2. Install with |:PlugInstall|. + + If you install this plugin using |dein|: + + 1. Add the following configuration to your + .vimrc(_vimrc). +> + call dein#add('itchyny/lightline.vim') +< + 2. Install with :call |dein#install()|. + +Problem 2: *lightline-problem-2* + How to update this plugin. + + If you installed this plugin using Vim packages: +> + git -C ~/.vim/pack/plugins/start/lightline pull +< + If you installed this plugin using |vim-pathogen|: +> + git -C ~/.vim/bundle/lightline.vim pull +< + If you installed this plugin using |Vundle|: + + Execute |:PluginUpdate|. + + If you installed this plugin using |NeoBundle|: + + Execute |:NeoBundleUpdate|. + + If you installed this plugin using |vim-plug|: + + Execute |:PlugUpdate|. + + If you installed this plugin using |dein|: + + Execute :call |dein#update()|. + +Problem 3: *lightline-problem-3* + How to uninstall this plugin. + + If you installed this plugin using Vim packages: +> + rm -rf ~/.vim/pack/plugins/start/lightline +< + If you installed this plugin using |vim-pathogen|: +> + rm -rf ~/.vim/bundle/lightline.vim +< + If you have installed this plugin using |Vundle|: + + 1. Remove `Plugin 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PluginClean|. + + If you installed this plugin using |NeoBundle|: + + 1. Remove `NeoBundle 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. + + If you installed this plugin using |vim-plug|: + + 1. Remove `Plug 'itchyny/lightline.vim'` + from your .vimrc(_vimrc). + 2. Execute |:PlugClean|. + + If you installed this plugin using |dein|: + + 1. Remove `call dein#add('itchyny/lightline.vim')` + from your .vimrc(_vimrc). + 2. Remove the plugin directory. + +Problem 4: *lightline-problem-4* + Cool statuslines appear only on |:vsp|. + + Add the following setting to your .vimrc(_vimrc). +> + set laststatus=2 +< +Problem 5: *lightline-problem-5* + The statusline does not seem to be correctly colored. + + Add +> + export TERM=xterm-256color +< + to your .*shrc and add +> + if !has('gui_running') + set t_Co=256 + endif +< + to your .vimrc(_vimrc). + +Problem 6: *lightline-problem-6* + How to use a powerline font and the triangles for separators. + + Using a patched font is not recommended due to less + portability. Also the powerline fonts project is not actively + maintained (https://github.com/powerline/fonts). + + If you still want to use a patched font, you can configure +> + \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, +< + or +> + \ 'separator': { 'left': "\u2b80", 'right': "\u2b82" }, + \ 'subseparator': { 'left': "\u2b81", 'right': "\u2b83" }, +< +Problem 10: *lightline-problem-10* + Cool statusline disappears on |unite|, |vimfiler| and |vimshell| + buffers. + + Add the following settings to your .vimrc(_vimrc). +> + let g:unite_force_overwrite_statusline = 0 + let g:vimfiler_force_overwrite_statusline = 0 + let g:vimshell_force_overwrite_statusline = 0 +< +Problem 11: *lightline-problem-11* + Cool statusline disappears in |CtrlP|, |Tagbar| buffers. + + Add the following settings to your .vimrc(_vimrc). +> + let g:ctrlp_status_func = { + \ 'main': 'CtrlPStatusFunc_1', + \ 'prog': 'CtrlPStatusFunc_2', + \ } + function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked) + return lightline#statusline(0) + endfunction + function! CtrlPStatusFunc_2(str) + return lightline#statusline(0) + endfunction + + let g:tagbar_status_func = 'TagbarStatusFunc' + function! TagbarStatusFunc(current, sort, fname, ...) abort + return lightline#statusline(0) + endfunction +< + See |lightline-example| for more cool settings for + these plugins. + +Problem 12: *lightline-problem-12* + How to make the plus sign red like |powerline|? + + Use the following settings. +> + let g:lightline = { + \ 'component': { + \ 'modified': '%#ModifiedColor#%{LightlineModified()}', + \ } + \ } + function! LightlineModified() + let map = { 'V': 'n', "\": 'n', 's': 'n', 'v': 'n', "\": 'n', 'c': 'n', 'R': 'n'} + let mode = get(map, mode()[0], mode()[0]) + let bgcolor = {'n': [240, '#585858'], 'i': [31, '#0087af']} + let color = get(bgcolor, mode, bgcolor.n) + exe printf('hi ModifiedColor ctermfg=196 ctermbg=%d guifg=#ff0000 guibg=%s term=bold cterm=bold', + \ color[0], color[1]) + return &modified ? '+' : &modifiable ? '' : '-' + endfunction +< + It's surely complicated. There's no easy API to do a thing + like this. But it means that your request does not match + the spirit of lightline. + +Problem 13: *lightline-problem-13* + How to change the lightline colorscheme on the fly. + + To update your lightline colorscheme in sync with your vim + colorscheme (only for select colorschemes which exist for + both), add the following settings to your .vimrc(_vimrc). +> + augroup LightlineColorscheme + autocmd! + autocmd ColorScheme * call s:lightline_update() + augroup END + function! s:lightline_update() + if !exists('g:loaded_lightline') + return + endif + try + if g:colors_name =~# 'wombat\|solarized\|landscape\|jellybeans\|seoul256\|Tomorrow' + let g:lightline.colorscheme = + \ substitute(substitute(g:colors_name, '-', '_', 'g'), '256.*', '', '') + call lightline#init() + call lightline#colorscheme() + call lightline#update() + endif + catch + endtry + endfunction +< + If you have not settled on a single lightline colorscheme, you + can easily switch between lightline colorschemes by adding the + following LightlineColorscheme command to your .vimrc(_vimrc). +> + function! s:set_lightline_colorscheme(name) abort + let g:lightline.colorscheme = a:name + call lightline#init() + call lightline#colorscheme() + call lightline#update() + endfunction + + function! s:lightline_colorschemes(...) abort + return join(map( + \ globpath(&rtp,"autoload/lightline/colorscheme/*.vim",1,1), + \ "fnamemodify(v:val,':t:r')"), + \ "\n") + endfunction + + command! -nargs=1 -complete=custom,s:lightline_colorschemes LightlineColorscheme + \ call s:set_lightline_colorscheme() +< +Problem 14: *lightline-problem-14* + The 'E541' warning appears on the right hand side. + Many components disable the statusline of lightline. + + The number of items in statusline/tabline is limited to 80 + (see |E541|). You cannot register too much components. + +Problem 15: *lightline-problem-15* + Do not deal with the tabline. + Do not use the fancy separators in the tabline. + + You can disable the tabline feature of lightline.vim using: +> + let g:lightline = { + \ 'enable': { 'tabline': 0 }, + \ } +< + If you don't like the separators in the tabline, use: +> + let g:lightline = { + \ 'tabline_separator': { 'left': '', 'right': '' }, + \ 'tabline_subseparator': { 'left': '', 'right': '' }, + \ } +< +Problem 16: *lightline-problem-16* + When changed the component to a function component to an expanding + component, the statusline of lightline is sometimes disabled. + + When you changed from +> + \ 'component_function': { + \ 'my': 'My', + \ } +< + to +> + \ 'component_expand': { + \ 'my': 'My', + \ } +< + the statusline of lightline is disabled unexpectedly. + In such a case, the text returned by 'My' function may include + the '%' character. Replace all the '%' signs with '%%'. +> + function My() + ... + return substitute(text, '%', '%%', 'g') + endfunction +< +Problem 17: *lightline-problem-17* + Found a bug of this plugin. + Got many errors while using this plugin. + Vim hangs while using this plugin. + Want this plugin to be more configurable. + This troubleshooting is not helpful. + + Report/Request the issue/feature at + https://github.com/itchyny/lightline.vim/issues. + +============================================================================== +vim:tw=78:sw=4:ts=8:ft=help:norl:noet: diff --git a/sources_non_forked/lightline.vim/plugin/lightline.vim b/sources_non_forked/lightline.vim/plugin/lightline.vim new file mode 100644 index 00000000..1f5f998e --- /dev/null +++ b/sources_non_forked/lightline.vim/plugin/lightline.vim @@ -0,0 +1,33 @@ +" ============================================================================= +" Filename: plugin/lightline.vim +" Author: itchyny +" License: MIT License +" Last Change: 2021/11/21 22:54:41. +" ============================================================================= + +if exists('g:loaded_lightline') || v:version < 703 + finish +endif +let g:loaded_lightline = 1 + +let s:save_cpo = &cpo +set cpo&vim + +augroup lightline + autocmd! + autocmd WinEnter,BufEnter,SessionLoadPost,FileChangedShellPost * call lightline#update() + if !has('patch-8.1.1715') + autocmd FileType qf call lightline#update() + endif + autocmd SessionLoadPost * call lightline#highlight() + autocmd ColorScheme * if !has('vim_starting') || expand('') !=# 'macvim' + \ | call lightline#update() | call lightline#highlight() | endif +augroup END + +" This quickfix option was introduced at Vim 85850f3a5ef9, which is the commit +" just before 8.1.1715. Before this patch, autocmd FileType is required to +" overwrite the statusline of the quickfix and location windows. +let g:qf_disable_statusline = 1 + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/lightline.vim/test/.themisrc b/sources_non_forked/lightline.vim/test/.themisrc new file mode 100644 index 00000000..5c7018a1 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/.themisrc @@ -0,0 +1,24 @@ +let s:sids = {} +function! s:sid(path) abort + if has_key(s:sids, a:path) + return s:sids[a:path] + endif + redir => scriptnames + silent! scriptnames + redir END + for line in split(scriptnames, '\n') + if line =~# a:path + let sid = matchstr(line, '\v^\s*\zs\d+\ze') + let s:sids[a:path] = sid + return sid + endif + endfor +endfunction + +function! SID(name) abort + return function(printf("\%d_%s", s:sid('autoload/lightline.vim'), a:name)) +endfunction + +filetype plugin on + +call lightline#init() diff --git a/sources_non_forked/lightline.vim/test/autocmd.vim b/sources_non_forked/lightline.vim/test/autocmd.vim new file mode 100644 index 00000000..934509b8 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/autocmd.vim @@ -0,0 +1,23 @@ +if !has("patch-8.2.0996") + finish +endif + +let s:suite = themis#suite('autocmd') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.doautoall() + tabnew + tabnew + tabprevious + doautoall WinEnter + let statusline = getwinvar(1, '&statusline') + call s:assert.match(statusline, 'lightline') + call s:assert.match(statusline, '_active_') +endfunction diff --git a/sources_non_forked/lightline.vim/test/concatenate.vim b/sources_non_forked/lightline.vim/test/concatenate.vim new file mode 100644 index 00000000..6fd2723a --- /dev/null +++ b/sources_non_forked/lightline.vim/test/concatenate.vim @@ -0,0 +1,90 @@ +let s:suite = themis#suite('concatenate') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = { 'subseparator': { 'left': '>', 'right': '<' } } + call lightline#init() +endfunction + +function! s:suite.nil() + call s:assert.equals(lightline#concatenate([], 0), '') + call s:assert.equals(lightline#concatenate([], 1), '') +endfunction + +function! s:suite.one() + call s:assert.equals(lightline#concatenate(['foo'], 0), 'foo') + call s:assert.equals(lightline#concatenate(['foo'], 1), 'foo') +endfunction + +function! s:suite.two() + call s:assert.equals(lightline#concatenate(['foo', 'bar'], 0), 'foo > bar') + call s:assert.equals(lightline#concatenate(['foo', 'bar'], 1), 'foo < bar') +endfunction + +function! s:suite.three() + call s:assert.equals(lightline#concatenate(['foo', 'bar', 'baz'], 0), 'foo > bar > baz') + call s:assert.equals(lightline#concatenate(['foo', 'bar', 'baz'], 1), 'foo < bar < baz') +endfunction + +function! s:suite.one_empty() + call s:assert.equals(lightline#concatenate([''], 0), '') + call s:assert.equals(lightline#concatenate([''], 1), '') +endfunction + +function! s:suite.two_empty_left() + call s:assert.equals(lightline#concatenate(['', 'bar'], 0), 'bar') + call s:assert.equals(lightline#concatenate(['', 'bar'], 1), 'bar') +endfunction + +function! s:suite.two_empty_right() + call s:assert.equals(lightline#concatenate(['foo', ''], 0), 'foo') + call s:assert.equals(lightline#concatenate(['foo', ''], 1), 'foo') +endfunction + +function! s:suite.two_empty_both() + call s:assert.equals(lightline#concatenate(['', ''], 0), '') + call s:assert.equals(lightline#concatenate(['', ''], 1), '') +endfunction + +function! s:suite.three_empty_left() + call s:assert.equals(lightline#concatenate(['', 'bar', 'baz'], 0), 'bar > baz') + call s:assert.equals(lightline#concatenate(['', 'bar', 'baz'], 1), 'bar < baz') +endfunction + +function! s:suite.three_empty_middle() + call s:assert.equals(lightline#concatenate(['foo', '', 'baz'], 0), 'foo > baz') + call s:assert.equals(lightline#concatenate(['foo', '', 'baz'], 1), 'foo < baz') +endfunction + +function! s:suite.three_empty_right() + call s:assert.equals(lightline#concatenate(['foo', 'bar', ''], 0), 'foo > bar') + call s:assert.equals(lightline#concatenate(['foo', 'bar', ''], 1), 'foo < bar') +endfunction + +function! s:suite.three_empty_middle_right() + call s:assert.equals(lightline#concatenate(['foo', '', ''], 0), 'foo') + call s:assert.equals(lightline#concatenate(['foo', '', ''], 1), 'foo') +endfunction + +function! s:suite.three_empty_left_right() + call s:assert.equals(lightline#concatenate(['', 'bar', ''], 0), 'bar') + call s:assert.equals(lightline#concatenate(['', 'bar', ''], 1), 'bar') +endfunction + +function! s:suite.three_empty_left_middle() + call s:assert.equals(lightline#concatenate(['', '', 'baz'], 0), 'baz') + call s:assert.equals(lightline#concatenate(['', '', 'baz'], 1), 'baz') +endfunction + +function! s:suite.three_empty_all() + call s:assert.equals(lightline#concatenate(['', '', ''], 0), '') + call s:assert.equals(lightline#concatenate(['', '', ''], 1), '') +endfunction + +function! s:suite.keep_original() + let xs = ['', 'bar', ''] + call s:assert.equals(lightline#concatenate(xs, 0), 'bar') + call s:assert.equals(xs, ['', 'bar', '']) + call s:assert.equals(lightline#concatenate(xs, 1), 'bar') + call s:assert.equals(xs, ['', 'bar', '']) +endfunction diff --git a/sources_non_forked/lightline.vim/test/error.vim b/sources_non_forked/lightline.vim/test/error.vim new file mode 100644 index 00000000..8fdabf46 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/error.vim @@ -0,0 +1,15 @@ +let s:suite = themis#suite('error') +let s:assert = themis#helper('assert') + +function! s:message() abort + redir => messages + silent! messages + redir END + return split(messages, '\n')[-1] +endfunction + +function! s:suite.error() + let message = 'An error occurred.' + call lightline#error(message) + call s:assert.equals(s:message(), 'lightline.vim: ' . message) +endfunction diff --git a/sources_non_forked/lightline.vim/test/expand.vim b/sources_non_forked/lightline.vim/test/expand.vim new file mode 100644 index 00000000..e1ac310d --- /dev/null +++ b/sources_non_forked/lightline.vim/test/expand.vim @@ -0,0 +1,667 @@ +let s:suite = themis#suite('expand') +let s:assert = themis#helper('assert') + +function! s:expand(...) + return call(SID('expand'), a:000) +endfunction + +function! s:suite.expand() + let g:lightline = {} + call lightline#init() + call s:assert.equals(s:expand([]), + \ [[], [], ['0']]) +endfunction + +function! s:suite.default() + let g:lightline = {} + call lightline#init() + call s:assert.equals(s:expand([['mode', 'paste'], ['readonly', 'filename', 'modified']]), + \ [[['mode', 'paste'], ['readonly', 'filename', 'modified']], [[0, 0], [0, 0, 0]], ['0', '1', '2']]) +endfunction + +function! s:suite.custom() + function! Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type() + function! Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.raw_type() + function! Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'raw' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [2, 2, 2], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 2, 2, 2, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.component_raw() + function! Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' }, 'component_raw': { 'custom': 1 } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [2], [2], [2], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 2], [2], [2, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.multiple() + function! Custom() + return [ ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['x0', 'x1', 'x2', 'y0', 'y1', 'y2', 'z0', 'z1', 'z2'], ['modified']], [[0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'x0', 'x1', 'x2', 'y0', 'y1', 'y2', 'z0', 'z1', 'z2', 'modified']], [[0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.multiple_type() + function! Custom() + return [ ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2'], ['modified']], [[0, 0], [1, 1, 1], [1, 1, 1], [1, 1, 1], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'x0', 'x1', 'x2'], ['y0', 'y1', 'y2'], ['z0', 'z1', 'z2', 'modified']], [[0, 0, 1, 1, 1], [1, 1, 1], [1, 1, 1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.flatten() + function! Custom() + return [ 'left', 'middle', 'right' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_flatten() + function! Custom() + return [ 'left', 'middle', 'right' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['middle'], ['right'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['middle'], ['right', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_string() + function! Custom() + return 'custom' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_string() + function! Custom() + return 'custom' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_void_string() + function! Custom() + return '' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_void_string() + function! Custom() + return '' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_number() + function! Custom() + return 24 + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', '24', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_number() + function! Custom() + return 24 + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename'], ['24'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_void_string_array() + function! Custom() + return ['', '', ''] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_void_string_array() + function! Custom() + return ['', '', ''] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_void_string_array_2() + function! Custom() + return [[''], [''], ['']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_void_string_array_2() + function! Custom() + return [[''], [''], ['']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_void_string_array_3() + function! Custom() + return ['', 'custom', ''] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_void_string_array_3() + function! Custom() + return ['', 'custom', ''] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_void_string_array_4() + function! Custom() + return [[''], ['custom'], ['']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'custom', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_void_string_array_4() + function! Custom() + return [[''], ['custom'], ['']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename'], ['custom'], ['modified']], [[0, 0], [1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_left_nil() + function! Custom() + return [ [], ['y0', 'y1'], ['z0', 'z1'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1', 'z0', 'z1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'modified']]), + \ [[['filename', 'y0', 'y1', 'z0', 'z1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_left_nil() + function! Custom() + return [ [], ['y0', 'y1'], ['z0', 'z1'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['modified']], [[0], [1, 1], [1, 1], [0]], ['0', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'modified']]), + \ [[['filename'], ['y0', 'y1'], ['z0', 'z1', 'modified']], [[0], [1, 1], [1, 1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_right_nil() + function! Custom() + return [ ['x0', 'x1'], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]), + \ [[['filename'], ['x0', 'x1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'modified']]), + \ [[['filename', 'x0', 'x1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_right_nil() + function! Custom() + return [ ['x0', 'x1'], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom'], ['modified']]), + \ [[['filename'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0], [1, 1], [1, 1], [0]], ['0', '1', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'modified']]), + \ [[['filename', 'x0', 'x1'], ['y0', 'y1'], ['modified']], [[0, 1, 1], [1, 1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_one() + function! Custom() + return [ 'left' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_one() + function! Custom() + return [ 'left' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['modified']], [[0, 0], [1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'modified']], [[0, 0, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_two() + function! Custom() + return [ 'left', 'middle'] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle'], ['modified']], [[0, 0], [1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'modified']], [[0, 0, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_two() + function! Custom() + return [ 'left', 'middle' ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['middle'], ['modified']], [[0, 0], [1], [1], [0]], ['0', '1', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['middle'], ['modified']], [[0, 0, 1], [1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_mixed() + function! Custom() + return ['left', { 'custom': 24 }, [function('tr')]] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', '{''custom'': 24}', 'function(''tr'')'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', '{''custom'': 24}', 'function(''tr'')', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_mixed() + function! Custom() + return ['left', { 'custom': 24 }, [function('tr')]] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['{''custom'': 24}'], ['function(''tr'')'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['{''custom'': 24}'], ['function(''tr'')', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_mixed_2() + function! Custom() + return [['left', ''], ['', { 'custom': 24 }, ''], [[function('tr')], '']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', '{''custom'': 24}', '[function(''tr'')]'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', '{''custom'': 24}', '[function(''tr'')]', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_mixed_2() + function! Custom() + return [['left', ''], ['', { 'custom': 24 }, ''], [[function('tr')], '']] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left'], ['{''custom'': 24}'], ['[function(''tr'')]'], ['modified']], [[0, 0], [1], [1], [1], [0]], ['0', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left'], ['{''custom'': 24}'], ['[function(''tr'')]', 'modified']], [[0, 0, 1], [1], [1, 0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_error() + function! Custom() + throw 'error' + return 'custom' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.custom_type_error() + function! Custom() + throw 'error' + return 'custom' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.notfound() + let g:lightline = { 'component_expand': { 'custom': 'NotFound' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) +endfunction + +function! s:suite.custom_type_notfound() + let g:lightline = { 'component_expand': { 'custom': 'NotFound' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], [], ['modified']], [[0, 0], [], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'modified']], [[0, 0, 0]], ['0', '1']]) +endfunction + +function! s:suite.duplicated_string() + function! Custom() + return 'custom' + endfunction + function! Modified() + return '' + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom', 'modified': 'Modified' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['custom', 'custom'], []], [[0], [1, 1], []], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'custom', 'custom']], [[0, 1, 1]], ['0', '1']]) + delfunction Custom + delfunction Modified +endfunction + +function! s:suite.duplicated_left_nil() + function! Custom() + return [ [], ['y0', 'y1'], ['z0', 'z1'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1', 'z0', 'z1', 'y0', 'y1', 'z0', 'z1'], ['modified']], [[0], [1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'y0', 'y1', 'z0', 'z1', 'y0', 'y1', 'z0', 'z1', 'modified']], [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_left_nil() + function! Custom() + return [ [], ['y0', 'y1'], ['z0', 'z1'] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['y0', 'y1'], ['z0', 'z1'], ['modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', 'custom', '1', 'custom', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename'], ['y0', 'y1'], ['z0', 'z1'], ['y0', 'y1'], ['z0', 'z1', 'modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1, 0]], ['0', 'custom', '0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_right_nil() + function! Custom() + return [ ['x0', 'x1'], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['x0', 'x1', 'y0', 'y1', 'x0', 'x1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1, 1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'x0', 'x1', 'y0', 'y1', 'x0', 'x1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_right_nil() + function! Custom() + return [ ['x0', 'x1'], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['x0', 'x1'], ['y0', 'y1'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0], [1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', '1', 'custom', '1', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'x0', 'x1'], ['y0', 'y1'], ['x0', 'x1'], ['y0', 'y1'], ['modified']], [[0, 1, 1], [1, 1], [1, 1], [1, 1], [0]], ['0', 'custom', '0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_both_nil() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename', 'y0', 'y1', 'y0', 'y1', 'modified']], [[0, 1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_both_nil() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom'], ['modified']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', 'custom', '2', '3']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom', 'modified']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1'], ['modified']], [[0], [1, 1, 1, 1], [0]], ['0', 'custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_both_nil_left_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['custom', 'custom'], ['modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['0', '1', '2']]) + call s:assert.equals(s:expand([['custom', 'custom', 'modified']]), + \ [[['y0', 'y1', 'y0', 'y1', 'modified']], [[1, 1, 1, 1, 0]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_both_nil_left_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['custom', 'custom'], ['modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', '1', '2']]) + call s:assert.equals(s:expand([['custom', 'custom', 'modified']]), + \ [[['y0', 'y1', 'y0', 'y1'], ['modified']], [[1, 1, 1, 1], [0]], ['custom', '0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_both_nil_right_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', '1', '2']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom']]), + \ [[['filename', 'y0', 'y1', 'y0', 'y1']], [[0, 1, 1, 1, 1]], ['0', '1']]) + delfunction Custom +endfunction + +function! s:suite.duplicated_type_both_nil_right_most() + function! Custom() + return [ [], ['y0', 'y1'], [] ] + endfunction + let g:lightline = { 'component_expand': { 'custom': 'Custom' }, 'component_type': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(s:expand([['filename'], ['custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '2']]) + call s:assert.equals(s:expand([['filename', 'custom', 'custom']]), + \ [[['filename'], ['y0', 'y1', 'y0', 'y1']], [[0], [1, 1, 1, 1]], ['0', 'custom', '1']]) + delfunction Custom +endfunction + +function! s:suite.dictionary_function() + let g:lightline = { 'component_expand': { 'custom': 'g:lightline.Custom' } } + function! g:lightline.Custom() + return [ ['left'], ['middle'], ['right'] ] + endfunction + call lightline#init() + call s:assert.equals(s:expand([['readonly', 'filename'], ['custom'], ['modified']]), + \ [[['readonly', 'filename'], ['left', 'middle', 'right'], ['modified']], [[0, 0], [1, 1, 1], [0]], ['0', '1', '2', '3']]) + call s:assert.equals(s:expand([['readonly', 'filename', 'custom', 'modified']]), + \ [[['readonly', 'filename', 'left', 'middle', 'right', 'modified']], [[0, 0, 1, 1, 1, 0]], ['0', '1']]) +endfunction diff --git a/sources_non_forked/lightline.vim/test/highlight.vim b/sources_non_forked/lightline.vim/test/highlight.vim new file mode 100644 index 00000000..590536c6 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/highlight.vim @@ -0,0 +1,171 @@ +let s:suite = themis#suite('highlight') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + hi clear +endfunction + +function! s:hi(name) + redir => hi + silent! exec 'hi' a:name + redir END + return substitute(join(split(hi, "\n"), ''), ' \+', ' ', 'g') +endfunction + +function! s:pattern(xs, ...) abort + let ys = a:0 ? a:xs[1:] : a:xs + let zs = get(a:000, 0, a:xs) + return 'ctermfg=' . ys[2] . ' ctermbg=' . zs[3] . '.*guifg=' . ys[0] . ' guibg=' . zs[1] +endfunction + +function! s:suite.highlight() + let g:lightline = {} + call lightline#init() + call lightline#colorscheme() + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) + call s:assert.match(s:hi('LightlineLeft_normal_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_normal_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) +endfunction + +function! s:suite.insert() + let g:lightline = {} + call lightline#init() + call lightline#colorscheme() + call lightline#highlight('insert') + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_insert_0'), s:pattern(palette.insert.left[0])) + call s:assert.match(s:hi('LightlineLeft_insert_1'), s:pattern(palette.insert.left[1])) + call s:assert.match(s:hi('LightlineLeft_insert_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_insert_0'), s:pattern(palette.insert.right[0])) + call s:assert.match(s:hi('LightlineRight_insert_1'), s:pattern(palette.insert.right[1])) + call s:assert.match(s:hi('LightlineRight_insert_2'), s:pattern(palette.insert.right[2])) + call s:assert.match(s:hi('LightlineRight_insert_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_insert'), s:pattern(palette.insert.middle[0])) +endfunction + + +function! s:suite.visual() + let g:lightline = {} + call lightline#init() + call lightline#colorscheme() + call lightline#highlight('visual') + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_visual_0'), s:pattern(palette.visual.left[0])) + call s:assert.match(s:hi('LightlineLeft_visual_1'), s:pattern(palette.visual.left[1])) + call s:assert.match(s:hi('LightlineLeft_visual_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_visual_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_visual_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_visual_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_visual_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) +endfunction + +function! s:suite.replace() + let g:lightline = {} + call lightline#init() + call lightline#colorscheme() + call lightline#highlight('replace') + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_replace_0'), s:pattern(palette.replace.left[0])) + call s:assert.match(s:hi('LightlineLeft_replace_1'), s:pattern(palette.replace.left[1])) + call s:assert.match(s:hi('LightlineLeft_replace_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_replace_0'), s:pattern(palette.replace.right[0])) + call s:assert.match(s:hi('LightlineRight_replace_1'), s:pattern(palette.replace.right[1])) + call s:assert.match(s:hi('LightlineRight_replace_2'), s:pattern(palette.replace.right[2])) + call s:assert.match(s:hi('LightlineRight_replace_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_replace'), s:pattern(palette.replace.middle[0])) +endfunction + +function! s:suite.left_right() + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ] + \ }, + \ } + call lightline#init() + call lightline#colorscheme() + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), s:pattern(palette.normal.left[1])) + call s:assert.match(s:hi('LightlineLeft_normal_2'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_3'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineLeft_normal_4'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), s:pattern(palette.normal.right[1])) + call s:assert.match(s:hi('LightlineRight_normal_2'), s:pattern(palette.normal.right[2])) + call s:assert.match(s:hi('LightlineRight_normal_3'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineRight_normal_4'), s:pattern(palette.normal.middle[0])) + call s:assert.match(s:hi('LightlineRight_normal_5'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) +endfunction + +function! s:suite.no_components() + let g:lightline = { + \ 'active': { + \ 'left': [], + \ 'right': [] + \ }, + \ 'inactive': { + \ 'left': [], + \ 'right': [] + \ }, + \ } + call lightline#init() + call lightline#colorscheme() + let palette = lightline#palette() + call s:assert.match(s:hi('LightlineLeft_normal_0'), s:pattern(palette.normal.left[0])) + call s:assert.match(s:hi('LightlineLeft_normal_1'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_normal_0'), s:pattern(palette.normal.right[0])) + call s:assert.match(s:hi('LightlineRight_normal_1'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_normal'), s:pattern(palette.normal.middle[0])) +endfunction + +function! s:suite.subseparator() + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ] + \ }, + \ } + call lightline#init() + call lightline#colorscheme() + let palette = lightline#palette() + for i in range(4) + for j in range(5) + if i + 1 == j + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0]))) + else + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', i, j)), 'E411: [hH]ighlight group not found\|cleared') + endif + endfor + endfor +endfunction + +function! s:suite.component_type() + let g:lightline = { 'component_type': { 'error': 'error', 'warning': 'warning' } } + call lightline#init() + call lightline#colorscheme() + let palette = lightline#palette() + for type in ['error', 'warning'] + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s', type)), s:pattern(palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_2_%s', type)), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0])) + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_3', type)), 'E411: [hH]ighlight group not found\|cleared') + endfor + for type1 in ['error', 'warning'] + for type2 in ['error', 'warning'] + call s:assert.match(s:hi(printf('LightlineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0])) + endfor + endfor +endfunction diff --git a/sources_non_forked/lightline.vim/test/link.vim b/sources_non_forked/lightline.vim/test/link.vim new file mode 100644 index 00000000..3235f548 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/link.vim @@ -0,0 +1,157 @@ +let s:suite = themis#suite('link') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + call s:clear() + let g:lightline = {} + call lightline#init() + call lightline#colorscheme() +endfunction + +function! s:clear() + hi clear + redir => hi + silent! hi + redir END + for line in split(hi, '\n') + if match(line, 'links to') > 0 + exec 'hi link' matchstr(line, '^\S*') 'NONE' + endif + endfor +endfunction + +function! s:hi(name) + redir => hi + silent! exec 'hi' a:name + redir END + return substitute(join(split(hi, "\n"), ''), ' \+', ' ', 'g') +endfunction + +function! s:suite.link() + call lightline#link() + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') +endfunction + +function! s:suite.insert() + call lightline#link('i') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_insert_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_insert_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_insert_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_insert_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_insert_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_insert') +endfunction + +function! s:suite.visual() + call lightline#link('v') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_visual_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_visual_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_visual_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_visual_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_visual_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_visual') +endfunction + +function! s:suite.replace() + call lightline#link('R') + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_replace_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_replace_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_replace_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_replace_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_replace_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_replace') +endfunction + +function! s:suite.left_right() + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ] + \ }, + \ } + call lightline#init() + call lightline#colorscheme() + call lightline#link() + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'LightlineLeft_normal_2') + call s:assert.match(s:hi('LightlineLeft_active_3'), 'LightlineLeft_normal_3') + call s:assert.match(s:hi('LightlineLeft_active_4'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'LightlineRight_normal_3') + call s:assert.match(s:hi('LightlineRight_active_4'), 'LightlineRight_normal_4') + call s:assert.match(s:hi('LightlineRight_active_5'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') +endfunction + +function! s:suite.subseparator() + let g:lightline = { + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ] + \ }, + \ } + call lightline#init() + call lightline#colorscheme() + call lightline#link() + for i in range(4) + for j in range(5) + if i + 1 == j + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), printf('LightlineLeft_normal_%s_%s', i, j)) + else + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', i, j)), 'E411: [hH]ighlight group not found\|cleared') + endif + endfor + endfor +endfunction + +function! s:suite.component_type() + let g:lightline = { 'component_type': { 'error': 'error', 'warning': 'warning' } } + call lightline#init() + call lightline#colorscheme() + call lightline#link() + for type in ['error', 'warning'] + call s:assert.match(s:hi(printf('LightlineLeft_active_%s', type)), printf('LightlineLeft_normal_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_0_%s', type)), printf('LightlineLeft_normal_0_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_1_%s', type)), printf('LightlineLeft_normal_1_%s', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_2_%s', type)), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_0', type)), printf('LightlineLeft_normal_%s_0', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_1', type)), printf('LightlineLeft_normal_%s_1', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_2', type)), printf('LightlineLeft_normal_%s_2', type)) + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_3', type)), 'E411: [hH]ighlight group not found\|cleared') + endfor + for type1 in ['error', 'warning'] + for type2 in ['error', 'warning'] + call s:assert.match(s:hi(printf('LightlineLeft_active_%s_%s', type1, type2)), printf('LightlineLeft_normal_%s_%s', type1, type2)) + endfor + endfor +endfunction + +function! s:suite.hi_clear() + call lightline#link() + colorscheme default + call lightline#link() + call s:assert.match(s:hi('LightlineLeft_active_0'), 'LightlineLeft_normal_0') + call s:assert.match(s:hi('LightlineLeft_active_1'), 'LightlineLeft_normal_1') + call s:assert.match(s:hi('LightlineLeft_active_2'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineRight_active_0'), 'LightlineRight_normal_0') + call s:assert.match(s:hi('LightlineRight_active_1'), 'LightlineRight_normal_1') + call s:assert.match(s:hi('LightlineRight_active_2'), 'LightlineRight_normal_2') + call s:assert.match(s:hi('LightlineRight_active_3'), 'E411: [hH]ighlight group not found\|cleared') + call s:assert.match(s:hi('LightlineMiddle_active'), 'LightlineMiddle_normal') +endfunction diff --git a/sources_non_forked/lightline.vim/test/mode.vim b/sources_non_forked/lightline.vim/test/mode.vim new file mode 100644 index 00000000..53280f51 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/mode.vim @@ -0,0 +1,14 @@ +let s:suite = themis#suite('mode') +let s:assert = themis#helper('assert') + +function! s:suite.mode() + let g:lightline = {} + call lightline#init() + call s:assert.equals(lightline#mode(), 'NORMAL') +endfunction + +function! s:suite.mode_map() + let g:lightline = { 'mode_map': { 'n': 'N' } } + call lightline#init() + call s:assert.equals(lightline#mode(), 'N') +endfunction diff --git a/sources_non_forked/lightline.vim/test/onetab.vim b/sources_non_forked/lightline.vim/test/onetab.vim new file mode 100644 index 00000000..529d8332 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/onetab.vim @@ -0,0 +1,98 @@ +let s:suite = themis#suite('onetab') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.onetab() + call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]') +endfunction + +function! s:suite.tabnew() + tabnew + call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]') + call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]') +endfunction + +function! s:suite.tabnew_tabnew() + tabnew + tabnew + call s:assert.equals(lightline#onetab(1, 0), '1 [No Name]') + call s:assert.equals(lightline#onetab(2, 0), '2 [No Name]') + call s:assert.equals(lightline#onetab(3, 1), '3 [No Name]') +endfunction + +function! s:suite.modified() + call append(0, '') + call s:assert.equals(lightline#onetab(1, 1), '1 [No Name] +') + undo +endfunction + +function! s:suite.filename() + edit test + call s:assert.equals(lightline#onetab(1, 1), '1 test') + tabnew + bunload test +endfunction + +function! s:suite.filename_modified() + edit test + call append(0, '') + call s:assert.equals(lightline#onetab(1, 1), '1 test +') + tabnew + bunload! test +endfunction + +function! s:suite.active_inactive() + let g:lightline = { 'tab': { 'active': [ 'tabnum', 'filename' ], 'inactive': [ 'filename' ] } } + call lightline#init() + edit test + call append(0, '') + call s:assert.equals(lightline#onetab(1, 1), '1 test') + call s:assert.equals(lightline#onetab(1, 0), 'test') + tabnew + bunload! test +endfunction + +function! s:suite.tab_component() + let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component': { 'custom': 'custom' } } + call lightline#init() + call s:assert.equals(lightline#onetab(1, 1), 'custom') + call s:assert.equals(lightline#onetab(2, 1), 'custom') +endfunction + +function! s:suite.tab_component_function() + function! Custom(n) + return 'custom: ' . a:n + endfunction + let g:lightline = { 'tab': { 'active': [ 'custom' ] }, 'tab_component_function': { 'custom': 'Custom' } } + call lightline#init() + call s:assert.equals(lightline#onetab(1, 1), 'custom: 1') + call s:assert.equals(lightline#onetab(2, 1), 'custom: 2') + delfunction Custom +endfunction + +function! s:suite.tab_component_empty_middle() + let g:lightline = { 'tab': { 'active': [ 'tabnum', 'custom', 'filename' ], 'inactive': [ 'tabnum', 'custom', 'custom', 'filename' ] }, 'tab_component': { 'custom': '' } } + call lightline#init() + call s:assert.equals(lightline#onetab(1, 1), '1 [No Name]') + call s:assert.equals(lightline#onetab(2, 1), '2 [No Name]') +endfunction + +function! s:suite.tab_component_empty_left() + let g:lightline = { 'tab': { 'active': [ 'custom', 'filename' ], 'inactive': [ 'custom', 'custom', 'filename' ] }, 'tab_component': { 'custom': '' } } + call lightline#init() + call s:assert.equals(lightline#onetab(1, 1), '[No Name]') + call s:assert.equals(lightline#onetab(2, 1), '[No Name]') +endfunction + +function! s:suite.tab_component_empty_middle() + let g:lightline = { 'tab': { 'active': [ 'tabnum', 'custom' ], 'inactive': [ 'tabnum', 'custom', 'custom' ] }, 'tab_component': { 'custom': '' } } + call lightline#init() + call s:assert.equals(lightline#onetab(1, 1), '1') + call s:assert.equals(lightline#onetab(2, 1), '2') +endfunction diff --git a/sources_non_forked/lightline.vim/test/popup.vim b/sources_non_forked/lightline.vim/test/popup.vim new file mode 100644 index 00000000..cc4e882a --- /dev/null +++ b/sources_non_forked/lightline.vim/test/popup.vim @@ -0,0 +1,19 @@ +if !exists('*popup_menu') || !exists('*win_execute') + finish +endif + +let s:suite = themis#suite('popup') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.win_execute_setfiletype() + let id = popup_menu(['aaa', 'bbb'], {}) + call win_execute(id, 'setfiletype vim') + call popup_close(id) +endfunction diff --git a/sources_non_forked/lightline.vim/test/quickfix.vim b/sources_non_forked/lightline.vim/test/quickfix.vim new file mode 100644 index 00000000..df4fce7a --- /dev/null +++ b/sources_non_forked/lightline.vim/test/quickfix.vim @@ -0,0 +1,25 @@ +let s:suite = themis#suite('quickfix') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.quickfix_statusline() + call setloclist(winnr(), []) + lopen + wincmd p + call setloclist(winnr(), []) + for n in range(1, winnr('$')) + let statusline = getwinvar(n, '&statusline') + call s:assert.match(statusline, 'lightline') + if has('patch-8.1.1715') + call s:assert.match(statusline, n == 1 ? '_active_' : '_inactive_') + else + call s:assert.match(statusline, n != 1 ? '_active_' : '_inactive_') + endif + endfor +endfunction diff --git a/sources_non_forked/lightline.vim/test/subseparator.vim b/sources_non_forked/lightline.vim/test/subseparator.vim new file mode 100644 index 00000000..2393840d --- /dev/null +++ b/sources_non_forked/lightline.vim/test/subseparator.vim @@ -0,0 +1,407 @@ +let s:suite = themis#suite('subseparator') +let s:assert = themis#helper('assert') + +function! s:subseparator(...) + return eval(substitute(call(SID('subseparator'), a:000), '^%{\|}$', '', 'g')) +endfunction + +function! s:suite.subseparator_component() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_visible_condition_1() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_visible_condition_2() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_visible_condition_3() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_visible_condition_4() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_visible_condition_5() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '0', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_visible_condition_6() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1||0', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_visible_condition_7() + let g:lightline = { 'component': { 'custom1': 'custom1', 'custom2': 'custom2', 'custom3': 'custom3' }, 'component_visible_condition': { 'custom1': '1||1', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_1() + function! Custom1() + return 'custom1' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom1 +endfunction + +function! s:suite.subseparator_component_function_2() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') + delfunction Custom1 + delfunction Custom2 +endfunction + +function! s:suite.subseparator_component_function_3() + function! Custom1() + return 'custom1' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') + delfunction Custom1 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_4() + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_5() + function! Custom1() + return '' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_6() + function! Custom1() + return '' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_7() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return '' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_function_visible_condition_1() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_2() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0', 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_3() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_4() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '1', 'custom2': '0', 'custom3': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_5() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return '' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom1': '0' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_6() + function! Custom1() + return '' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom2': '1', 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') +endfunction + +function! s:suite.subseparator_component_function_visible_condition_7() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return '' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' }, 'component_function_visible_condition': { 'custom3': '1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') +endfunction + +function! s:suite.subseparator_component_expand() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 1]), '|') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_expand() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 1]), '|') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_expand_1() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_expand': { 'custom1': 'Custom1' }, 'component_function': { 'custom2': 'Custom2', 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 0, 0]), '|') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_expand_2() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_expand': { 'custom1': 'Custom1', 'custom2': 'Custom2' }, 'component_function': { 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [1, 1, 0]), '|') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_expand_3() + function! Custom1() + return '' + endfunction + function! Custom2() + return 'custom2' + endfunction + function! Custom3() + return 'custom3' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2' }, 'component_expand': { 'custom3': 'Custom3' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 1]), '') + delfunction Custom1 + delfunction Custom2 + delfunction Custom3 +endfunction + +function! s:suite.subseparator_component_not_found() + function! Custom1() + return 'custom1' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom1 +endfunction + +function! s:suite.subseparator_component_not_found_1() + function! Custom2() + return 'custom2' + endfunction + let g:lightline = { 'component_function': { 'custom2': 'Custom2' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '') + delfunction Custom2 +endfunction + +function! s:suite.subseparator_component_not_found_2() + function! Custom1() + return 'custom1' + endfunction + function! Custom2() + return 'custom2' + endfunction + let g:lightline = { 'component_function': { 'custom1': 'Custom1', 'custom2': 'Custom2' } } + call lightline#init() + call s:assert.equals(s:subseparator(['custom1', 'custom2', 'custom3'], '|', [0, 0, 0]), '|') + delfunction Custom1 + delfunction Custom2 +endfunction diff --git a/sources_non_forked/lightline.vim/test/tabline.vim b/sources_non_forked/lightline.vim/test/tabline.vim new file mode 100644 index 00000000..0a9879f6 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/tabline.vim @@ -0,0 +1,67 @@ +let s:suite = themis#suite('tabline') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.tabline() + call s:assert.equals(&tabline, '%!lightline#tabline()') +endfunction + +function! s:suite.enabled() + let g:lightline = { 'enable': { 'tabline': 1 } } + call lightline#init() + call s:assert.equals(&tabline, '%!lightline#tabline()') +endfunction + +function! s:suite.disabled() + let g:lightline = { 'enable': { 'tabline': 0 } } + call lightline#init() + call s:assert.equals(&tabline, '') +endfunction + +function! s:suite.tabnew() + let tabline = lightline#tabline() + tabnew + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction + +function! s:suite.tabnew_first() + let tabline = lightline#tabline() + 0tabnew + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction + +function! s:suite.tabnext() + tabnew + let tabline = lightline#tabline() + tabnext + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction + +function! s:suite.tabonly() + tabnew + tabfirst + let tabline = lightline#tabline() + tabonly + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction + +function! s:suite.tabclose() + tabnew + let tabline = lightline#tabline() + tabclose + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction + +function! s:suite.tabclose_last() + tabnew + tabfirst + let tabline = lightline#tabline() + $tabclose + call s:assert.not_equals(lightline#tabline(), tabline) +endfunction diff --git a/sources_non_forked/lightline.vim/test/tabs.vim b/sources_non_forked/lightline.vim/test/tabs.vim new file mode 100644 index 00000000..863dd7fa --- /dev/null +++ b/sources_non_forked/lightline.vim/test/tabs.vim @@ -0,0 +1,99 @@ +let s:suite = themis#suite('tabs') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + set columns=180 + call lightline#init() + tabnew + tabonly +endfunction + +function! s:tab(number, ...) abort + let active = get(a:000, 0, 0) + let last = get(a:000, 1, 0) + return '%' . a:number . 'T%{lightline#onetab(' . a:number . ',' . active . ')}' . (last ? '%T' : '') +endfunction + +function! s:suite.tabs() + call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1, 1)], []]) +endfunction + +function! s:suite.tabnew() + tabnew + call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1, 1)], []]) +endfunction + +function! s:suite.tabnew_tabnew() + tabnew + tabnew + call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2)], [s:tab(3, 1, 1)], []]) +endfunction + +function! s:suite.tabnew_tabfirst() + tabnew + tabfirst + call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2, 0, 1)]]) +endfunction + +function! s:suite.tabnew_tabnew_tabfirst() + tabnew + tabnew + tabfirst + call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3, 0, 1)]]) +endfunction + +function! s:suite.tabnew_tabnew_tabprevious() + tabnew + tabnew + tabprevious + call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3, 0, 1)]]) +endfunction + +function! s:suite.tabnew_20() + for i in range(19) + tabnew + endfor + call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), s:tab(4), '...', s:tab(16), s:tab(17), s:tab(18), s:tab(19)], [s:tab(20, 1, 1)], []]) +endfunction + +function! s:suite.tabnew_20_tabfirst() + for i in range(19) + tabnew + endfor + tabfirst + call s:assert.equals(lightline#tabs(), [[], [s:tab(1, 1)], [s:tab(2), s:tab(3), s:tab(4), '%<' . s:tab(5), '...', '%<' . s:tab(17), '%<' . s:tab(18), '%<' . s:tab(19), '%<' . s:tab(20, 0, 1)]]) +endfunction + +function! s:suite.tabnew_20_tabfirst_tabnext() + for i in range(19) + tabnew + endfor + tabfirst + tabnext + call s:assert.equals(lightline#tabs(), [[s:tab(1)], [s:tab(2, 1)], [s:tab(3), s:tab(4), s:tab(5), '%<' . s:tab(6), '...', '%<' . s:tab(18), '%<' . s:tab(19), '%<' . s:tab(20, 0, 1)]]) +endfunction + +function! s:suite.tabnew_20_tabnext_10() + for i in range(19) + tabnew + endfor + tabnext 10 + call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), '...', s:tab(8), s:tab(9)], [s:tab(10, 1)], [s:tab(11), s:tab(12), '...', '%<' . s:tab(19), '%<' . s:tab(20, 0, 1)]]) +endfunction + +function! s:suite.tabnew_20_tabprevious() + for i in range(19) + tabnew + endfor + tabprevious + call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17), s:tab(18)], [s:tab(19, 1)], [s:tab(20, 0, 1)]]) +endfunction + +function! s:suite.tabnew_20_tabprevious_tabprevious() + for i in range(19) + tabnew + endfor + tabprevious + tabprevious + call s:assert.equals(lightline#tabs(), [[s:tab(1), s:tab(2), s:tab(3), '...', s:tab(15), s:tab(16), s:tab(17)], [s:tab(18, 1)], [s:tab(19), s:tab(20, 0, 1)]]) +endfunction diff --git a/sources_non_forked/lightline.vim/test/toggle.vim b/sources_non_forked/lightline.vim/test/toggle.vim new file mode 100644 index 00000000..6f7eb5bd --- /dev/null +++ b/sources_non_forked/lightline.vim/test/toggle.vim @@ -0,0 +1,51 @@ +let s:suite = themis#suite('toggle') +let s:assert = themis#helper('assert') + +function! s:suite.before_each() + let g:lightline = {} + call lightline#init() + tabnew + tabonly +endfunction + +function! s:suite.default() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) + call s:assert.not_equals(&statusline, '') + call s:assert.not_equals(&tabline, '') +endfunction + +function! s:suite.disable_enable() + call lightline#disable() + call s:assert.equals(exists('#lightline'), 0) + call s:assert.equals(exists('#lightline-disable'), 1) + call s:assert.equals(&statusline, '') + call s:assert.equals(&tabline, '') + call lightline#update() + call s:assert.equals(&statusline, '') + call s:assert.equals(&tabline, '') + call lightline#enable() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) + call s:assert.not_equals(&statusline, '') + call s:assert.not_equals(&tabline, '') + call lightline#disable() + call lightline#disable() + call lightline#enable() + call lightline#enable() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) +endfunction + +function! s:suite.toggle() + call lightline#toggle() + call s:assert.equals(exists('#lightline'), 0) + call s:assert.equals(exists('#lightline-disable'), 1) + call s:assert.equals(&statusline, '') + call s:assert.equals(&tabline, '') + call lightline#toggle() + call s:assert.equals(exists('#lightline'), 1) + call s:assert.equals(exists('#lightline-disable'), 0) + call s:assert.not_equals(&statusline, '') + call s:assert.not_equals(&tabline, '') +endfunction diff --git a/sources_non_forked/lightline.vim/test/uniq.vim b/sources_non_forked/lightline.vim/test/uniq.vim new file mode 100644 index 00000000..cdfaec09 --- /dev/null +++ b/sources_non_forked/lightline.vim/test/uniq.vim @@ -0,0 +1,46 @@ +let s:suite = themis#suite('uniq') +let s:assert = themis#helper('assert') + +function! s:uniq(...) + try + return call(SID('uniq'), a:000) + catch + return call(function('uniq'), a:000) + endtry +endfunction + +function! s:suite.nil() + call s:assert.equals(s:uniq([]), []) +endfunction + +function! s:suite.one() + call s:assert.equals(s:uniq(['foo']), ['foo']) +endfunction + +function! s:suite.two() + call s:assert.equals(s:uniq(['foo', 'bar']), ['foo', 'bar']) +endfunction + +function! s:suite.three() + call s:assert.equals(s:uniq(['foo', 'bar', 'baz']), ['foo', 'bar', 'baz']) +endfunction + +function! s:suite.two_duplicated() + call s:assert.equals(s:uniq(['foo', 'foo']), ['foo']) +endfunction + +function! s:suite.three_duplicated() + call s:assert.equals(s:uniq(['foo', 'bar', 'foo']), ['foo', 'bar', 'foo']) +endfunction + +function! s:suite.many1() + call s:assert.equals(s:uniq(['foo', 'foo', 'bar', 'baz', 'baz', 'qux', 'foo']), ['foo', 'bar', 'baz', 'qux', 'foo']) +endfunction + +function! s:suite.many2() + call s:assert.equals(s:uniq(['foo', 'foo', 'foo', 'foo', 'bar', 'bar', 'bar']), ['foo', 'bar']) +endfunction + +function! s:suite.many3() + call s:assert.equals(s:uniq(['foo', 'foo', 'bar', 'bar', 'bar', 'foo', 'foo', 'foo']), ['foo', 'bar', 'foo']) +endfunction diff --git a/sources_non_forked/mayansmoke/README b/sources_non_forked/mayansmoke/README new file mode 100644 index 00000000..7f5b5c42 --- /dev/null +++ b/sources_non_forked/mayansmoke/README @@ -0,0 +1,43 @@ +This is a mirror of http://www.vim.org/scripts/script.php?script_id=3065 + +This is a pleasant and ergonomic light-background color scheme, designed for long hours of coding and working. The UI elements are muted without being drab, the syntax elements are colorful without being garish, and the background is relaxing without being soporific. It is of a low-enough contrast so as not to cause eye-burn, but high-enough contrast so as not to cause eye-strain. The syntax coloration offers just a little higher resolution than most, distinguishing between class names vs. functions, strings and numbers vs. other constants, etc. Many of the colors in this color scheme are drawn from Mayan murals, paintings and codices, and thus the name. + +Screenshots: +========== + + - Python: http://jeetworks.org/files/images/mayansmoke-python1.png + - C++: http://jeetworks.org/files/images/mayansmoke-cpp1.png + +Customization: +============== + +If any of the following highlights are defined (e.g., in your "~/.vimrc"), these will override the default highlight definitions: + + MayanSmokeCursorLine (will be applied to: CursorColumn and CursorLine) + MayanSmokeSearch (will be applied to: Search and IncSearch) + MayanSmokeSpecialKey (will be applied to: SpecialKey) + +For example, you can set the following in your "~/.vimrc" to select your own colors for these items: + + hi MayanSmokeCursorLine guifg=NONE guibg=yellow gui=NONE + hi MayanSmokeSearch guifg=white guibg=blue gui=NONE + hi MayanSmokeSpecialKey guifg=NONE guibg=green gui=NONE + +Alternatively, you can define one or more of the following values in your "~/.vimrc" to select different pre-defined levels of visibility for the above highlights: + + let g:mayansmoke_cursor_line_visibility = 0 " lower visibility + let g:mayansmoke_cursor_line_visibility = 1 " medium visibility + let g:mayansmoke_cursor_line_visibility = 2 " higher visibility + + let g:mayansmoke_search_visibility = 0 " low visibility + let g:mayansmoke_search_visibility = 1 " medium visibility (default) + let g:mayansmoke_search_visibility = 2 " high visibility + let g:mayansmoke_search_visibility = 3 " very high visibility + let g:mayansmoke_search_visibility = 4 " highest visibility + + let g:mayansmoke_special_key_visibility = 0 " lower visibility + let g:mayansmoke_special_key_visibility = 1 " medium visibility + let g:mayansmoke_special_key_visibility = 2 " higher visibility + + + diff --git a/sources_non_forked/mayansmoke/colors/mayansmoke.vim b/sources_non_forked/mayansmoke/colors/mayansmoke.vim new file mode 100644 index 00000000..6d146f86 --- /dev/null +++ b/sources_non_forked/mayansmoke/colors/mayansmoke.vim @@ -0,0 +1,343 @@ +" ============================================================================= +" +" File: mayansmoke.vim +" Description: Vim color scheme file +" Maintainer: Jeet Sukumaran (GUI colors); Clayton Parker (cterm colors) +" +" ============================================================================= + +" Initialization and Setup {{{1 +" ============================================================================= +set background=light +highlight clear +if exists("syntax_on") + syntax reset +endif +let colors_name = "mayansmoke" +" }}} + +" Normal Color {{{1 +" ============================================================================= +hi Normal gui=NONE guifg=Black guibg=#F4F4E8 +" }}} + +" Highlight Groups {{{1 +" ============================================================================= +" Groups (see ':help highlight-groups'): +" ColorColumn highlight to use with ':set colorcolumn' +" Cursor the character under the cursor +" CursorIM like Cursor, but used when in IME mode |CursorIM| +" CursorColumn the screen column that the cursor is in when 'cursorcolumn' is set +" CursorLine the screen line that the cursor is in when 'cursorline' is set +" Directory directory names (and other special names in listings) +" DiffAdd diff mode: Added line |diff.txt| +" DiffChange diff mode: Changed line |diff.txt| +" DiffDelete diff mode: Deleted line |diff.txt| +" DiffText diff mode: Changed text within a changed line |diff.txt| +" ErrorMsg error messages on the command line +" VertSplit the column separating vertically split windows +" Folded line used for closed folds +" FoldColumn 'foldcolumn' +" SignColumn column where |signs| are displayed +" IncSearch 'incsearch' highlighting; also used for the text replaced with ":s///c" +" LineNr Line number for ":number" and ":#" commands, and when 'number' option is set. +" MatchParen The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| +" ModeMsg 'showmode' message (e.g., "-- INSERT --") +" MoreMsg |more-prompt| +" NonText '~' and '@' at the end of the window, etc. +" Normal normal text +" Pmenu Popup menu: normal item. +" PmenuSel Popup menu: selected item. +" PmenuSbar Popup menu: scrollbar. +" PmenuThumb Popup menu: Thumb of the scrollbar. +" Question |hit-enter| prompt and yes/no questions +" Search Last search pattern highlighting (see 'hlsearch'). +" SpecialKey Meta and special keys listed with ":map", text that is displayed differently from what it really is (such as tabs, spaces in listchars etc.). +" SpellBad Word that is not recognized by the spellchecker. |spell| +" SpellCap Word that should start with a capital. |spell| +" SpellLocal Word that is recognized by the spellchecker as one that is +" SpellRare Word that is recognized by the spellchecker as one that is hardly ever used. |spell| +" StatusLine status line of current window +" StatusLineNC status lines of not-current windows +" TabLine tab pages line, not active tab page label +" TabLineFill tab pages line, where there are no labels +" TabLineSel tab pages line, active tab page label +" Title titles for output from ":set all", ":autocmd" etc. +" Visual Visual mode selection +" VisualNOS Visual mode selection when vim is "Not Owning the Selection". +" WarningMsg warning messages +" WildMenu current match in 'wildmenu' completion +hi ColorColumn guifg=NONE guibg=#EEEEDD +hi Cursor guifg=bg guibg=fg gui=NONE +if hlexists('MayanSmokeCursorLine') + hi link CursorColumn MayanSmokeCursorLine + hi link CursorLine MayanSmokeCursorLine +elseif exists('g:mayansmoke_cursor_line_visibility') && g:mayansmoke_cursor_line_visibility >= 2 + hi CursorColumn guifg=NONE guibg=NavajoWhite gui=NONE + hi CursorLine guifg=NONE guibg=NavajoWhite gui=NONE +elseif exists('g:mayansmoke_cursor_line_visibility') && g:mayansmoke_cursor_line_visibility >= 1 + hi CursorColumn guifg=NONE guibg=white gui=NONE + hi CursorLine guifg=NONE guibg=white gui=NONE +else + hi CursorColumn guifg=NONE guibg=#FFFDD0 gui=NONE + hi CursorLine guifg=NONE guibg=#FFFDD0 gui=NONE +endif +hi CursorIM guifg=bg guibg=fg gui=NONE +hi lCursor guifg=bg guibg=fg gui=NONE +hi DiffAdd guifg=NONE guibg=SeaGreen1 gui=NONE +hi DiffChange guifg=NONE guibg=LightSkyBlue1 gui=NONE +hi DiffDelete guifg=NONE guibg=LightCoral gui=NONE +hi DiffText guifg=black guibg=LightCyan1 gui=NONE +hi Directory guifg=#1600FF guibg=bg gui=NONE +hi ErrorMsg guifg=Red2 guibg=NONE gui=NONE +hi FoldColumn guifg=SteelBlue4 guibg=LightYellow2 gui=bold +hi Folded guifg=SteelBlue4 guibg=Gainsboro gui=italic +if hlexists('MayanSmokeSearch') + hi link IncSearch MayanSmokeSearch + hi link Search MayanSmokeSearch +elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility >= 4 + hi IncSearch guifg=white guibg=red gui=NONE + hi Search guifg=white guibg=red gui=NONE +elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 3 + hi IncSearch guifg=black guibg=gold gui=NONE + hi Search guifg=black guibg=gold gui=NONE +elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 2 + hi IncSearch guifg=white guibg=darkorange gui=NONE + hi Search guifg=white guibg=darkorange gui=NONE +elseif exists('g:mayansmoke_search_visibility') && g:mayansmoke_search_visibility == 0 + hi IncSearch guifg=black guibg=tan gui=NONE + hi Search guifg=black guibg=tan gui=NONE +else + hi IncSearch guifg=black guibg=khaki gui=NONE + hi Search guifg=black guibg=khaki gui=NONE +endif +hi LineNr guifg=#666677 guibg=#cccfbf gui=NONE +hi MatchParen guifg=black guibg=LemonChiffon3 gui=bold +hi ModeMsg guifg=White guibg=tomato1 gui=bold +hi MoreMsg guifg=SeaGreen4 guibg=bg gui=bold +hi NonText guifg=LightCyan3 guibg=bg gui=bold + +hi Pmenu guifg=Orange4 guibg=LightYellow3 gui=NONE +hi PmenuSel guifg=ivory2 guibg=NavajoWhite4 gui=bold +hi PmenuSbar guifg=White guibg=#999666 gui=NONE +hi PmenuThumb guifg=White guibg=#7B7939 gui=NONE + +hi Question guifg=Chartreuse4 guibg=bg gui=bold +hi SignColumn guifg=white guibg=LightYellow3 gui=NONE +if hlexists('MayanSmokeSpecialKey') + hi link SpecialKey MayanSmokeSpecialKey +elseif exists('g:mayansmoke_special_key_visibility') && g:mayansmoke_special_key_visibility >= 2 + hi SpecialKey guifg=black guibg=NavajoWhite gui=NONE +elseif exists('g:mayansmoke_special_key_visibility') && g:mayansmoke_special_key_visibility == 0 + hi SpecialKey guifg=bisque3 guibg=NONE gui=NONE +else + hi SpecialKey guifg=white guibg=ivory3 gui=NONE +endif +hi SpellBad guisp=Firebrick2 gui=undercurl +hi SpellCap guisp=Blue gui=undercurl +hi SpellLocal guisp=DarkCyan gui=undercurl +hi SpellRare guisp=Magenta gui=undercurl +hi StatusLine guifg=#FFFEEE guibg=#557788 gui=NONE +" hi StatusLineNC guifg=#EAE6E2 guibg=LightSteelBlue3 gui=italic +hi StatusLineNC guifg=#F4F4EE guibg=#99aabb gui=italic +hi TabLine guifg=fg guibg=LightGrey gui=underline +hi TabLineFill guifg=fg guibg=bg gui=reverse +hi TabLineSel guifg=fg guibg=bg gui=bold +hi Title guifg=DeepSkyBlue3 guibg=bg gui=bold +hi VertSplit guifg=#99aabb guibg=#99aabb +hi Visual guifg=white guibg=DeepSkyBlue1 gui=NONE +hi WarningMsg guifg=Firebrick2 guibg=bg gui=NONE +hi WildMenu guifg=Black guibg=SkyBlue gui=NONE +" }}} + +" 256-Color Terminal Colors, by Clayton Parker {{{1 +" ============================================================================= +hi Normal cterm=NONE ctermfg=16 ctermbg=255 +hi Comment ctermfg=110 +hi Constant ctermfg=214 + hi String ctermfg=30 + hi Boolean ctermfg=88 +hi Identifier ctermfg=160 +hi Function ctermfg=132 +hi Statement ctermfg=21 +hi Keyword ctermfg=45 +hi PreProc ctermfg=27 +hi Type ctermfg=147 +hi Special ctermfg=64 +hi Ignore ctermfg=255 +hi Error ctermfg=196 ctermbg=255 term=none +hi Todo ctermfg=136 ctermbg=255 cterm=NONE +hi VimError ctermfg=160 ctermbg=16 +hi VimCommentTitle ctermfg=110 +hi qfLineNr ctermfg=16 ctermbg=46 cterm=NONE +hi pythonDecorator ctermfg=208 ctermbg=255 cterm=NONE +hi Cursor ctermfg=255 ctermbg=16 cterm=NONE +hi CursorColumn ctermfg=NONE ctermbg=255 cterm=NONE +hi CursorIM ctermfg=255 ctermbg=16 cterm=NONE +hi CursorLine ctermfg=NONE ctermbg=254 cterm=NONE +hi lCursor ctermfg=255 ctermbg=16 cterm=NONE +hi DiffAdd ctermfg=16 ctermbg=48 cterm=NONE +hi DiffChange ctermfg=16 ctermbg=153 cterm=NONE +hi DiffDelete ctermfg=16 ctermbg=203 cterm=NONE +hi DiffText ctermfg=16 ctermbg=226 cterm=NONE +hi Directory ctermfg=21 ctermbg=255 cterm=NONE +hi ErrorMsg ctermfg=160 ctermbg=NONE cterm=NONE +hi FoldColumn ctermfg=24 ctermbg=252 cterm=NONE +hi Folded ctermfg=24 ctermbg=252 cterm=NONE +hi IncSearch ctermfg=255 ctermbg=160 cterm=NONE +hi LineNr ctermfg=253 ctermbg=110 cterm=NONE +hi NonText ctermfg=110 ctermbg=255 cterm=NONE +hi Pmenu ctermfg=fg ctermbg=195 cterm=NONE +hi PmenuSbar ctermfg=255 ctermbg=153 cterm=NONE +hi PmenuSel ctermfg=255 ctermbg=21 cterm=NONE +hi PmenuThumb ctermfg=111 ctermbg=255 cterm=NONE +hi SignColumn ctermfg=110 ctermbg=254 cterm=NONE +hi Search ctermfg=255 ctermbg=160 cterm=NONE +hi SpecialKey ctermfg=255 ctermbg=144 cterm=NONE +hi SpellBad ctermfg=16 ctermbg=229 cterm=NONE +hi SpellCap ctermfg=16 ctermbg=231 cterm=NONE +hi SpellLocal ctermfg=16 ctermbg=231 cterm=NONE +hi SpellRare ctermfg=16 ctermbg=226 cterm=NONE +hi StatusLine ctermfg=255 ctermbg=24 cterm=NONE +hi StatusLineNC ctermfg=253 ctermbg=110 cterm=NONE +hi Title ctermfg=75 ctermbg=255 cterm=NONE +hi VertSplit ctermfg=255 ctermbg=24 cterm=NONE +hi Visual ctermfg=255 ctermbg=153 cterm=NONE +hi WildMenu ctermfg=16 ctermbg=117 cterm=NONE + +" 1}}} + +" Syntax {{{1 +" ============================================================================= + +" General {{{2 +" ----------------------------------------------------------------------------- +" Groups ('*' = major; see 'help group-name'): +" *Comment any comment +" *Constant any constant +" String a string constant: "this is a string" +" Character a character constant: 'c', '\n' +" Number a number constant: 234, 0xff +" Boolean a boolean constant: TRUE, false +" Float a floating point constant: 2.3e10 +" *Identifier any variable name +" Function function name (also: methods for classes) +" *Statement any statement +" Conditional if, then, else, endif, switch, etc. +" Repeat for, do, while, etc. +" Label case, default, etc. +" Operator "sizeof", "+", "*", etc. +" Keyword any other keyword +" Exception try, catch, throw +" *PreProc generic Preprocessor +" Include preprocessor #include +" Define preprocessor #define +" Macro same as Define +" PreCondit preprocessor #if, #else, #endif, etc. +" *Type int, long, char, etc. +" StorageClass static, register, volatile, etc. +" Structure struct, union, enum, etc. +" Typedef A typedef +" *Special any special symbol +" SpecialChar special character in a constant +" Tag you can use CTRL-] on this +" Delimiter character that needs attention +" SpecialComment special things inside a comment +" Debug debugging statements +" *Error any erroneous construct +" *Todo anything that needs extra attention +" hi Comment guifg=#A2B5CD guibg=NONE gui=italic +hi Comment guifg=#96AAC2 guibg=NONE gui=italic +hi Constant guifg=DarkOrange guibg=NONE gui=NONE + hi String guifg=Aquamarine4 guibg=NONE gui=NONE + hi Boolean guifg=IndianRed4 guibg=NONE gui=NONE +hi Identifier guifg=brown3 guibg=NONE gui=NONE +hi Function guifg=VioletRed4 guibg=NONE gui=NONE +hi Statement guifg=blue1 guibg=NONE gui=NONE +hi Keyword guifg=DodgerBlue guibg=NONE gui=NONE +hi PreProc guifg=blue1 guibg=NONE gui=NONE +hi Type guifg=LightSlateBlue guibg=NONE gui=NONE +hi Special guifg=DarkOliveGreen4 guibg=NONE gui=NONE +hi Ignore guifg=bg guibg=NONE gui=NONE +hi Error guifg=Red guibg=NONE gui=underline +hi Todo guifg=tan4 guibg=NONE gui=underline +" 2}}} + +" Vim {{{2 +" ----------------------------------------------------------------------------- +hi VimError guifg=red guibg=Black gui=bold +hi VimCommentTitle guifg=DarkSlateGray4 guibg=bg gui=bold,italic +" 2}}} + +" QuickFix {{{2 +" ----------------------------------------------------------------------------- + +" syn match qfFileName "^[^|]*" nextgroup=qfSeparator +" syn match qfSeparator "|" nextgroup=qfLineNr contained +" syn match qfLineNr "[^|]*" contained contains=qfError +" syn match qfError "error" contained +hi qfFileName guifg=LightSkyBlue4 guibg=NONE gui=italic +hi qfLineNr guifg=coral guibg=NONE gui=bold +hi qfError guifg=red guibg=NONE gui=bold +" 2}}} + +" Python {{{2 +" ----------------------------------------------------------------------------- +hi pythonDecorator guifg=orange3 guibg=NONE gui=bold +hi link pythonDecoratorFunction pythonDecorator +" 2}}} + +" Diff {{{2 +" ----------------------------------------------------------------------------- +hi diffOldFile guifg=#006666 guibg=NONE gui=NONE +hi diffNewFile guifg=#0088FF guibg=NONE gui=bold +hi diffFile guifg=#0000FF guibg=NONE gui=NONE +hi link diffOnly Constant +hi link diffIdentical Constant +hi link diffDiffer Constant +hi link diffBDiffer Constant +hi link diffIsA Constant +hi link diffNoEOL Constant +hi link diffCommon Constant +hi diffRemoved guifg=#BB0000 guibg=NONE gui=NONE +hi diffChanged guifg=DarkSeaGreen guibg=NONE gui=NONE +hi diffAdded guifg=#00AA00 guibg=NONE gui=NONE +hi diffLine guifg=thistle4 guibg=NONE gui=italic +hi link diffSubname diffLine +hi link diffComment Comment +" 2}}} + +" PHP (contributed by Ryan Kulla) {{{2 +" ----------------------------------------------------------------------------- +" Ryan Kulla's addition for PHP syntax highlighting (for regular/terminal vim) +hi phpConditional ctermfg=21 cterm=NONE guifg=black +hi phpIdentifier ctermfg=0 cterm=NONE guifg=black +hi phpOperator ctermfg=black cterm=NONE guifg=black +hi phpRegion ctermfg=132 cterm=NONE guifg=VioletRed4 +hi phpComparison ctermfg=black cterm=NONE guifg=black +hi phpType ctermfg=darkgreen cterm=NONE guifg=darkgreen +hi phpParent ctermfg=black cterm=NONE guifg=black +hi phpMethodsVar ctermfg=132 cterm=NONE guifg=VioletRed4 +hi phpStatement ctermfg=21 cterm=NONE guifg=blue +hi phpStorageClass ctermfg=21 cterm=NONE guifg=blue +hi phpStringSingle ctermfg=30 cterm=NONE guifg=Aquamarine4 +hi phpStringDouble ctermfg=30 cterm=NONE guifg=Aquamarine4 +hi phpFunctions ctermfg=21 cterm=NONE guifg=blue +hi phpSpecialFunction ctermfg=21 cterm=NONE guifg=blue +hi phpRepeat ctermfg=21 cterm=NONE guifg=blue +hi phpNumber ctermfg=214 cterm=bold guifg=brown +hi phpTodo ctermfg=red cterm=bold guifg=red gui=bold +hi phpDefine ctermfg=21 cterm=NONE guifg=blue +hi phpConstant ctermfg=21 cterm=NONE guifg=black +hi phpCoreConstant ctermfg=21 cterm=NONE guifg=black +hi phpMemberSelector ctermfg=black cterm=NONE guifg=black +hi phpLabel ctermfg=21 cterm=NONE guifg=blue +hi phpStructure ctermfg=black cterm=NONE guifg=black +hi phpRelation ctermfg=black cterm=NONE guifg=black +hi phpEnvVar ctermfg=black cterm=NONE guifg=black +hi phpIntVar ctermfg=0 cterm=bold guifg=black gui=bold +hi phpBoolean ctermfg=58 cterm=NONE guifg=brown +" 2}}} + +" 1}}} + diff --git a/sources_non_forked/mru.vim/README b/sources_non_forked/mru.vim/README new file mode 100644 index 00000000..04c3a748 --- /dev/null +++ b/sources_non_forked/mru.vim/README @@ -0,0 +1,192 @@ +This is a mirror of http://www.vim.org/scripts/script.php?script_id=521 + +Overview + +The Most Recently Used (MRU) plugin provides an easy access to a list of +recently opened/edited files in Vim. This plugin automatically stores the +file names as you open/edit them in Vim. + +This plugin will work on all the platforms where Vim is supported. This +plugin will work in both console and GUI Vim. This version of the MRU +plugin needs Vim 7.0 and above. If you are using an earlier version of +Vim, then you should use an older version of the MRU plugin. + +The recently used filenames are stored in a file specified by the Vim +MRU_File variable. + +The Github repository for the MRU plugin is available at: + + http://github.com/yegappan/mru + +Usage + +To list and edit files from the MRU list, you can use the ":MRU" command. +The ":MRU" command displays the MRU file list in a temporary Vim window. If +the MRU window is already opened, then the MRU list displayed in the window +is refreshed. + +If you are using GUI Vim, then the names of the recently edited files are +added to the "File->Recent Files" menu. You can select the name of a file +from this sub-menu to edit the file. + +You can use the normal Vim commands to move around in the MRU window. You +cannot make changes in the MRU window. + +You can select a file name to edit by pressing the key or by double +clicking the left mouse button on a file name. The selected file will be +opened. If the file is already opened in a window, the cursor will be moved +to that window. Otherwise, the file is opened in the previous window. If the +previous window has a modified buffer or is the preview window or is used by +some other plugin, then the file is opened in a new window. + +You can press the 'o' key to open the file name under the cursor in the +MRU window in a new window. You can also press instead of 'o' +to open the file in a new window. + +To open a file from the MRU window in read-only mode (view), press the 'v' +key. + +To open a file from the MRU window in a new tab, press the 't' key. If the +file is already opened in a window in the current or in another tab, then +the cursor is moved to that tab. Otherwise, a new tab is opened. + +You can open multiple files from the MRU window by specifying a count before +pressing '' or 'v' or 'o' or 't'. You can also visually (using +linewise visual mode) select multiple filenames and invoke the commands to +open the files. Each selected file will be opened in a separate window or +tab. + +You can press the 'u' key in the MRU window to update the file list. This is +useful if you keep the MRU window open always. + +You can close the MRU window by pressing the 'q' key or the key or +using one of the Vim window commands. + +To display only files matching a pattern from the MRU list in the MRU +window, you can specify a pattern to the ":MRU" command. For example, to +display only file names matching "vim" in them, you can use the following +command ":MRU vim". When you specify a partial file name and only one +matching filename is found, then the ":MRU" command will edit that file. + +The ":MRU" command supports command-line completion of file names from +the MRU list. You can enter a partial file name and then press +or to complete or list all the matching file names. Note that +after typing the ":MRU" command, you have to enter a space before completing +the file names with . + +When a file supplied to the ":MRU" command is not present in the MRU list, +but it is a readable file, then the file will be opened (even though it is +not present in the MRU list). This is useful if you want to open a file +present in the same directory as a file in the MRU list. You can use the +command-line completion of the ":MRU" command to complete the full path of a +file and then modify the path to open another file present in the same path. + +Whenever the MRU list changes, the MRU file is updated with the latest MRU +list. When you have multiple instances of Vim running at the same time, the +latest MRU list will show up in all the instances of Vim. + +The MRUFilename syntax group is used to highlight the file names in the MRU +window. By default, this syntax group is linked to the Identifier highlight +group. You can change the highlight group by adding the following line in +your .vimrc: + + highlight link MRUFileName LineNr + +The MRU buffer uses the 'mru file type. You can use this file type to add +custom auto commands, syntax highlighting, etc. + +Configuration + +By changing the following variables you can configure the behavior of this +plugin. Set the following variables in your .vimrc file using the 'let' +command. + +The list of recently edited file names is stored in the file specified by the +MRU_File variable. The default setting for this variable is +$HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files +for MS-Windows systems. You can change this variable to point to a file by +adding the following line to the .vimrc file: + + let MRU_File = 'd:\myhome\_vim_mru_files' + +By default, the plugin will remember the names of the last 100 used files. +As you edit more files, old file names will be removed from the MRU list. +You can set the 'MRU_Max_Entries' variable to remember more file names. For +example, to remember 1000 most recently used file names, you can use + + let MRU_Max_Entries = 1000 + +By default, all the edited file names will be added to the MRU list. If you +want to exclude file names matching a list of patterns, you can set the +MRU_Exclude_Files variable to a list of Vim regular expressions. By default, +this variable is set to an empty string. For example, to not include files +in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the +MRU_Exclude_Files variable to + + let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix + let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows + +The specified pattern should be a Vim regular expression pattern. + +If you want to add only file names matching a set of patterns to the MRU +list, then you can set the MRU_Include_Files variable. This variable should +be set to a Vim regular expression pattern. For example, to add only .c and +.h files to the MRU list, you can set this variable as below: + + let MRU_Include_Files = '\.c$\|\.h$' + +By default, MRU_Include_Files is set to an empty string and all the edited +filenames are added to the MRU list. + +The default height of the MRU window is 8. You can set the MRU_Window_Height +variable to change the window height. + + let MRU_Window_Height = 15 + +By default, when the :MRU command is invoked, the MRU list will be displayed +in a new window. Instead, if you want the MRU plugin to reuse the current +window, then you can set the 'MRU_Use_Current_Window' variable to one. + + let MRU_Use_Current_Window = 1 + +The MRU plugin will reuse the current window. When a file name is selected, +the file is also opened in the current window. + +When you select a file from the MRU window, the MRU window will be +automatically closed and the selected file will be opened in the previous +window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU +window open. + + let MRU_Auto_Close = 0 + +If you don't use the "File->Recent Files" menu and want to disable it, +then you can set the 'MRU_Add_Menu' variable to zero. By default, the +menu is enabled. + + let MRU_Add_Menu = 0 + +If too many file names are present in the MRU list, then updating the MRU +menu to list all the file names makes Vim slow. To avoid this, the +MRU_Max_Menu_Entries variable controls the number of file names to show in +the MRU menu. By default, this is set to 10. You can change this to show +more entries in the menu. + + let MRU_Max_Menu_Entries = 20 + +If many file names are present in the MRU list, then the MRU menu is split +into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names. +The default setting for this is 10. You can change this to increase the +number of file names displayed in a single sub-menu: + + let MRU_Max_Submenu_Entries = 15 + +In the MRU window, the filenames are displayed in two parts. The first part +contains the file name without the path and the second part contains the +full path to the file in parenthesis. This format is controlled by the +MRU_Filename_Format variable. If you prefer to change this to some other +format, then you can modify the MRU_Filename_Format variable. For example, +to display the full path without splitting it, you can set this variable +as shown below: + + let MRU_Filename_Format={'formatter':'v:val', 'parser':'.*'} + diff --git a/sources_non_forked/mru.vim/plugin/mru.vim b/sources_non_forked/mru.vim/plugin/mru.vim new file mode 100644 index 00000000..5cf7015d --- /dev/null +++ b/sources_non_forked/mru.vim/plugin/mru.vim @@ -0,0 +1,1039 @@ +" File: mru.vim +" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) +" Version: 3.9 +" Last Modified: Feb 3, 2015 +" Copyright: Copyright (C) 2003-2015 Yegappan Lakshmanan +" License: Permission is hereby granted to use and distribute this code, +" with or without modifications, provided that this copyright +" notice is copied with it. Like anything else that's free, +" mru.vim is provided *as is* and comes with no warranty of any +" kind, either expressed or implied. In no event will the copyright +" holder be liable for any damages resulting from the use of this +" software. +" +" Overview +" -------- +" The Most Recently Used (MRU) plugin provides an easy access to a list of +" recently opened/edited files in Vim. This plugin automatically stores the +" file names as you open/edit them in Vim. +" +" This plugin will work on all the platforms where Vim is supported. This +" plugin will work in both console and GUI Vim. This version of the MRU +" plugin needs Vim 7.0 and above. If you are using an earlier version of +" Vim, then you should use an older version of the MRU plugin. +" +" The recently used filenames are stored in a file specified by the Vim +" MRU_File variable. +" +" The Github repository for the MRU plugin is available at: +" +" http://github.com/yegappan/mru +" +" Installation +" ------------ +" 1. Copy the mru.vim file to one of the following directories: +" $HOME/.vim/plugin - Unix like systems +" $HOME/vimfiles/plugin - MS-Windows +" $VIM:vimfiles:plugin - Macintosh +" $VIM/vimfiles/plugin - All +" 2. Restart Vim. +" 3. You can use the ":MRU" command to list and edit the recently used files. +" In GUI Vim, you can use the 'File->Recent Files' menu to access the +" recently used files. +" +" To uninstall this plugin, remove this file (mru.vim) from the +" $HOME/.vim/plugin or $HOME/vimfiles/plugin or the $VIM/vimfile/plugin +" directory. +" +" Usage +" ----- +" To list and edit files from the MRU list, you can use the ":MRU" command. +" The ":MRU" command displays the MRU file list in a temporary Vim window. If +" the MRU window is already opened, then the MRU list displayed in the window +" is refreshed. +" +" If you are using GUI Vim, then the names of the recently edited files are +" added to the "File->Recent Files" menu. You can select the name of a file +" from this sub-menu to edit the file. +" +" You can use the normal Vim commands to move around in the MRU window. You +" cannot make changes in the MRU window. +" +" You can select a file name to edit by pressing the key or by double +" clicking the left mouse button on a file name. The selected file will be +" opened. If the file is already opened in a window, the cursor will be moved +" to that window. Otherwise, the file is opened in the previous window. If the +" previous window has a modified buffer or is the preview window or is used by +" some other plugin, then the file is opened in a new window. +" +" You can press the 'o' key to open the file name under the cursor in the +" MRU window in a new window. You can also press instead of 'o' +" to open the file in a new window. +" +" To open a file from the MRU window in read-only mode (view), press the 'v' +" key. +" +" To open a file from the MRU window in a new tab, press the 't' key. If the +" file is already opened in a window in the current or in another tab, then +" the cursor is moved to that tab. Otherwise, a new tab is opened. +" +" You can open multiple files from the MRU window by specifying a count before +" pressing '' or 'v' or 'o' or 't'. You can also visually (using +" linewise visual mode) select multiple filenames and invoke the commands to +" open the files. Each selected file will be opened in a separate window or +" tab. +" +" You can press the 'u' key in the MRU window to update the file list. This is +" useful if you keep the MRU window open always. +" +" You can close the MRU window by pressing the 'q' key or the key or +" using one of the Vim window commands. +" +" To display only files matching a pattern from the MRU list in the MRU +" window, you can specify a pattern to the ":MRU" command. For example, to +" display only file names matching "vim" in them, you can use the following +" command ":MRU vim". When you specify a partial file name and only one +" matching filename is found, then the ":MRU" command will edit that file. +" +" The ":MRU" command supports command-line completion of file names from +" the MRU list. You can enter a partial file name and then press +" or to complete or list all the matching file names. Note that +" after typing the ":MRU" command, you have to enter a space before completing +" the file names with . +" +" When a file supplied to the ":MRU" command is not present in the MRU list, +" but it is a readable file, then the file will be opened (even though it is +" not present in the MRU list). This is useful if you want to open a file +" present in the same directory as a file in the MRU list. You can use the +" command-line completion of the ":MRU" command to complete the full path of a +" file and then modify the path to open another file present in the same path. +" +" Whenever the MRU list changes, the MRU file is updated with the latest MRU +" list. When you have multiple instances of Vim running at the same time, the +" latest MRU list will show up in all the instances of Vim. +" +" The MRUFilename syntax group is used to highlight the file names in the MRU +" window. By default, this syntax group is linked to the Identifier highlight +" group. You can change the highlight group by adding the following line in +" your .vimrc: +" +" highlight link MRUFileName LineNr +" +" The MRU buffer uses the 'mru file type. You can use this file type to add +" custom auto commands, syntax highlighting, etc. +" +" Configuration +" ------------- +" By changing the following variables you can configure the behavior of this +" plugin. Set the following variables in your .vimrc file using the 'let' +" command. +" +" The list of recently edited file names is stored in the file specified by the +" MRU_File variable. The default setting for this variable is +" $HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files +" for MS-Windows systems. You can change this variable to point to a file by +" adding the following line to the .vimrc file: +" +" let MRU_File = 'd:\myhome\_vim_mru_files' +" +" By default, the plugin will remember the names of the last 100 used files. +" As you edit more files, old file names will be removed from the MRU list. +" You can set the 'MRU_Max_Entries' variable to remember more file names. For +" example, to remember 1000 most recently used file names, you can use +" +" let MRU_Max_Entries = 1000 +" +" By default, all the edited file names will be added to the MRU list. If you +" want to exclude file names matching a list of patterns, you can set the +" MRU_Exclude_Files variable to a list of Vim regular expressions. By default, +" this variable is set to an empty string. For example, to not include files +" in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the +" MRU_Exclude_Files variable to +" +" let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix +" let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows +" +" The specified pattern should be a Vim regular expression pattern. +" +" If you want to add only file names matching a set of patterns to the MRU +" list, then you can set the MRU_Include_Files variable. This variable should +" be set to a Vim regular expression pattern. For example, to add only .c and +" .h files to the MRU list, you can set this variable as below: +" +" let MRU_Include_Files = '\.c$\|\.h$' +" +" By default, MRU_Include_Files is set to an empty string and all the edited +" filenames are added to the MRU list. +" +" The default height of the MRU window is 8. You can set the MRU_Window_Height +" variable to change the window height. +" +" let MRU_Window_Height = 15 +" +" By default, when the :MRU command is invoked, the MRU list will be displayed +" in a new window. Instead, if you want the MRU plugin to reuse the current +" window, then you can set the 'MRU_Use_Current_Window' variable to one. +" +" let MRU_Use_Current_Window = 1 +" +" The MRU plugin will reuse the current window. When a file name is selected, +" the file is also opened in the current window. +" +" When you select a file from the MRU window, the MRU window will be +" automatically closed and the selected file will be opened in the previous +" window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU +" window open. +" +" let MRU_Auto_Close = 0 +" +" If you don't use the "File->Recent Files" menu and want to disable it, +" then you can set the 'MRU_Add_Menu' variable to zero. By default, the +" menu is enabled. +" +" let MRU_Add_Menu = 0 +" +" If too many file names are present in the MRU list, then updating the MRU +" menu to list all the file names makes Vim slow. To avoid this, the +" MRU_Max_Menu_Entries variable controls the number of file names to show in +" the MRU menu. By default, this is set to 10. You can change this to show +" more entries in the menu. +" +" let MRU_Max_Menu_Entries = 20 +" +" If many file names are present in the MRU list, then the MRU menu is split +" into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names. +" The default setting for this is 10. You can change this to increase the +" number of file names displayed in a single sub-menu: +" +" let MRU_Max_Submenu_Entries = 15 +" +" In the MRU window, the filenames are displayed in two parts. The first part +" contains the file name without the path and the second part contains the +" full path to the file in parenthesis. This format is controlled by the +" MRU_Filename_Format variable. If you prefer to change this to some other +" format, then you can modify the MRU_Filename_Format variable. For example, +" to display the full path without splitting it, you can set this variable +" as shown below: +" +" let MRU_Filename_Format = +" \ {'formatter':'v:val', 'parser':'.*', 'syntax': '[^/\\]\+$'} +" +" ****************** Do not modify after this line ************************ +if exists('loaded_mru') + finish +endif +let loaded_mru=1 + +if v:version < 700 + finish +endif + +" Line continuation used here +let s:cpo_save = &cpo +set cpo&vim + +" MRU configuration variables {{{1 +" Maximum number of entries allowed in the MRU list +if !exists('MRU_Max_Entries') + let MRU_Max_Entries = 100 +endif + +" Files to exclude from the MRU list +if !exists('MRU_Exclude_Files') + let MRU_Exclude_Files = '' +endif + +" Files to include in the MRU list +if !exists('MRU_Include_Files') + let MRU_Include_Files = '' +endif + +" Height of the MRU window +" Default height is 8 +if !exists('MRU_Window_Height') + let MRU_Window_Height = 8 +endif + +if !exists('MRU_Use_Current_Window') + let MRU_Use_Current_Window = 0 +endif + +if !exists('MRU_Auto_Close') + let MRU_Auto_Close = 1 +endif + +if !exists('MRU_File') + if has('unix') || has('macunix') + let MRU_File = $HOME . '/.vim_mru_files' + else + let MRU_File = $VIM . '/_vim_mru_files' + if has('win32') + " MS-Windows + if $USERPROFILE != '' + let MRU_File = $USERPROFILE . '\_vim_mru_files' + endif + endif + endif +endif + +" Option for enabling or disabling the MRU menu +if !exists('MRU_Add_Menu') + let MRU_Add_Menu = 1 +endif + +" Maximum number of file names to show in the MRU menu. If too many files are +" listed in the menu, then Vim becomes slow when updating the menu. So set +" this to a low value. +if !exists('MRU_Max_Menu_Entries') + let MRU_Max_Menu_Entries = 10 +endif + +" Maximum number of file names to show in a MRU sub-menu. If the MRU list +" contains more file names than this setting, then the MRU menu is split into +" one or more sub-menus. +if !exists('MRU_Max_Submenu_Entries') + let MRU_Max_Submenu_Entries = 10 +endif + +" When only a single matching filename is found in the MRU list, the following +" option controls whether the file name is displayed in the MRU window or the +" file is directly opened. When this variable is set to 0 and a single +" matching file name is found, then the file is directly opened. +if !exists('MRU_Window_Open_Always') + let MRU_Window_Open_Always = 0 +endif + +" When opening a file from the MRU list, the file is opened in the current +" tab. If the selected file has to be opened in a tab always, then set the +" following variable to 1. If the file is already opened in a tab, then the +" cursor will be moved to that tab. +if !exists('MRU_Open_File_Use_Tabs') + let MRU_Open_File_Use_Tabs = 0 +endif + +" Format of the file names displayed in the MRU window. +" The default is to display the filename followed by the complete path to the +" file in parenthesis. This variable controls the expressions used to format +" and parse the path. This can be changed to display the filenames in a +" different format. The 'formatter' specifies how to split/format the filename +" and 'parser' specifies how to read the filename back; 'syntax' matches the +" part to be highlighted. +if !exists('MRU_Filename_Format') + let MRU_Filename_Format = { + \ 'formatter': 'fnamemodify(v:val, ":t") . " (" . v:val . ")"', + \ 'parser': '(\zs.*\ze)', + \ 'syntax': '^.\{-}\ze(' + \} +endif + +" Control to temporarily lock the MRU list. Used to prevent files from +" getting added to the MRU list when the ':vimgrep' command is executed. +let s:mru_list_locked = 0 + +" MRU_LoadList {{{1 +" Loads the latest list of file names from the MRU file +function! s:MRU_LoadList() + " If the MRU file is present, then load the list of filenames. Otherwise + " start with an empty list. + if filereadable(g:MRU_File) + let s:MRU_files = readfile(g:MRU_File) + if s:MRU_files[0] =~# '^\s*" Most recently edited files in Vim' + " Generated by the previous version of the MRU plugin. + " Discard the list. + let s:MRU_files = [] + elseif s:MRU_files[0] =~# '^#' + " Remove the comment line + call remove(s:MRU_files, 0) + else + " Unsupported format + let s:MRU_files = [] + endif + else + let s:MRU_files = [] + endif + + " Refresh the MRU menu with the latest list of filenames + call s:MRU_Refresh_Menu() +endfunction + +" MRU_SaveList {{{1 +" Saves the MRU file names to the MRU file +function! s:MRU_SaveList() + let l = [] + call add(l, '# Most recently edited files in Vim (version 3.0)') + call extend(l, s:MRU_files) + call writefile(l, g:MRU_File) +endfunction + +" MRU_AddFile {{{1 +" Adds a file to the MRU file list +" acmd_bufnr - Buffer number of the file to add +function! s:MRU_AddFile(acmd_bufnr) + if s:mru_list_locked + " MRU list is currently locked + return + endif + + " Get the full path to the filename + let fname = fnamemodify(bufname(a:acmd_bufnr + 0), ':p') + if fname == '' + return + endif + + " Skip temporary buffers with buftype set. The buftype is set for buffers + " used by plugins. + if &buftype != '' + return + endif + + if g:MRU_Include_Files != '' + " If MRU_Include_Files is set, include only files matching the + " specified pattern + if fname !~# g:MRU_Include_Files + return + endif + endif + + if g:MRU_Exclude_Files != '' + " Do not add files matching the pattern specified in the + " MRU_Exclude_Files to the MRU list + if fname =~# g:MRU_Exclude_Files + return + endif + endif + + " If the filename is not already present in the MRU list and is not + " readable then ignore it + let idx = index(s:MRU_files, fname) + if idx == -1 + if !filereadable(fname) + " File is not readable and is not in the MRU list + return + endif + endif + + " Load the latest MRU file list + call s:MRU_LoadList() + + " Remove the new file name from the existing MRU list (if already present) + call filter(s:MRU_files, 'v:val !=# fname') + + " Add the new file list to the beginning of the updated old file list + call insert(s:MRU_files, fname, 0) + + " Trim the list + if len(s:MRU_files) > g:MRU_Max_Entries + call remove(s:MRU_files, g:MRU_Max_Entries, -1) + endif + + " Save the updated MRU list + call s:MRU_SaveList() + + " Refresh the MRU menu + call s:MRU_Refresh_Menu() + + " If the MRU window is open, update the displayed MRU list + let bname = '__MRU_Files__' + let winnum = bufwinnr(bname) + if winnum != -1 + let cur_winnr = winnr() + call s:MRU_Open_Window() + if winnr() != cur_winnr + exe cur_winnr . 'wincmd w' + endif + endif +endfunction + +" MRU_escape_filename {{{1 +" Escape special characters in a filename. Special characters in file names +" that should be escaped (for security reasons) +let s:esc_filename_chars = ' *?[{`$%#"|!<>();&' . "'\t\n" +function! s:MRU_escape_filename(fname) + if exists("*fnameescape") + return fnameescape(a:fname) + else + return escape(a:fname, s:esc_filename_chars) + endif +endfunction + +" MRU_Edit_File {{{1 +" Edit the specified file +" filename - Name of the file to edit +" sanitized - Specifies whether the filename is already escaped for special +" characters or not. +function! s:MRU_Edit_File(filename, sanitized) + if !a:sanitized + let esc_fname = s:MRU_escape_filename(a:filename) + else + let esc_fname = a:filename + endif + + " If the user wants to always open the file in a tab, then open the file + " in a tab. If it is already opened in a tab, then the cursor will be + " moved to that tab. + if g:MRU_Open_File_Use_Tabs + call s:MRU_Open_File_In_Tab(a:filename, esc_fname) + return + endif + + " If the file is already open in one of the windows, jump to it + let winnum = bufwinnr('^' . a:filename . '$') + if winnum != -1 + if winnum != winnr() + exe winnum . 'wincmd w' + endif + else + if !&hidden && (&modified || &buftype != '' || &previewwindow) + " Current buffer has unsaved changes or is a special buffer or is + " the preview window. The 'hidden' option is also not set. + " So open the file in a new window. + exe 'split ' . esc_fname + else + " The current file can be replaced with the selected file. + exe 'edit ' . esc_fname + endif + endif +endfunction + +" MRU_Open_File_In_Tab +" Open a file in a tab. If the file is already opened in a tab, jump to the +" tab. Otherwise, create a new tab and open the file. +" fname : Name of the file to open +" esc_fname : File name with special characters escaped +function! s:MRU_Open_File_In_Tab(fname, esc_fname) + " If the selected file is already open in the current tab or in + " another tab, jump to it. Otherwise open it in a new tab + if bufwinnr('^' . a:fname . '$') == -1 + let tabnum = -1 + let i = 1 + let bnum = bufnr('^' . a:fname . '$') + while i <= tabpagenr('$') + if index(tabpagebuflist(i), bnum) != -1 + let tabnum = i + break + endif + let i += 1 + endwhile + + if tabnum != -1 + " Goto the tab containing the file + exe 'tabnext ' . i + else + " Open a new tab as the last tab page + exe '$tabnew ' . a:esc_fname + endif + endif + + " Jump to the window containing the file + let winnum = bufwinnr('^' . a:fname . '$') + if winnum != winnr() + exe winnum . 'wincmd w' + endif +endfunction + +" MRU_Window_Edit_File {{{1 +" fname : Name of the file to edit. May specify single or multiple +" files. +" edit_type : Specifies how to edit the file. Can be one of 'edit' or 'view'. +" 'view' - Open the file as a read-only file +" 'edit' - Edit the file as a regular file +" multi : Specifies whether a single file or multiple files need to be +" opened. +" open_type : Specifies where to open the file. +" useopen - If the file is already present in a window, then +" jump to that window. Otherwise, open the file in +" the previous window. +" newwin_horiz - Open the file in a new horizontal window. +" newwin_vert - Open the file in a new vertical window. +" newtab - Open the file in a new tab. If the file is already +" opened in a tab, then jump to that tab. +" preview - Open the file in the preview window +function! s:MRU_Window_Edit_File(fname, multi, edit_type, open_type) + let esc_fname = s:MRU_escape_filename(a:fname) + + if a:open_type ==# 'newwin_horiz' + " Edit the file in a new horizontally split window above the previous + " window + wincmd p + exe 'belowright new ' . esc_fname + elseif a:open_type ==# 'newwin_vert' + " Edit the file in a new vertically split window above the previous + " window + wincmd p + exe 'belowright vnew ' . esc_fname + elseif a:open_type ==# 'newtab' || g:MRU_Open_File_Use_Tabs + call s:MRU_Open_File_In_Tab(a:fname, esc_fname) + elseif a:open_type ==# 'preview' + " Edit the file in the preview window + exe 'topleft pedit ' . esc_fname + else + " If the selected file is already open in one of the windows, + " jump to it + let winnum = bufwinnr('^' . a:fname . '$') + if winnum != -1 + exe winnum . 'wincmd w' + else + if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 + " Jump to the window from which the MRU window was opened + if exists('s:MRU_last_buffer') + let last_winnr = bufwinnr(s:MRU_last_buffer) + if last_winnr != -1 && last_winnr != winnr() + exe last_winnr . 'wincmd w' + endif + endif + else + if g:MRU_Use_Current_Window == 0 + " Goto the previous window + " If MRU_Use_Current_Window is set to one, then the + " current window is used to open the file + wincmd p + endif + endif + + let split_window = 0 + + if (!&hidden && (&modified || &previewwindow)) || a:multi + " Current buffer has unsaved changes or is the preview window + " or the user is opening multiple files + " So open the file in a new window + let split_window = 1 + endif + + if &buftype != '' + " Current buffer is a special buffer (maybe used by a plugin) + if g:MRU_Use_Current_Window == 0 || + \ bufnr('%') != bufnr('__MRU_Files__') + let split_window = 1 + endif + endif + + " Edit the file + if split_window + " Current buffer has unsaved changes or is a special buffer or + " is the preview window. So open the file in a new window + if a:edit_type ==# 'edit' + exe 'split ' . esc_fname + else + exe 'sview ' . esc_fname + endif + else + if a:edit_type ==# 'edit' + exe 'edit ' . esc_fname + else + exe 'view ' . esc_fname + endif + endif + endif + endif +endfunction + +" MRU_Select_File_Cmd {{{1 +" Open a file selected from the MRU window +" +" 'opt' has two values separated by comma. The first value specifies how to +" edit the file and can be either 'edit' or 'view'. The second value +" specifies where to open the file. It can take one of the following values: +" 'useopen' to open file in the previous window +" 'newwin_horiz' to open the file in a new horizontal split window +" 'newwin_vert' to open the file in a new vertical split window. +" 'newtab' to open the file in a new tab. +" If multiple file names are selected using visual mode, then open multiple +" files (either in split windows or tabs) +function! s:MRU_Select_File_Cmd(opt) range + let [edit_type, open_type] = split(a:opt, ',') + + let fnames = getline(a:firstline, a:lastline) + + if g:MRU_Auto_Close == 1 && g:MRU_Use_Current_Window == 0 + " Automatically close the window if the file window is + " not used to display the MRU list. + silent! close + endif + + let multi = 0 + + for f in fnames + if f == '' + continue + endif + + " The text in the MRU window contains the filename in parenthesis + let file = matchstr(f, g:MRU_Filename_Format.parser) + + call s:MRU_Window_Edit_File(file, multi, edit_type, open_type) + + if a:firstline != a:lastline + " Opening multiple files + let multi = 1 + endif + endfor +endfunction + +" MRU_Warn_Msg {{{1 +" Display a warning message +function! s:MRU_Warn_Msg(msg) + echohl WarningMsg + echo a:msg + echohl None +endfunction + +" MRU_Open_Window {{{1 +" Display the Most Recently Used file list in a temporary window. +" If the optional argument is supplied, then it specifies the pattern of files +" to selectively display in the MRU window. +function! s:MRU_Open_Window(...) + + " Load the latest MRU file list + call s:MRU_LoadList() + + " Check for empty MRU list + if empty(s:MRU_files) + call s:MRU_Warn_Msg('MRU file list is empty') + return + endif + + " Save the current buffer number. This is used later to open a file when a + " entry is selected from the MRU window. The window number is not saved, + " as the window number will change when new windows are opened. + let s:MRU_last_buffer = bufnr('%') + + let bname = '__MRU_Files__' + + " If the window is already open, jump to it + let winnum = bufwinnr(bname) + if winnum != -1 + if winnr() != winnum + " If not already in the window, jump to it + exe winnum . 'wincmd w' + endif + + setlocal modifiable + + " Delete the contents of the buffer to the black-hole register + silent! %delete _ + else + if g:MRU_Use_Current_Window + " Reuse the current window + " + " If the __MRU_Files__ buffer exists, then reuse it. Otherwise open + " a new buffer + let bufnum = bufnr(bname) + if bufnum == -1 + let cmd = 'edit ' . bname + else + let cmd = 'buffer ' . bufnum + endif + + exe cmd + + if bufnr('%') != bufnr(bname) + " Failed to edit the MRU buffer + return + endif + else + " Open a new window at the bottom + + " If the __MRU_Files__ buffer exists, then reuse it. Otherwise open + " a new buffer + let bufnum = bufnr(bname) + if bufnum == -1 + let wcmd = bname + else + let wcmd = '+buffer' . bufnum + endif + + exe 'silent! botright ' . g:MRU_Window_Height . 'split ' . wcmd + endif + endif + + setlocal modifiable + + " Mark the buffer as scratch + setlocal buftype=nofile + setlocal bufhidden=delete + setlocal noswapfile + setlocal nowrap + setlocal nobuflisted + " Set the 'filetype' to 'mru'. This allows the user to apply custom + " syntax highlighting or other changes to the MRU bufer. + setlocal filetype=mru + " Use fixed height for the MRU window + setlocal winfixheight + + " Setup the cpoptions properly for the maps to work + let old_cpoptions = &cpoptions + set cpoptions&vim + + " Create mappings to select and edit a file from the MRU list + nnoremap + \ :call MRU_Select_File_Cmd('edit,useopen') + vnoremap + \ :call MRU_Select_File_Cmd('edit,useopen') + nnoremap o + \ :call MRU_Select_File_Cmd('edit,newwin_horiz') + vnoremap o + \ :call MRU_Select_File_Cmd('edit,newwin_horiz') + nnoremap + \ :call MRU_Select_File_Cmd('edit,newwin_horiz') + vnoremap + \ :call MRU_Select_File_Cmd('edit,newwin_horiz') + nnoremap O + \ :call MRU_Select_File_Cmd('edit,newwin_vert') + vnoremap O + \ :call MRU_Select_File_Cmd('edit,newwin_vert') + nnoremap t + \ :call MRU_Select_File_Cmd('edit,newtab') + vnoremap t + \ :call MRU_Select_File_Cmd('edit,newtab') + nnoremap v + \ :call MRU_Select_File_Cmd('view,useopen') + nnoremap p + \ :call MRU_Select_File_Cmd('view,preview') + vnoremap p + \ :if line("'<") == line("'>") + \ call MRU_Select_File_Cmd('open,preview') + \ else + \ echoerr "Only a single file can be previewed" + \ endif + nnoremap u :MRU + nnoremap <2-LeftMouse> + \ :call MRU_Select_File_Cmd('edit,useopen') + nnoremap q :close + + " Restore the previous cpoptions settings + let &cpoptions = old_cpoptions + + " Display the MRU list + if a:0 == 0 + " No search pattern specified. Display the complete list + let m = copy(s:MRU_files) + else + " Display only the entries matching the specified pattern + " First try using it as a literal pattern + let m = filter(copy(s:MRU_files), 'stridx(v:val, a:1) != -1') + if len(m) == 0 + " No match. Try using it as a regular expression + let m = filter(copy(s:MRU_files), 'v:val =~# a:1') + endif + endif + + " Get the tail part of the file name (without the directory) and display + " it along with the full path in parenthesis. + let output = map(m, g:MRU_Filename_Format.formatter) + silent! 0put =output + + " Delete the empty line at the end of the buffer + silent! $delete _ + + " Move the cursor to the beginning of the file + normal! gg + + " Add syntax highlighting for the file names + if has_key(g:MRU_Filename_Format, 'syntax') + exe "syntax match MRUFileName '" . g:MRU_Filename_Format.syntax . "'" + highlight default link MRUFileName Identifier + endif + + setlocal nomodifiable +endfunction + +" MRU_Complete {{{1 +" Command-line completion function used by :MRU command +function! s:MRU_Complete(ArgLead, CmdLine, CursorPos) + if a:ArgLead == '' + " Return the complete list of MRU files + return s:MRU_files + else + " Return only the files matching the specified pattern + return filter(copy(s:MRU_files), 'v:val =~? a:ArgLead') + endif +endfunction + +" MRU_Cmd {{{1 +" Function to handle the MRU command +" pat - File name pattern passed to the MRU command +function! s:MRU_Cmd(pat) + if a:pat == '' + " No arguments specified. Open the MRU window + call s:MRU_Open_Window() + return + endif + + " Load the latest MRU file + call s:MRU_LoadList() + + " Empty MRU list + if empty(s:MRU_files) + call s:MRU_Warn_Msg('MRU file list is empty') + return + endif + + " First use the specified string as a literal string and search for + " filenames containing the string. If only one filename is found, + " then edit it (unless the user wants to open the MRU window always) + let m = filter(copy(s:MRU_files), 'stridx(v:val, a:pat) != -1') + if len(m) > 0 + if len(m) == 1 && !g:MRU_Window_Open_Always + call s:MRU_Edit_File(m[0], 0) + return + endif + + " More than one file matches. Try find an accurate match + let new_m = filter(m, 'v:val ==# a:pat') + if len(new_m) == 1 && !g:MRU_Window_Open_Always + call s:MRU_Edit_File(new_m[0], 0) + return + endif + + " Couldn't find an exact match, open the MRU window with all the + " files matching the pattern. + call s:MRU_Open_Window(a:pat) + return + endif + + " Use the specified string as a regular expression pattern and search + " for filenames matching the pattern + let m = filter(copy(s:MRU_files), 'v:val =~? a:pat') + + if len(m) == 0 + " If an existing file (not present in the MRU list) is specified, + " then open the file. + if filereadable(a:pat) + call s:MRU_Edit_File(a:pat, 0) + return + endif + + " No filenames matching the specified pattern are found + call s:MRU_Warn_Msg("MRU file list doesn't contain " . + \ "files matching " . a:pat) + return + endif + + if len(m) == 1 && !g:MRU_Window_Open_Always + call s:MRU_Edit_File(m[0], 0) + return + endif + + call s:MRU_Open_Window(a:pat) +endfunction + +" MRU_add_files_to_menu {{{1 +" Adds a list of files to the "Recent Files" sub menu under the "File" menu. +" prefix - Prefix to use for each of the menu entries +" file_list - List of file names to add to the menu +function! s:MRU_add_files_to_menu(prefix, file_list) + for fname in a:file_list + " Escape special characters in the filename + let esc_fname = escape(fnamemodify(fname, ':t'), ".\\" . + \ s:esc_filename_chars) + let esc_fname = substitute(esc_fname, '&', '&&', 'g') + + " Truncate the directory name if it is long + let dir_name = fnamemodify(fname, ':h') + let len = strlen(dir_name) + " Shorten long file names by adding only few characters from + " the beginning and end. + if len > 30 + let dir_name = strpart(dir_name, 0, 10) . + \ '...' . + \ strpart(dir_name, len - 20) + endif + let esc_dir_name = escape(dir_name, ".\\" . s:esc_filename_chars) + let esc_dir_name = substitute(esc_dir_name, '&', '&&', 'g') + + let menu_path = '&File.&Recent\ Files.' . a:prefix . esc_fname . + \ '\ (' . esc_dir_name . ')' + let esc_mfname = s:MRU_escape_filename(fname) + exe 'anoremenu ' . menu_path . + \ " :call MRU_Edit_File('" . esc_mfname . "', 1)" + exe 'tmenu ' . menu_path . ' Edit file ' . esc_mfname + endfor +endfunction + +" MRU_Refresh_Menu {{{1 +" Refresh the MRU menu +function! s:MRU_Refresh_Menu() + if !has('menu') || !g:MRU_Add_Menu + " No support for menus + return + endif + + " Setup the cpoptions properly for the maps to work + let old_cpoptions = &cpoptions + set cpoptions&vim + + " Remove the MRU menu + " To retain the teared-off MRU menu, we need to add a dummy entry + silent! unmenu &File.&Recent\ Files + " The menu priority of the File menu is 10. If the MRU plugin runs + " first before menu.vim, the File menu order may not be correct. + " So specify the priority of the File menu here. + 10noremenu &File.&Recent\ Files.Dummy + silent! unmenu! &File.&Recent\ Files + + anoremenu &File.&Recent\ Files.Refresh\ list + \ :call MRU_LoadList() + exe 'tmenu File.&Recent\ Files.Refresh\ list Reload the MRU file list from ' + \ . s:MRU_escape_filename(g:MRU_File) + anoremenu File.&Recent\ Files.-SEP1- : + + " Add the filenames in the MRU list to the menu + let entry_cnt = len(s:MRU_files) + if entry_cnt > g:MRU_Max_Menu_Entries + " Show only MRU_Max_Menu_Entries file names in the menu + let mru_list = s:MRU_files[0 : g:MRU_Max_Menu_Entries - 1] + let entry_cnt = g:MRU_Max_Menu_Entries + else + let mru_list = s:MRU_files + endif + if entry_cnt > g:MRU_Max_Submenu_Entries + " Split the MRU menu into sub-menus + for start_idx in range(0, entry_cnt, g:MRU_Max_Submenu_Entries) + let last_idx = start_idx + g:MRU_Max_Submenu_Entries - 1 + if last_idx >= entry_cnt + let last_idx = entry_cnt - 1 + endif + let prefix = 'Files\ (' . (start_idx + 1) . '\.\.\.' . + \ (last_idx + 1) . ').' + call s:MRU_add_files_to_menu(prefix, + \ mru_list[start_idx : last_idx]) + endfor + else + call s:MRU_add_files_to_menu('', mru_list) + endif + + " Remove the dummy menu entry + unmenu &File.&Recent\ Files.Dummy + + " Restore the previous cpoptions settings + let &cpoptions = old_cpoptions +endfunction + +" Load the MRU list on plugin startup +call s:MRU_LoadList() + +" MRU autocommands {{{1 +" Autocommands to detect the most recently used files +autocmd BufRead * call s:MRU_AddFile(expand('')) +autocmd BufNewFile * call s:MRU_AddFile(expand('')) +autocmd BufWritePost * call s:MRU_AddFile(expand('')) + +" The ':vimgrep' command adds all the files searched to the buffer list. +" This also modifies the MRU list, even though the user didn't edit the +" files. Use the following autocmds to prevent this. +autocmd QuickFixCmdPre *vimgrep* let s:mru_list_locked = 1 +autocmd QuickFixCmdPost *vimgrep* let s:mru_list_locked = 0 + +" Command to open the MRU window +command! -nargs=? -complete=customlist,s:MRU_Complete MRU + \ call s:MRU_Cmd() +command! -nargs=? -complete=customlist,s:MRU_Complete Mru + \ call s:MRU_Cmd() + +" }}} + +" restore 'cpo' +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set foldenable foldmethod=marker: diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 00000000..e2ce07b9 --- /dev/null +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,46 @@ +--- +name: "Bug Report" +about: "NERDTree is misbehaving? Tell us about it." +labels: bug +--- + + +#### Self-Diagnosis +Before creating an issue, take some time to search these resources for an answer. It's possible that someone else has already seen and solved your issue. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resources: , , etc. + +#### Environment +- Operating System: +- Vim/Neovim version `:version`: +- NERDTree version, found on first line of quickhelp `?`: +- Are you using any of these NERDTree-dependent plugins? + - [ ] [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin) + - [ ] [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons) + - [ ] [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight) + - [ ] [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin) + - [ ] [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops) + - [ ] [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection) + - [ ] [jistr/vim-nerdtree-tabs](https://github.com/jistr/vim-nerdtree-tabs) + - [ ] Others (specify): +- Provide a minimal **.vimrc** file that will reproduce the issue. +```vim +``` + +#### Steps to Reproduce the Issue +1. + +#### Current Behavior (Include screenshots where appropriate.) + +#### Expected Result + diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/feature_request.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..35db0f6a --- /dev/null +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,8 @@ +--- +name: "Feature Request" +about: "What new feature are you requesting for NERDTree?" +labels: "feature request" +--- + +#### Description + diff --git a/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000..7e13b7ac --- /dev/null +++ b/sources_non_forked/nerdtree/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,13 @@ +--- +name: "General Question" +about: "Having trouble setting up NERDTree? Need clarification on a setting? Ask your question here." +labels: "general question" +--- +Before creating an issue, take some time to search these resources. It's possible that someone else has already asked your question and gotten an answer. +- [old NERDTree issues](https://github.com/preservim/nerdtree/issues?q=is%3Aissue) +- NERDTree documentation - `:h NERDTree` +- [NERDTree Wiki](https://github.com/preservim/nerdtree/wiki) +- Other resource: , , etc. + +#### State Your Question + diff --git a/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..d2e3b7d4 --- /dev/null +++ b/sources_non_forked/nerdtree/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,22 @@ +### Description of Changes +Closes # + + +--- +### New Version Info + +#### Author's Instructions +- [ ] Derive a new `MAJOR.MINOR.PATCH` version number. Increment the: + - `MAJOR` version when you make incompatible API changes + - `MINOR` version when you add functionality in a backwards-compatible manner + - `PATCH` version when you make backwards-compatible bug fixes +- [ ] Update [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), following the established pattern. +#### Collaborator's Instructions +- [ ] Review [CHANGELOG.md](https://github.com/scrooloose/nerdtree/blob/master/CHANGELOG.md), suggesting a different version number if necessary. +- [ ] After merging, tag the commit using these (Mac-compatible) bash commands: + ```bash + git checkout master + git pull + sed -n "$(grep -n -m2 '####' CHANGELOG.md | cut -f1 -d: | sed 'N;s/\n/,/')p" CHANGELOG.md | sed '$d' + git tag -a $(read -p "Tag Name: " tag;echo $tag) -m"$(git show --quiet --pretty=%s)";git push origin --tags + ``` diff --git a/sources_non_forked/nerdtree/.github/workflows/vint.yml b/sources_non_forked/nerdtree/.github/workflows/vint.yml new file mode 100644 index 00000000..36d72580 --- /dev/null +++ b/sources_non_forked/nerdtree/.github/workflows/vint.yml @@ -0,0 +1,15 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1.0.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review diff --git a/sources_non_forked/nerdtree/.gitignore b/sources_non_forked/nerdtree/.gitignore new file mode 100644 index 00000000..3698c0ef --- /dev/null +++ b/sources_non_forked/nerdtree/.gitignore @@ -0,0 +1,3 @@ +*~ +*.swp +tags diff --git a/sources_non_forked/nerdtree/.vintrc.yaml b/sources_non_forked/nerdtree/.vintrc.yaml new file mode 100644 index 00000000..c44b6aba --- /dev/null +++ b/sources_non_forked/nerdtree/.vintrc.yaml @@ -0,0 +1,5 @@ +cmdargs: + severity: style_problem + color: true + env: + neovim: false diff --git a/sources_non_forked/nerdtree/CHANGELOG.md b/sources_non_forked/nerdtree/CHANGELOG.md new file mode 100644 index 00000000..6e6893a4 --- /dev/null +++ b/sources_non_forked/nerdtree/CHANGELOG.md @@ -0,0 +1,307 @@ +# NERDTree Change Log + +#### 6.10 +- **.16**: Fix documentation errors. (lifecrisis) [#1269](https://github.com/preservim/nerdtree/pull/1269) +- **.15**: Ensure backward compatible testing of types. (lifecrisis) [#1266](https://github.com/preservim/nerdtree/pull/1266) +- **.14**: Replace trim() with a version-compatible alternative. (PhilRunninger) [#1265](https://github.com/preservim/nerdtree/pull/1265) +- **.13**: Change highlighting of bookmarks in the tree. (PhilRunninger) [#1261](https://github.com/preservim/nerdtree/pull/1261) +- **.12**: Answer the question about accessing files over scp or ftp. (PhilRunninger) [#1259](https://github.com/preservim/nerdtree/pull/1259) +- **.11**: Trim filenames created via the fs_menu (elanorigby) [#1243](https://github.com/preservim/nerdtree/pull/1243) +- **.10**: Improve F.A.Q. Answers and Issue Templates (PhilRunninger) [#1249](https://github.com/preservim/nerdtree/pull/1249) +- **.9**: `go` on a bookmark directory will NERDTreeFind it. (PhilRunninger) [#1236](https://github.com/preservim/nerdtree/pull/1236) +- **.8**: Put `Callback` function variables in local scope. (PhilRunninger) [#1230](https://github.com/preservim/nerdtree/pull/1230) +- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) +- **.6**: Restore the default behavior of the `` key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) +- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) +- **.4**: Removed directory separator from sort key (Daniel E) [#1219](https://github.com/preservim/nerdtree/pull/1219) +- **.3**: Add new FAQ and answer: How to prevent buffers replacing NERDTree. (PhilRunninger) [#1215](https://github.com/preservim/nerdtree/pull/1215) +- **.2**: New menu command: Run a system command in this directory. (PhilRunninger) [#1214](https://github.com/preservim/nerdtree/pull/1214) +- **.1**: Escape quotation marks so they can be used in key mappings. (PhilRunninger) [#1213](https://github.com/preservim/nerdtree/pull/1213) +- **.0**: Enable full path specifications for NERDTreeIgnore (PhilRunninger) [#1207](https://github.com/preservim/nerdtree/pull/1207) +#### 6.9 +- **.12**: Respect NERDTreeCustomOpenArgs when opening bookmark (przepompownia) [#1200](https://github.com/preservim/nerdtree/pull/1200) +- **.11**: Revamp the README. (buncis, PhilRunninger) [#1192](https://github.com/preservim/nerdtree/pull/1192), [#1193](https://github.com/preservim/nerdtree/pull/1193) +- **.10**: Open a mirrored NERDTree with correct width (PhilRunninger) [#1177](https://github.com/preservim/nerdtree/pull/1177) +- **.9**: Updated Readme, removed typo (H3RSKO) [#1167](https://github.com/preservim/nerdtree/pull/1167) +- **.8**: Refactor sort comparison functions, removing redundancy (PhilRunninger) [#1166](https://github.com/preservim/nerdtree/pull/1166) +- **.7**: Fix argument of `exists()` function calls checking for autocommands. (PhilRunninger) [#1165](https://github.com/preservim/nerdtree/pull/1165) +- **.6**: Don't use silent when raising User events (PhilRunninger) [#1164](https://github.com/preservim/nerdtree/pull/1164) +- **.5**: Fix highlight for file node. (pirey) [#1157](https://github.com/preservim/nerdtree/pull/1157) +- **.4**: Make sure symbolic links' flags are highlighted correctly. (PhilRunninger) [#1156](https://github.com/preservim/nerdtree/pull/1156) +- **.3**: Fix new NERDTrees' width when previous one was in the only window. (PhilRunninger) [#1153](https://github.com/preservim/nerdtree/pull/1153) +- **.2**: Fix the scope of several key mappings (lifecrisis, PhilRunninger) [#1151](https://github.com/preservim/nerdtree/pull/1151) +- **.1**: Respect user's `&shellslash` setting in CopyNode and RemoveNode functions (PhilRunninger) [#1150](https://github.com/preservim/nerdtree/pull/1150) +- **.0**: Enable opening bookmarks in split windows. (PhilRunninger) [#1144](https://github.com/preservim/nerdtree/pull/1144) +#### 6.8 +- **.0**: Allow concealed characters to show another character. (PhilRunninger) [#1138](https://github.com/preservim/nerdtree/pull/1138) +#### 6.7 +- **.15**: Add curly braces to the list of characters to be escaped. (PhilRunninger) [#1128](https://github.com/preservim/nerdtree/pull/1128) +- **.14**: Use backward-compatible `nerdtree#and()` in one place that was missed. (PhilRunninger) [#1134](https://github.com/preservim/nerdtree/pull/1134) +- **.13**: `cmd.exe /c start "" ` for windows default viewer support. (J. Altayó) [#1130](https://github.com/preservim/nerdtree/pull/1130) +- **.12**: Fixed a bug that caused the file-tree construction to slow down significantly. (Eugenij-W) [#1126](https://github.com/preservim/nerdtree/pull/1126) +- **.11**: Fix exception in NERDTreeFind (on windows OS and If the file is located in the root directory of the disk) (Eugenij-W) [#1122](https://github.com/preservim/nerdtree/pull/1122) +- **.10**: Do not consider the tree root to be "cascadable". (lifecrisis) [#1120](https://github.com/preservim/nerdtree/pull/1120) +- **.9**: Force `:NERDTreeFocus` to allow events to be fired when switching windows. (PhilRunninger) [#1118](https://github.com/preservim/nerdtree/pull/1118) +- **.8**: Fix example code for the `NERDTreeAddKeyMap()` function. (PhilRunninger) [#1116](https://github.com/preservim/nerdtree/pull/1116) +- **.7**: Put `'%'` argument in `bufname()` for backwards compatibility. (PhilRunninger) [#1105](https://github.com/preservim/nerdtree/pull/1105) +- **.6**: If a file's already open in the window, don't edit it again. (PhilRunninger) [#1103](https://github.com/preservim/nerdtree/pull/1103) +- **.5**: Prevent unneeded tree creation in `:NERDTreeToggle[VCS] ` (PhilRunninger) [#1101](https://github.com/preservim/nerdtree/pull/1101) +- **.4**: Add missing calls to the `shellescape()` function (lifecrisis) [#1099](https://github.com/preservim/nerdtree/pull/1099) +- **.3**: Fix vsplit to not open empty buffers when opening previously closed file (AwkwardKore) [#1098](https://github.com/preservim/nerdtree/pull/1098) +- **.2**: Fix infinity loop (on winvim) in FindParentVCSRoot (Eugenij-W) [#1095](https://github.com/preservim/nerdtree/pull/1095) +- **.1**: File Move: Escape existing directory name when looking for open files. (PhilRunninger) [#1094](https://github.com/preservim/nerdtree/pull/1094) +- **.0**: Open the parent directory when revealing a non-existent file with :NERDTreeFind (bouk) [#1090](https://github.com/preservim/nerdtree/pull/1090) +#### 6.6 +- **.1**: [add] How to install using dein.vim (kazukazuinaina) [#1087](https://github.com/preservim/nerdtree/pull/1087) +- **.0**: Add the ability to turn off directory arrows (PhilRunninger) [#1085](https://github.com/preservim/nerdtree/pull/1085) +#### 6.5 +- **.0**: `NERDTreeToggle ` always sets NERDTree root. (PhilRunninger) [#1083](https://github.com/preservim/nerdtree/pull/1083) +#### 6.4 +- **.6**: NERDTreeFind shows expected message if file doesn't exist e.g. with vim-startify (andys8). [#1081](https://github.com/preservim/nerdtree/pull/1081) +- **.5**: Ensure events are (or aren't) being ignored correctly. (PhilRunninger) [#1080](https://github.com/preservim/nerdtree/pull/1080) +- **.4**: Prevent overwriting existing files/dirs on node move. (PhilRunninger) [#1079](https://github.com/preservim/nerdtree/pull/1079) +- **.3**: Fix regex that finds keyword for minimal menu. (PhilRunninger) [#1075](https://github.com/preservim/nerdtree/pull/1075) +- **.2**: Lint vimscript, fix errors and warnings, add CI job to review PRs (Caleb Maclennan) [#1071](https://github.com/preservim/nerdtree/pull/1071) +- **.1**: Ensure backward compatibility. v:t_func is not available before Vim 8.0 (Phil Runninger) +- **.0**: Allow use of function references as callbacks (HiPhish) [#1067](https://github.com/preservim/nerdtree/pull/1067) +#### 6.3 +- **.0**: Add new command that behaves like NERDTreeToggle but defaults to the root of a VCS repository. (willfindlay) [#1060](https://github.com/preservim/nerdtree/pull/1060) +#### 6.2 +- **.1**: Menu option, 'copy path to clipboard' is aware of VIM clipboard option (jhzn) [#1056](https://github.com/preservim/nerdtree/pull/1056) +- **.0**: Support tab-specific CWDs (PhilRunninger) [#1032](https://github.com/preservim/nerdtree/pull/1032) +#### 6.1 +- **.4**: Add VIM built-in package management to read me file. (pesarkhobeee) [#1049](https://github.com/preservim/nerdtree/pull/1049) +- **.3**: Save/Set screen state also on WinLeave and WinEnter. (PhilRunninger) [#1048](https://github.com/preservim/nerdtree/pull/1048) +- **.2**: Wrap saveScreenState's statements in a try-catch block. (PhilRunninger) [#1047](https://github.com/preservim/nerdtree/pull/1047) +- **.1**: Catch errors when trying to read CHANGELOG.md. (PhilRunninger) [#1045](https://github.com/preservim/nerdtree/pull/1045) +- **.0**: If file path doesn't exist, :NERDTreeFind its parent directory instead. (PhilRunninger) [#1043](https://github.com/preservim/nerdtree/pull/1043) +#### 6.0 +- **.1**: Reintroduce necessary variable mistakenly removed. (PhilRunninger) [#1040](https://github.com/preservim/nerdtree/pull/1040) +- **.0**: Make the behavior of window splits consistent (dragonxlwang, PhilRunninger) [#1035](https://github.com/preservim/nerdtree/pull/1035) +#### 5.3 +- **.3**: Fix (p)ath not displaying in the minimal menu (tuzz) [#1038](https://github.com/preservim/nerdtree/pull/1038) +- **.2**: Enable events when closing NerdTree window. (PhilRunninger) [#1037](https://github.com/preservim/nerdtree/pull/1037) +- **.1**: Fix the `e` key mapping to use netrw if desired (PhilRunninger) [#1031](https://github.com/preservim/nerdtree/pull/1031) +- **.0**: Add file extension and size to sorting capabilities (PhilRunninger) [#1029](https://github.com/preservim/nerdtree/pull/1029) +#### 5.2 +- **.9**: Suppress events for intermediate window/tab/buffer changes (PhilRunninger) [#1026](https://github.com/preservim/nerdtree/pull/1026) +- **.8**: Revert [#1019](https://github.com/preservim/nerdtree/pull/1019) to fix nvim artifacts and flickering. (PhilRunninger) [#1021](https://github.com/preservim/nerdtree/pull/1021) +- **.7**: Use :mode only in neovim. MacVim still needs to use :redraw! (PhilRunninger) [#1019](https://github.com/preservim/nerdtree/pull/1019) +- **.6**: In CHANGELOG.md and PR template, make reference to PR a true HTML link. (PhilRunninger) [#1017](https://github.com/preservim/nerdtree/pull/1017) +- **.5**: Use `:mode` instead of `:redraw!` when updating menu. (PhilRunninger) [#1016](https://github.com/preservim/nerdtree/pull/1016) +- **.4**: When searching for root line num, stop at end of file. (PhilRunninger) [#1015](https://github.com/preservim/nerdtree/pull/1015) +- **.3**: Fix `` key map on the bookmark (lkebin) [#1014](https://github.com/preservim/nerdtree/pull/1014) +- **.2**: Make Enter work on the `.. ( up a dir )` line (PhilRunninger) [#1013](https://github.com/preservim/nerdtree/pull/1013) +- **.1**: Fix nerdtree#version() on Windows. (PhilRunninger) +- **.0**: Expand functionality of `` mapping. (PhilRunninger) [#1011](https://github.com/preservim/nerdtree/pull/1011) +#### 5.1 +- **.3**: Remove @mentions from PR template and change log. They weren't working. (PhilRunninger) [#1009](https://github.com/preservim/nerdtree/pull/1009) +- **.2**: Fix NERDTree opening with the wrong size. (PhilRunninger) [#1008](https://github.com/preservim/nerdtree/pull/1008) +- **.1**: Update Changelog and create PR Template (PhilRunninger) [#1007](https://github.com/preservim/nerdtree/pull/1007) +- **.0**: Too many changes for one patch... + - Refresh a dir_node if the file wasn't found in it, and look once more. (PhilRunninger) [#1005](https://github.com/preservim/nerdtree/pull/1005) + - Add a "copy path to clipboard" menu option (PhilRunninger) [#1002](https://github.com/preservim/nerdtree/pull/1002) + - Enable root refresh on "vim ." a different way than [#999](https://github.com/preservim/nerdtree/pull/999). (PhilRunninger) [#1001](https://github.com/preservim/nerdtree/pull/1001) + - Fix refreshroot (PhilRunninger) [#999](https://github.com/preservim/nerdtree/pull/999) + - Change version check to look for 703 not 730 (vhalis) [#994](https://github.com/preservim/nerdtree/pull/994) + - Change minimum vim (PhilRunninger) [#991](https://github.com/preservim/nerdtree/pull/991) + - Allow multi-character DirArrows (PhilRunninger) [#985](https://github.com/preservim/nerdtree/pull/985) + - Remove redraw! while still clearing last message empty string. (PhilRunninger) [#979](https://github.com/preservim/nerdtree/pull/979) + - fix `_initChildren` function value set to numChildrenCached error (terryding77) [#969](https://github.com/preservim/nerdtree/pull/969) + - On Windows, do a case-insensitive comparison of paths. (PhilRunninger) [#967](https://github.com/preservim/nerdtree/pull/967) + - Remove the **Please wait... DONE** messages. (PhilRunninger) [#966](https://github.com/preservim/nerdtree/pull/966) + - Smarter delimiter default (PhilRunninger) [#963](https://github.com/preservim/nerdtree/pull/963) + - Update directory .vimdc readme example (spencerdcarlson) [#961](https://github.com/preservim/nerdtree/pull/961) + - Preview bookmarks (PhilRunninger) [#956](https://github.com/preservim/nerdtree/pull/956) + - Add new value to NERDTreeQuitOnOpen to close bookmark table (PhilRunninger) [#955](https://github.com/preservim/nerdtree/pull/955) + - Add an :EditBookmarks command to edit the bookmarks file (PhilRunninger) [#954](https://github.com/preservim/nerdtree/pull/954) + - Before copying, turn off &shellslash. Restore after copy is finished. (PhilRunninger) [#952](https://github.com/preservim/nerdtree/pull/952) + - Set a maximum window size when zooming. (PhilRunninger) [#950](https://github.com/preservim/nerdtree/pull/950) + - Confirm the wipeout of a unsaved buffer whose file has been renamed. (PhilRunninger) [#949](https://github.com/preservim/nerdtree/pull/949) + - Escape a backslash so it can be used in a key mapping. (PhilRunninger) [#948](https://github.com/preservim/nerdtree/pull/948) + - Add a NERDTreeMinimalMenu feature (tuzz) [#938](https://github.com/preservim/nerdtree/pull/938) + - fixed root path error for windows (zcodes) [#935](https://github.com/preservim/nerdtree/pull/935) + - Restore getDirChildren for use in nerdtree-project-plugin. (PhilRunninger) [#929](https://github.com/preservim/nerdtree/pull/929) + - Document NERDTreeNodeDelimiter [#912](https://github.com/preservim/nerdtree/pull/912) (PhilRunninger) [#926](https://github.com/preservim/nerdtree/pull/926) + - Allow modification of menu keybindings (Leandros) [#923](https://github.com/preservim/nerdtree/pull/923) + - Add two more disqualifications for isCascadable(). (PhilRunninger) [#914](https://github.com/preservim/nerdtree/pull/914) + - Allow highlighting more than one flag. (kristijanhusak) [#908](https://github.com/preservim/nerdtree/pull/908) + - Support sorting files and directories by modification time. (PhilRunninger) [#901](https://github.com/preservim/nerdtree/pull/901) + - Parse . and .. from path string with trailing slash. (PhilRunninger) [#899](https://github.com/preservim/nerdtree/pull/899) + - Force sort to recalculate the cached sortKey. (PhilRunninger) [#898](https://github.com/preservim/nerdtree/pull/898) + - Add NERDTreeRefreshRoot command (wgfm) [#897](https://github.com/preservim/nerdtree/pull/897) + - Call Resolve on the file's path when calling :NERDTreeFind. (PhilRunninger) [#896](https://github.com/preservim/nerdtree/pull/896) + - Catch all errors, not just NERDTree errors. (PhilRunninger) [#894](https://github.com/preservim/nerdtree/pull/894) + - Fix typo in help file (lvoisin) [#892](https://github.com/preservim/nerdtree/pull/892) + - Make NERDTreeCreator set the `'nolist'` option (lifecrisis) [#889](https://github.com/preservim/nerdtree/pull/889) + - Refresh buffers after `m`, `m` operation on a folder (PhilRunninger) [#888](https://github.com/preservim/nerdtree/pull/888) + - Use a better arg for FINDSTR when using the m,l command in Windows. (PhilRunninger) [#887](https://github.com/preservim/nerdtree/pull/887) + - Fix the / motions, which currently fail with cascades (lifecrisis) [#886](https://github.com/preservim/nerdtree/pull/886) + - Function "s:UI.getLineNum()" doesn't always work on cascades. (lifecrisis) [#882](https://github.com/preservim/nerdtree/pull/882) + - NERDTreeCWD: reset CWD if changed by NERDTreeFocus (PhilRunninger) [#878](https://github.com/preservim/nerdtree/pull/878) + - Use tabnext instead of gt to allow users to remap gt. (PhilRunninger) [#877](https://github.com/preservim/nerdtree/pull/877) + - Do a case sensitive comparison of new/existing buffers. (PhilRunninger) [#875](https://github.com/preservim/nerdtree/pull/875) + - Fix opening sub-directories that have commas in their name. (PhilRunninger) [#873](https://github.com/preservim/nerdtree/pull/873) + - Add new command to open NERDTree in the root of a VCS repository. (PhilRunninger) [#872](https://github.com/preservim/nerdtree/pull/872) + - Make sure the path to the bookmarks file exists before writing it. (PhilRunninger) [#871](https://github.com/preservim/nerdtree/pull/871) + - Unzoom NERDTree when opening a file (PhilRunninger) [#870](https://github.com/preservim/nerdtree/pull/870) + - Support unusual characters in file and directory names (PhilRunninger) [#868](https://github.com/preservim/nerdtree/pull/868) + - Reword renamed-buffer prompt to be more clear (aflock) [#867](https://github.com/preservim/nerdtree/pull/867) + - Default to placing cursor on root when closing bookmark table (lifecrisis) [#866](https://github.com/preservim/nerdtree/pull/866) + - Fix issues with sorting of nodes (PhilRunninger) [#856](https://github.com/preservim/nerdtree/pull/856) + - Better OSX detection (bubba-h57) [#853](https://github.com/preservim/nerdtree/pull/853) + - Bugfix - ensure keymaps dictionary exists before using it (mnussbaum) [#852](https://github.com/preservim/nerdtree/pull/852) + - Decrease startup-time by avoiding linear-time iteration over key mappings (mnussbaum) [#851](https://github.com/preservim/nerdtree/pull/851) + - Add code to sort mappings in quickhelp (lifecrisis) [#849](https://github.com/preservim/nerdtree/pull/849) + - Use ":clearjumps" in new NERDTree windows (lifecrisis) [#844](https://github.com/preservim/nerdtree/pull/844) + - Like m-c did before, create parent directories if needed on m-m. (PhilRunninger) [#840](https://github.com/preservim/nerdtree/pull/840) + - BUGFIX: Repair a problem with the `'u'` mapping. (lifecrisis) [#838](https://github.com/preservim/nerdtree/pull/838) + - Make the NERDTree buffer writable when rendering it. (PhilRunninger) [#837](https://github.com/preservim/nerdtree/pull/837) + - Code cleanup: Remove unsupported bookmark table mappings (lifecrisis) [#835](https://github.com/preservim/nerdtree/pull/835) + - Replace strcharpart() with substitute() for backward compatibility (bravestarr) [#834](https://github.com/preservim/nerdtree/pull/834) + - Fixed error `unknown function strcharpart` for older versions of Vim (hav4ik) [#833](https://github.com/preservim/nerdtree/pull/833) + - Clear output when NERDTree menu is aborted (lifecrisis) [#832](https://github.com/preservim/nerdtree/pull/832) + - Display a path with multi-byte characters correctly when it is truncated (bravestarr) [#830](https://github.com/preservim/nerdtree/pull/830) + - Support revealing file and executing file with xdg-open for Linux (ngnmhieu) [#824](https://github.com/preservim/nerdtree/pull/824) + - If node isn't open, count children on disk before deleting. (PhilRunninger) [#822](https://github.com/preservim/nerdtree/pull/822) + - Add new variable g:NERDTreeRemoveFileCmd (kutsan) [#816](https://github.com/preservim/nerdtree/pull/816) + - Use a better check for existence of the NERDTree buffer. (PhilRunninger) [#814](https://github.com/preservim/nerdtree/pull/814) + - Fix focussing previous buffer when closing NERDTree (mrubli) [#801](https://github.com/preservim/nerdtree/pull/801) + - Update the docs for "NERDTreeStatusline" (lifecrisis) [#796](https://github.com/preservim/nerdtree/pull/796) + - BUGFIX: Unstable behavior in the "getPath()" method (lifecrisis) [#795](https://github.com/preservim/nerdtree/pull/795) + - Revert the bugfix from pull request [#785](https://github.com/preservim/nerdtree/pull/785) (lifecrisis) [#794](https://github.com/preservim/nerdtree/pull/794) + - BUGFIX: Allow ":NERDTreeFind" to discover hidden files (lifecrisis) [#786](https://github.com/preservim/nerdtree/pull/786) + - BUGFIX: Allow ":NERDTreeFind" to reveal new files (lifecrisis) [#785](https://github.com/preservim/nerdtree/pull/785) + - Add modelines (lifecrisis) [#782](https://github.com/preservim/nerdtree/pull/782) + - Change the type of completion used by NERDTreeFind (lifecrisis) [#781](https://github.com/preservim/nerdtree/pull/781) + - change NERDTreeFind with args (zhenyangze) [#778](https://github.com/preservim/nerdtree/pull/778) + - Style Choice: Using confirm() when deleting a bookmark (lifecrisis) [#777](https://github.com/preservim/nerdtree/pull/777) + - remove useless substitute when `file =~# "/$"` (skyblueee) [#773](https://github.com/preservim/nerdtree/pull/773) + - remove useless removeLeadingSpaces in _stripMarkup (skyblueee) [#772](https://github.com/preservim/nerdtree/pull/772) + - Make the "o" mapping consistent with "x" (lifecrisis) [#769](https://github.com/preservim/nerdtree/pull/769) + - Fix a problem with the "x" handler (lifecrisis) [#768](https://github.com/preservim/nerdtree/pull/768) + - Clean up the handler for the "x" mapping (lifecrisis) [#767](https://github.com/preservim/nerdtree/pull/767) + - Revert change to tab opening method (lifecrisis) [#766](https://github.com/preservim/nerdtree/pull/766) + - BUGFIX: Add back support for "b:NERDTreeRoot" (lifecrisis) [#765](https://github.com/preservim/nerdtree/pull/765) + - Fix broken "t" and "T" mappings, tabs now open at end (lifecrisis) [#759](https://github.com/preservim/nerdtree/pull/759) + - Update doc with already existing mapping variables (asnr) [#699](https://github.com/preservim/nerdtree/pull/699) + - Fix the broken g:NERDTreeBookmarksSort setting (lifecrisis) [#696](https://github.com/preservim/nerdtree/pull/696) + - Correct NERDTreeIgnore pattern in doc (cntoplolicon) [#648](https://github.com/preservim/nerdtree/pull/648) + - Remove empty segments when splitting path (sooth-sayer) [#574](https://github.com/preservim/nerdtree/pull/574) + - Suppress autocmds less agressively (wincent) [#578](https://github.com/preservim/nerdtree/pull/578) [#691](https://github.com/preservim/nerdtree/pull/691) + - Add an Issues template to ask for more info initially. + - Fix markdown headers in readme (josephfrazier) [#676](https://github.com/preservim/nerdtree/pull/676) + - Don't touch `@o` and `@h` registers when rendering + - Fix bug with files and directories with dollar signs (alegen) [#649](https://github.com/preservim/nerdtree/pull/649) + - Reuse/reopen existing window trees where possible [#244](https://github.com/preservim/nerdtree/pull/244) + - Remove NERDTree.previousBuf() + - Change color of arrow (Leeiio) [#630](https://github.com/preservim/nerdtree/pull/630) + - Improved a tip in README.markdown (ggicci) [#628](https://github.com/preservim/nerdtree/pull/628) + - Shorten delete confimration of empty directory to `y` (mikeperri) [#530](https://github.com/preservim/nerdtree/pull/530) + - Fix API call to open directory tree in window (devm33) [#533](https://github.com/preservim/nerdtree/pull/533) + - Change default arrows on non-Windows platforms (gwilk) [#546](https://github.com/preservim/nerdtree/pull/546) + - Update to README - combine cd and git clone (zwhitchcox) [#584](https://github.com/preservim/nerdtree/pull/584) + - Update to README - Tip: start NERDTree when vim starts (therealplato) [#593](https://github.com/preservim/nerdtree/pull/593) + - Escape filename when moving an open buffer (zacharyvoase) [#595](https://github.com/preservim/nerdtree/pull/595) + - Fixed incorrect :helptags command in README (curran) [#619](https://github.com/preservim/nerdtree/pull/619) + - Fixed incomplete escaping of folder arrows (adityanatraj) [#548](https://github.com/preservim/nerdtree/pull/548) + - Added NERDTreeCascadeSingleChildDir option (juanibiapina) [#558](https://github.com/preservim/nerdtree/pull/558) + - Replace strchars() with backward compatible workaround. + - Add support for copy command in Windows (SkylerLipthay) [#231](https://github.com/preservim/nerdtree/pull/231) + - Fixed typo in README.markdown - :Helptags -> :helptags + - Rename "primary" and "secondary" trees to "tab" and "window" trees. + - Move a bunch of buffer level variables into the NERDTree and UI classes. + - Display cascading dirs on one line to save vertical/horizontal space (matt-gardner: brainstorming/testing) + - Remove the old style UI - Remove `NERDTreeDirArrows` option. + - On windows default to + and ~ for expand/collapse directory symbols. + - Lots more refactoring. Move a bunch of b: level vars into b:NERDTree and friends. + +#### 5.0.0 +- Refactor the code significantly: + * Break the classes out into their own files. + * Make the majority of the code OO - previously large parts were effectively a tangle of "global" methods. +- Add an API to assign flags to nodes. This allows VCS plugins like https://github.com/Xuyuanp/nerdtree-git-plugin to exist. Thanks to **Xuyuanp** for helping design/test/build said API. +- add `scope` argument to the key map API see :help NERDTreeAddKeyMap() +- add magic [[dir]] and [[file]] flags to NERDTreeIgnore +- add support for custom path filters. See :help NERDTreeAddPathFilter() +- add path listener API. See :help NERDTreePathListenerAPI. +- expand the fs menu functionality to list file properties (PhilRunninger, apbarrero, JESii) +- make bookmarks work with `~` home shortcuts (hiberabyss) +- show OSX specific fsmenu options in regular vim on mac (evindor) +- make dir arrow icons configurable (PickRelated) +- optimise node sorting performance when opening large dirs (vtsang) +- make the root note render prettier by truncating it at a path slash (gcmt) +- remove NERDChristmasTree option - its always christmas now +- add "cascade" open and closing for dirs containing only another single dir. See :help NERDTreeCascadeOpenSingleChildDir (pendulm) +- Many other fixes, doc updates and contributions from: **actionshrimp**, **agrussellknives**, **alvan**, **AndrewRadev**, **cperl82** (*many small fixes*), **devmanhinton**, **egalpin**, **franksort**, **gastropoda**, **handcraftedbits**, **kelaban**, **lucascaton**, **mixvin**, **pendulm**, **SchDen**, **shanesmith**, **staeff**, **stephenprater**, **toiffel**, **Twinside**, **WoLpH**, **xiaodili**, **zhangoose** + +#### 4.2.0 +- Add NERDTreeDirArrows option to make the UI use pretty arrow chars instead of the old +~| chars to define the tree structure (sickill) +- shift the syntax highlighting out into its own syntax file (gnap) +- add some mac specific options to the filesystem menu - for macvim only (andersonfreitas) +- Add NERDTreeMinimalUI option to remove some non functional parts of the nerdtree ui (camthompson) +- tweak the behaviour of :NERDTreeFind - see :help :NERDTreeFind for the new behaviour (benjamingeiger) +- if no name is given to :Bookmark, make it default to the name of the target file/dir (minyoung) +- use `file` completion when doing copying, create, and move operations (EvanDotPro) +- lots of misc bug fixes from: **AndrewRadev**, **Bogdanov**, **camthompson**, **kml**, **mathias**, **paddyoloughlin**, **scottstvnsn**, **sdewald**, **Vitaly**, **wycats**, me RAWR! + +#### 4.1.0 +- features: + - NERDTreeFind to reveal the node for the current buffer in the tree, see `|NERDTreeFind|`. This effectively merges the FindInNERDTree plugin (by **Doug McInnes**) into the script. + - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to **Stefan Ritter** and **Rémi Prévost**. + - truncate the root node if wider than the tree window. Thanks to **Victor Gonzalez**. + +- bugfixes: + - really fix window state restoring + - fix some win32 path escaping issues. Thanks to **Stephan Baumeister**, **Ricky**, **jfilip1024**, and **Chris Chambers**. + +#### 4.0.0 +- add a new programmable menu system (see `:help NERDTreeMenu`). +- add new APIs to add menus/menu-items to the menu system as well as custom key mappings to the NERD tree buffer (see `:help NERDTreeAPI`). +- removed the old API functions +- added a mapping to maximize/restore the size of nerd tree window, thanks to Guillaume Duranceau for the patch. See :help NERDTree-A for details. +- fix a bug where secondary nerd trees (netrw hijacked trees) and NERDTreeQuitOnOpen didnt play nicely, thanks to **Curtis Harvey**. +- fix a bug where the script ignored directories whose name ended in a dot, thanks to **Aggelos Orfanakos** for the patch. +- fix a bug when using the x mapping on the tree root, thanks to **Bryan Venteicher** for the patch. +- fix a bug where the cursor position/window size of the nerd tree buffer wasnt being stored on closing the window, thanks to **Richard Hart**. +- fix a bug where NERDTreeMirror would mirror the wrong tree + +#### 3.1.1 +- fix a bug where a non-listed no-name buffer was getting created every time the tree windows was created, thanks to **Derek Wyatt** and **owen1** +- make `` behave the same as the `o` mapping +- some helptag fixes in the doc, thanks **strull**. +- fix a bug when using `:set nohidden` and opening a file where the previous buf was modified. Thanks **iElectric**. +- other minor fixes + +#### 3.1.0 +- New features: + - add mappings to open files in a vsplit, see `:help NERDTree-s` and `:help NERDTree-gs` + - make the statusline for the nerd tree window default to something hopefully more useful. See `:help 'NERDTreeStatusline'` +- Bugfixes: + - make the hijack netrw functionality work when vim is started with `vim ` (thanks to **Alf Mikula** for the patch). + - fix a bug where the CWD wasnt being changed for some operations even when NERDTreeChDirMode==2 (thanks to **Lucas S. Buchala**) + - add -bar to all the nerd tree :commands so they can chain with other :commands (thanks to **tpope**) + - fix bugs when ignorecase was set (thanks to **nach**) + - fix a bug with the relative path code (thanks to **nach**) + - fix a bug where doing a `:cd` would cause `:NERDTreeToggle` to fail (thanks **nach**) + + +#### 3.0.1 +- Bugfixes: + - fix bugs with :NERDTreeToggle and :NERDTreeMirror when `'hidden'` was not set + - fix a bug where `:NERDTree ` would fail if `` was relative and didnt start with a `./` or `../` Thanks to **James Kanze**. + - make the `q` mapping work with secondary (`:e ` style) trees, thanks to **jamessan** + - fix a bunch of small bugs with secondary trees +- More insane refactoring. + +#### 3.0.0 +- hijack netrw so that doing an `:edit ` will put a NERD tree in the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' +- allow sharing of trees across tabs, see `:help :NERDTreeMirror` +- remove "top" and "bottom" as valid settings for NERDTreeWinPos +- change the `''` mapping to `'i'` +- change the `'H'` mapping to `'I'` +- lots of refactoring diff --git a/sources_non_forked/nerdtree/LICENCE b/sources_non_forked/nerdtree/LICENCE new file mode 100644 index 00000000..8b1a9d81 --- /dev/null +++ b/sources_non_forked/nerdtree/LICENCE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/sources_non_forked/nerdtree/README.markdown b/sources_non_forked/nerdtree/README.markdown new file mode 100644 index 00000000..27aa3148 --- /dev/null +++ b/sources_non_forked/nerdtree/README.markdown @@ -0,0 +1,227 @@ +![Help Wanted](http://blog.ncce.org/wp-content/uploads/2013/12/help-wanted.jpg) + +**NERDTree** is on the lookout for a new maintainer. See [issue #1280](https://github.com/preservim/nerdtree/issues/1280) to submit your name for consideration. + +--- + +# The NERDTree [![Vint](https://github.com/preservim/nerdtree/workflows/Vint/badge.svg)](https://github.com/preservim/nerdtree/actions?workflow=Vint) + +## Introduction + +The NERDTree is a file system explorer for the Vim editor. Using this plugin, users can visually browse complex directory hierarchies, quickly open files for reading or editing, and perform basic file system operations. + +![NERDTree Screenshot](https://github.com/preservim/nerdtree/raw/master/screenshot.png) + +## Installation + +Use your favorite plugin manager to install this plugin. [tpope/vim-pathogen](https://github.com/tpope/vim-pathogen), [VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim), [junegunn/vim-plug](https://github.com/junegunn/vim-plug), and [Shougo/dein.vim](https://github.com/Shougo/dein.vim) are some of the more popular ones. A lengthy discussion of these and other managers can be found on [vi.stackexchange.com](https://vi.stackexchange.com/questions/388/what-is-the-difference-between-the-vim-plugin-managers). Basic instructions are provided below, but please **be sure to read, understand, and follow all the safety rules that come with your ~~power tools~~ plugin manager.** + +If you have no favorite, or want to manage your plugins without 3rd-party dependencies, consider using Vim 8+ packages, as described in Greg Hurrell's excellent Youtube video: [Vim screencast #75: Plugin managers](https://www.youtube.com/watch?v=X2_R3uxDN6g). + +
+Pathogen +Pathogen is more of a runtime path manager than a plugin manager. You must clone the plugins' repositories yourself to a specific location, and Pathogen makes sure they are available in Vim. + + +1. In the terminal, + ```bash + git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree + ``` +1. In your `vimrc`, + ```vim + call pathogen#infect() + syntax on + filetype plugin indent on + ``` +1. Restart Vim, and run `:helptags ~/.vim/bundle/nerdtree/doc/` or `:Helptags`. +
+ +
+ Vundle + +1. Install Vundle, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call vundle#begin() + Plugin 'preservim/nerdtree' + call vundle#end() + ``` +1. Restart Vim, and run the `:PluginInstall` statement to install your plugins. +
+ +
+ Vim-Plug + +1. Install Vim-Plug, according to its instructions. +1. Add the following text to your `vimrc`. +```vim +call plug#begin() + Plug 'preservim/nerdtree' +call plug#end() +``` +1. Restart Vim, and run the `:PlugInstall` statement to install your plugins. +
+ +
+ Dein + +1. Install Dein, according to its instructions. +1. Add the following text to your `vimrc`. + ```vim + call dein#begin() + call dein#add('preservim/nerdtree') + call dein#end() + ``` +1. Restart Vim, and run the `:call dein#install()` statement to install your plugins. +
+ +
+Vim 8+ packages + +If you are using Vim version 8 or higher you can use its built-in package management; see `:help packages` for more information. Just run these commands in your terminal: + +```bash +git clone https://github.com/preservim/nerdtree.git ~/.vim/pack/vendor/start/nerdtree +vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q +``` +
+ +## Getting Started +After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`. + +## NERDTree Plugins +NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible. + +* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree. +* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders, +* [tiagofumo/vim-nerdtree-syntax-highlight](https://github.com/tiagofumo/vim-nerdtree-syntax-highlight): Adds syntax highlighting to NERDTree based on filetype. +* [scrooloose/nerdtree-project-plugin](https://github.com/scrooloose/nerdtree-project-plugin): Saves and restores the state of the NERDTree between sessions. +* [PhilRunninger/nerdtree-buffer-ops](https://github.com/PhilRunninger/nerdtree-buffer-ops): 1) Highlights open files in a different color. 2) Closes a buffer directly from NERDTree. +* [PhilRunninger/nerdtree-visual-selection](https://github.com/PhilRunninger/nerdtree-visual-selection): Enables NERDTree to open, delete, move, or copy multiple Visually-selected files at once. + +If any others should be listed, mention them in an issue or pull request. + + +## Frequently Asked Questions + +In the answers to these questions, you will see code blocks that you can put in your `vimrc` file. + +### How can I map a specific key or shortcut to open NERDTree? + +NERDTree doesn't create any shortcuts outside of the NERDTree window, so as not to overwrite any of your other shortcuts. Use the `nnoremap` command in your `vimrc`. You, of course, have many keys and NERDTree commands to choose from. Here are but a few examples. +```vim +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind +``` + +### How do I open NERDTree automatically when Vim starts? +Each code block below is slightly different, as described in the `" Comment lines`. + +```vim +" Start NERDTree and leave the cursor in it. +autocmd VimEnter * NERDTree +``` +--- +```vim +" Start NERDTree and put the cursor back in the other window. +autocmd VimEnter * NERDTree | wincmd p +``` +--- +```vim +" Start NERDTree when Vim is started without file arguments. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif +``` +--- +```vim +" Start NERDTree. If a file is specified, move the cursor to its window. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif +``` +--- +```vim +" Start NERDTree, unless a file or session is specified, eg. vim -S session_file.vim. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists('s:std_in') && v:this_session == '' | NERDTree | endif +``` +--- +```vim +" Start NERDTree when Vim starts with a directory argument. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif +``` + +### How can I close Vim or a tab automatically when NERDTree is the last window? + +```vim +" Exit Vim if NERDTree is the only window remaining in the only tab. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +``` +--- +```vim +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif +``` + +### How can I prevent other buffers replacing NERDTree in its window? + +```vim +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +``` + +### Can I have the same NERDTree on every tab automatically? + +```vim +" Open the existing NERDTree on each new tab. +autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif +``` +or change your NERDTree-launching shortcut key like so: +```vim +" Mirror the NERDTree before showing it. This makes it the same on all tabs. +nnoremap :NERDTreeMirror:NERDTreeFocus +``` + +### How can I change the default arrows? + +```vim +let g:NERDTreeDirArrowExpandable = '?' +let g:NERDTreeDirArrowCollapsible = '?' +``` +The preceding values are the non-Windows default arrow symbols. Setting these variables to empty strings will remove the arrows completely and shift the entire tree two character positions to the left. See `:h NERDTreeDirArrowExpandable` for more details. + +### Can NERDTree access remote files via scp or ftp? + +Short answer: No, and there are no plans to add that functionality. However, Vim ships with a plugin that does just that. It's called netrw, and by adding the following lines to your `.vimrc`, you can use it to open files over the `scp:`, `ftp:`, or other protocols, while still using NERDTree for all local files. The function seamlessly makes the decision to open NERDTree or netrw, and other supported protocols can be added to the regular expression. + +```vim +" Function to open the file or NERDTree or netrw. +" Returns: 1 if either file explorer was opened; otherwise, 0. +function! s:OpenFileOrExplorer(...) + if a:0 == 0 || a:1 == '' + NERDTree + elseif filereadable(a:1) + execute 'edit '.a:1 + return 0 + elseif a:1 =~? '^\(scp\|ftp\)://' " Add other protocols as needed. + execute 'Vexplore '.a:1 + elseif isdirectory(a:1) + execute 'NERDTree '.a:1 + endif + return 1 +endfunction + +" Auto commands to handle OS commandline arguments +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc()==1 && !exists('s:std_in') | if OpenFileOrExplorer(argv()[0]) | wincmd p | enew | wincmd p | endif | endif + +" Command to call the OpenFileOrExplorer function. +command! -n=? -complete=file -bar Edit :call OpenFileOrExplorer('') + +" Command-mode abbreviation to replace the :edit Vim command. +cnoreabbrev e Edit +``` diff --git a/sources_non_forked/nerdtree/_config.yml b/sources_non_forked/nerdtree/_config.yml new file mode 100644 index 00000000..c4192631 --- /dev/null +++ b/sources_non_forked/nerdtree/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/sources_non_forked/nerdtree/autoload/nerdtree.vim b/sources_non_forked/nerdtree/autoload/nerdtree.vim new file mode 100644 index 00000000..ba708711 --- /dev/null +++ b/sources_non_forked/nerdtree/autoload/nerdtree.vim @@ -0,0 +1,249 @@ +if exists('g:loaded_nerdtree_autoload') + finish +endif +let g:loaded_nerdtree_autoload = 1 + +let s:rootNERDTreePath = resolve(expand(':p:h:h')) + +"FUNCTION: nerdtree#version(...) {{{1 +" If any value is given as an argument, the entire line of text from the +" change log is shown for the current version; otherwise, only the version +" number is shown. +function! nerdtree#version(...) abort + let l:text = 'Unknown' + try + let l:changelog = readfile(join([s:rootNERDTreePath, 'CHANGELOG.md'], nerdtree#slash())) + let l:line = 0 + while l:line <= len(l:changelog) + if l:changelog[l:line] =~# '\d\+\.\d\+' + let l:text = substitute(l:changelog[l:line], '.*\(\d\+.\d\+\).*', '\1', '') + let l:text .= substitute(l:changelog[l:line+1], '^.\{-}\(\.\d\+\).\{-}:\(.*\)', a:0>0 ? '\1:\2' : '\1', '') + break + endif + let l:line += 1 + endwhile + catch + endtry + return l:text +endfunction + +" SECTION: General Functions {{{1 +"============================================================ + +" FUNCTION: nerdtree#closeTreeOnOpen() {{{2 +function! nerdtree#closeTreeOnOpen() abort + return g:NERDTreeQuitOnOpen == 1 || g:NERDTreeQuitOnOpen == 3 +endfunction + +" FUNCTION: nerdtree#closeBookmarksOnOpen() {{{2 +function! nerdtree#closeBookmarksOnOpen() abort + return g:NERDTreeQuitOnOpen == 2 || g:NERDTreeQuitOnOpen == 3 +endfunction + +" FUNCTION: nerdtree#slash() {{{2 +" Return the path separator used by the underlying file system. Special +" consideration is taken for the use of the 'shellslash' option on Windows +" systems. +function! nerdtree#slash() abort + if nerdtree#runningWindows() + if exists('+shellslash') && &shellslash + return '/' + endif + + return '\' + endif + + return '/' +endfunction + +"FUNCTION: nerdtree#checkForBrowse(dir) {{{2 +"inits a window tree in the current buffer if appropriate +function! nerdtree#checkForBrowse(dir) abort + if !isdirectory(a:dir) + return + endif + + if s:reuseWin(a:dir) + return + endif + + call g:NERDTreeCreator.CreateWindowTree(a:dir) +endfunction + +"FUNCTION: s:reuseWin(dir) {{{2 +"finds a NERDTree buffer with root of dir, and opens it. +function! s:reuseWin(dir) abort + let path = g:NERDTreePath.New(fnamemodify(a:dir, ':p')) + + for i in range(1, bufnr('$')) + unlet! nt + let nt = getbufvar(i, 'NERDTree') + if empty(nt) + continue + endif + + if nt.isWinTree() && nt.root.path.equals(path) + call nt.setPreviousBuf(bufnr('#')) + exec 'buffer ' . i + return 1 + endif + endfor + + return 0 +endfunction + +" FUNCTION: nerdtree#completeBookmarks(A,L,P) {{{2 +" completion function for the bookmark commands +function! nerdtree#completeBookmarks(A,L,P) abort + return filter(g:NERDTreeBookmark.BookmarkNames(), 'v:val =~# "^' . a:A . '"') +endfunction + +"FUNCTION: nerdtree#compareNodes(n1, n2) {{{2 +function! nerdtree#compareNodes(n1, n2) abort + return nerdtree#compareNodePaths(a:n1.path, a:n2.path) +endfunction + +"FUNCTION: nerdtree#compareNodePaths(p1, p2) {{{2 +function! nerdtree#compareNodePaths(p1, p2) abort + let sortKey1 = a:p1.getSortKey() + let sortKey2 = a:p2.getSortKey() + let i = 0 + while i < min([len(sortKey1), len(sortKey2)]) + " Compare chunks upto common length. + " If chunks have different type, the one which has + " integer type is the lesser. + if type(sortKey1[i]) == type(sortKey2[i]) + if sortKey1[i] <# sortKey2[i] + return - 1 + elseif sortKey1[i] ># sortKey2[i] + return 1 + endif + elseif type(sortKey1[i]) == type(0) + return -1 + elseif type(sortKey2[i]) == type(0) + return 1 + endif + let i += 1 + endwhile + + " Keys are identical upto common length. + " The key which has smaller chunks is the lesser one. + if len(sortKey1) < len(sortKey2) + return -1 + elseif len(sortKey1) > len(sortKey2) + return 1 + else + return 0 + endif +endfunction + +" FUNCTION: nerdtree#deprecated(func, [msg]) {{{2 +" Issue a deprecation warning for a:func. If a second arg is given, use this +" as the deprecation message +function! nerdtree#deprecated(func, ...) abort + let msg = a:0 ? a:func . ' ' . a:1 : a:func . ' is deprecated' + + if !exists('s:deprecationWarnings') + let s:deprecationWarnings = {} + endif + if !has_key(s:deprecationWarnings, a:func) + let s:deprecationWarnings[a:func] = 1 + echomsg msg + endif +endfunction + +" FUNCTION: nerdtree#exec(cmd, ignoreAll) {{{2 +" Same as :exec cmd but, if ignoreAll is TRUE, set eventignore=all for the duration +function! nerdtree#exec(cmd, ignoreAll) abort + let old_ei = &eventignore + if a:ignoreAll + set eventignore=all + endif + try + exec a:cmd + finally + let &eventignore = old_ei + endtry +endfunction + +" FUNCTION: nerdtree#has_opt(options, name) {{{2 +function! nerdtree#has_opt(options, name) abort + return has_key(a:options, a:name) && a:options[a:name] ==# 1 +endfunction + +" FUNCTION: nerdtree#loadClassFiles() {{{2 +function! nerdtree#loadClassFiles() abort + runtime lib/nerdtree/path.vim + runtime lib/nerdtree/menu_controller.vim + runtime lib/nerdtree/menu_item.vim + runtime lib/nerdtree/key_map.vim + runtime lib/nerdtree/bookmark.vim + runtime lib/nerdtree/tree_file_node.vim + runtime lib/nerdtree/tree_dir_node.vim + runtime lib/nerdtree/opener.vim + runtime lib/nerdtree/creator.vim + runtime lib/nerdtree/flag_set.vim + runtime lib/nerdtree/nerdtree.vim + runtime lib/nerdtree/ui.vim + runtime lib/nerdtree/event.vim + runtime lib/nerdtree/notifier.vim +endfunction + +" FUNCTION: nerdtree#postSourceActions() {{{2 +function! nerdtree#postSourceActions() abort + call g:NERDTreeBookmark.CacheBookmarks(1) + call nerdtree#ui_glue#createDefaultBindings() + + "load all nerdtree plugins + runtime! nerdtree_plugin/**/*.vim +endfunction + +"FUNCTION: nerdtree#runningWindows(dir) {{{2 +function! nerdtree#runningWindows() abort + return has('win16') || has('win32') || has('win64') +endfunction + +"FUNCTION: nerdtree#runningCygwin(dir) {{{2 +function! nerdtree#runningCygwin() abort + return has('win32unix') +endfunction + +" SECTION: View Functions {{{1 +"============================================================ + +"FUNCTION: nerdtree#echo {{{2 +"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages +" +"Args: +"msg: the message to echo +function! nerdtree#echo(msg) abort + redraw + echomsg empty(a:msg) ? '' : ('NERDTree: ' . a:msg) +endfunction + +"FUNCTION: nerdtree#echoError {{{2 +"Wrapper for nerdtree#echo, sets the message type to errormsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoError(msg) abort + echohl errormsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#echoWarning {{{2 +"Wrapper for nerdtree#echo, sets the message type to warningmsg for this message +"Args: +"msg: the message to echo +function! nerdtree#echoWarning(msg) abort + echohl warningmsg + call nerdtree#echo(a:msg) + echohl normal +endfunction + +"FUNCTION: nerdtree#renderView {{{2 +function! nerdtree#renderView() abort + call b:NERDTree.render() +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim new file mode 100644 index 00000000..fc22f216 --- /dev/null +++ b/sources_non_forked/nerdtree/autoload/nerdtree/ui_glue.vim @@ -0,0 +1,732 @@ +if exists('g:loaded_nerdtree_ui_glue_autoload') + finish +endif +let g:loaded_nerdtree_ui_glue_autoload = 1 + +" FUNCTION: nerdtree#ui_glue#createDefaultBindings() {{{1 +function! nerdtree#ui_glue#createDefaultBindings() abort + let s = '' . s:SID() . '_' + + call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s . 'handleMiddleMouse' }) + call NERDTreeAddKeyMap({ 'key': '', 'scope': 'all', 'callback': s.'handleLeftClick' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': '<2-LeftMouse>', 'scope': 'all', 'callback': s.'activateAll' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'FileNode', 'callback': s.'customOpenFile'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'DirNode', 'callback': s.'customOpenDir'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'Bookmark', 'callback': s.'customOpenBookmark'}) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCustomOpen, 'scope':'all', 'callback': s.'activateAll' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'DirNode', 'callback': s.'activateDirNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'FileNode', 'callback': s.'activateFileNode' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'Bookmark', 'callback': s.'activateBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'Bookmark', 'callback': s.'previewBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapActivateNode, 'scope': 'all', 'callback': s.'activateAll' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'FileNode', 'callback': s.'openHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenSplit, 'scope': 'Bookmark', 'callback': s.'openHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'FileNode', 'callback': s.'openVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenVSplit, 'scope': 'Bookmark', 'callback': s.'openVSplitBookmark' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreview, 'scope': 'FileNode', 'callback': s.'previewNodeCurrent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'FileNode', 'callback': s.'previewNodeHSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeHSplitBookmark' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'FileNode', 'callback': s.'previewNodeVSplit' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapPreviewVSplit, 'scope': 'Bookmark', 'callback': s.'previewNodeVSplitBookmark' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenRecursively, 'scope': 'DirNode', 'callback': s.'openNodeRecursively' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdir, 'scope': 'all', 'callback': s . 'upDirCurrentRootClosed' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapUpdirKeepOpen, 'scope': 'all', 'callback': s . 'upDirCurrentRootOpen' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChangeRoot, 'scope': 'Node', 'callback': s . 'chRoot' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapChdir, 'scope': 'Node', 'callback': s.'chCwd' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapQuit, 'scope': 'all', 'callback': s.'closeTreeWindow' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCWD, 'scope': 'all', 'callback': 'nerdtree#ui_glue#chRootCwd' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefreshRoot, 'scope': 'all', 'callback': s.'refreshRoot' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapRefresh, 'scope': 'Node', 'callback': s.'refreshCurrent' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapHelp, 'scope': 'all', 'callback': s.'displayHelp' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleZoom, 'scope': 'all', 'callback': s.'toggleZoom' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleHidden, 'scope': 'all', 'callback': s.'toggleShowHidden' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFilters, 'scope': 'all', 'callback': s.'toggleIgnoreFilter' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleFiles, 'scope': 'all', 'callback': s.'toggleShowFiles' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapToggleBookmarks, 'scope': 'all', 'callback': s.'toggleShowBookmarks' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseDir, 'scope': 'Node', 'callback': s.'closeCurrentDir' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapCloseChildren, 'scope': 'DirNode', 'callback': s.'closeChildren' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapMenu, 'scope': 'Node', 'callback': s.'showMenu' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpParent, 'scope': 'Node', 'callback': s.'jumpToParent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpFirstChild, 'scope': 'Node', 'callback': s.'jumpToFirstChild' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpLastChild, 'scope': 'Node', 'callback': s.'jumpToLastChild' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpRoot, 'scope': 'all', 'callback': s.'jumpToRoot' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpNextSibling, 'scope': 'Node', 'callback': s.'jumpToNextSibling' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapJumpPrevSibling, 'scope': 'Node', 'callback': s.'jumpToPrevSibling' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Node', 'callback': s . 'openInNewTab' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Node', 'callback': s . 'openInNewTabSilent' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTab, 'scope': 'Bookmark', 'callback': s . 'openInNewTab' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenInTabSilent, 'scope': 'Bookmark', 'callback': s . 'openInNewTabSilent' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'DirNode', 'callback': s.'openExplorer' }) + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapOpenExpl, 'scope': 'FileNode', 'callback': s.'openExplorer' }) + + call NERDTreeAddKeyMap({ 'key': g:NERDTreeMapDeleteBookmark, 'scope': 'Bookmark', 'callback': s.'deleteBookmark' }) +endfunction + + +"SECTION: Interface bindings {{{1 +"============================================================ + +"FUNCTION: s:customOpenFile() {{{1 +" Open file node with the 'custom' key, initially . +function! s:customOpenFile(node) abort + call a:node.activate(s:initCustomOpenArgs().file) +endfunction + +"FUNCTION: s:customOpenDir() {{{1 +" Open directory node with the 'custom' key, initially . +function! s:customOpenDir(node) abort + call s:activateDirNode(a:node, s:initCustomOpenArgs().dir) +endfunction + +"FUNCTION: s:customOpenBookmark() {{{1 +" Open bookmark node with the 'custom' key, initially . +function! s:customOpenBookmark(node) abort + if a:node.path.isDirectory + call a:node.activate(b:NERDTree, s:initCustomOpenArgs().dir) + else + call a:node.activate(b:NERDTree, s:initCustomOpenArgs().file) + endif +endfunction + +"FUNCTION: s:initCustomOpenArgs() {{{1 +function! s:initCustomOpenArgs() abort + let l:defaultOpenArgs = {'file': {'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}, 'dir': {}} + try + let g:NERDTreeCustomOpenArgs = get(g:, 'NERDTreeCustomOpenArgs', {}) + call extend(g:NERDTreeCustomOpenArgs, l:defaultOpenArgs, 'keep') + catch /^Vim(\a\+):E712:/ + call nerdtree#echoWarning('g:NERDTreeCustomOpenArgs is not set properly. Using default value.') + let g:NERDTreeCustomOpenArgs = l:defaultOpenArgs + finally + return g:NERDTreeCustomOpenArgs + endtry +endfunction + +"FUNCTION: s:activateAll() {{{1 +"handle the user activating the updir line +function! s:activateAll() abort + if getline('.') ==# g:NERDTreeUI.UpDirLine() + return nerdtree#ui_glue#upDir(0) + endif +endfunction + +" FUNCTION: s:activateDirNode(directoryNode, options) {{{1 +" Open a directory with optional options +function! s:activateDirNode(directoryNode, ...) abort + + if a:directoryNode.isRoot() && a:directoryNode.isOpen + call nerdtree#echo('cannot close tree root') + return + endif + + call a:directoryNode.activate((a:0 > 0) ? a:1 : {}) +endfunction + +"FUNCTION: s:activateFileNode() {{{1 +"handle the user activating a tree node +function! s:activateFileNode(node) abort + call a:node.activate({'reuse': 'all', 'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()}) +endfunction + +"FUNCTION: s:activateBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:activateBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'p', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) +endfunction + +" FUNCTION: nerdtree#ui_glue#bookmarkNode(name) {{{1 +" Associate the current node with the given name +function! nerdtree#ui_glue#bookmarkNode(...) abort + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode !=# {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(0) + endif + try + call currentNode.bookmark(name) + call b:NERDTree.render() + catch /^NERDTree.IllegalBookmarkNameError/ + call nerdtree#echo('bookmark names must not contain spaces') + endtry + else + call nerdtree#echo('select a node first') + endif +endfunction + +" FUNCTION: s:chCwd(node) {{{1 +function! s:chCwd(node) abort + try + call a:node.path.changeToDir() + catch /^NERDTree.PathChangeError/ + call nerdtree#echoWarning('could not change cwd') + endtry +endfunction + +" FUNCTION: s:chRoot(node) {{{1 +" changes the current root to the selected one +function! s:chRoot(node) abort + call b:NERDTree.changeRoot(a:node) +endfunction + +" FUNCTION: s:nerdtree#ui_glue#chRootCwd() {{{1 +" Change the NERDTree root to match the current working directory. +function! nerdtree#ui_glue#chRootCwd() abort + NERDTreeCWD +endfunction + +" FUNCTION: nnerdtree#ui_glue#clearBookmarks(bookmarks) {{{1 +function! nerdtree#ui_glue#clearBookmarks(bookmarks) abort + if a:bookmarks ==# '' + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode !=# {} + call currentNode.clearBookmarks() + endif + else + for name in split(a:bookmarks, ' ') + let bookmark = g:NERDTreeBookmark.BookmarkFor(name) + call bookmark.delete() + endfor + endif + call b:NERDTree.root.refresh() + call b:NERDTree.render() +endfunction + +" FUNCTION: s:closeChildren(node) {{{1 +" closes all childnodes of the current node +function! s:closeChildren(node) abort + call a:node.closeChildren() + call b:NERDTree.render() + call a:node.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:closeCurrentDir(node) {{{1 +" Close the parent directory of the current node. +function! s:closeCurrentDir(node) abort + + if a:node.isRoot() + call nerdtree#echo('cannot close parent of tree root') + return + endif + + let l:parent = a:node.parent + + while l:parent.isCascadable() + let l:parent = l:parent.parent + endwhile + + if l:parent.isRoot() + call nerdtree#echo('cannot close tree root') + return + endif + + call l:parent.close() + call b:NERDTree.render() + call l:parent.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:closeTreeWindow() {{{1 +" close the tree window +function! s:closeTreeWindow() abort + if b:NERDTree.isWinTree() && b:NERDTree.previousBuf() !=# -1 + exec 'buffer ' . b:NERDTree.previousBuf() + else + if winnr('$') > 1 + call g:NERDTree.Close() + else + call nerdtree#echo('Cannot close last window') + endif + endif +endfunction + +" FUNCTION: s:deleteBookmark(bookmark) {{{1 +" Prompt the user to confirm the deletion of the selected bookmark. +function! s:deleteBookmark(bookmark) abort + let l:message = 'Delete the bookmark "' . a:bookmark.name + \ . '" from the bookmark list?' + + let l:choices = "&Yes\n&No" + + echo | redraw + let l:selection = confirm(l:message, l:choices, 1, 'Warning') + + if l:selection !=# 1 + call nerdtree#echo('bookmark not deleted') + return + endif + + try + call a:bookmark.delete() + silent call b:NERDTree.root.refresh() + call b:NERDTree.render() + echo | redraw + catch /^NERDTree/ + call nerdtree#echoWarning('could not remove bookmark') + endtry +endfunction + +" FUNCTION: s:displayHelp() {{{1 +" toggles the help display +function! s:displayHelp() abort + call b:NERDTree.ui.toggleHelp() + call b:NERDTree.render() + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:findAndRevealPath(pathStr) {{{1 +function! s:findAndRevealPath(pathStr) abort + let l:pathStr = !empty(a:pathStr) ? a:pathStr : expand('%:p') + let l:revealOpts = {} + + if empty(l:pathStr) + call nerdtree#echoWarning('no file for the current buffer') + return + endif + + if !filereadable(l:pathStr) + let l:pathStr = fnamemodify(l:pathStr, ':h') + let l:revealOpts['open'] = 1 + endif + + try + let l:pathStr = g:NERDTreePath.Resolve(l:pathStr) + let l:pathObj = g:NERDTreePath.New(l:pathStr) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echoWarning('invalid path') + return + endtry + + if !g:NERDTree.ExistsForTab() + try + let l:cwd = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('current directory does not exist.') + let l:cwd = l:pathObj.getParent() + endtry + + if l:pathObj.isUnder(l:cwd) + call g:NERDTreeCreator.CreateTabTree(l:cwd.str()) + else + call g:NERDTreeCreator.CreateTabTree(l:pathObj.getParent().str()) + endif + else + NERDTreeFocus + + if !l:pathObj.isUnder(b:NERDTree.root.path) + call s:chRoot(g:NERDTreeDirNode.New(l:pathObj.getParent(), b:NERDTree)) + endif + endif + + if l:pathObj.isHiddenUnder(b:NERDTree.root.path) + call b:NERDTree.ui.setShowHidden(1) + endif + + let l:node = b:NERDTree.root.reveal(l:pathObj, l:revealOpts) + call b:NERDTree.render() + call l:node.putCursorHere(1, 0) +endfunction + +"FUNCTION: s:handleLeftClick() {{{1 +"Checks if the click should open the current node +function! s:handleLeftClick() abort + let currentNode = g:NERDTreeFileNode.GetSelected() + if currentNode !=# {} + + "the dir arrows are multibyte chars, and vim's string functions only + "deal with single bytes - so split the line up with the hack below and + "take the line substring manually + let line = split(getline(line('.')), '\zs') + let startToCur = '' + for i in range(0,len(line)-1) + let startToCur .= line[i] + endfor + + if currentNode.path.isDirectory + if startToCur =~# g:NERDTreeUI.MarkupReg() && startToCur =~# '[+~'.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.'] \?$' + call currentNode.activate() + return + endif + endif + + if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 + let char = strpart(startToCur, strlen(startToCur)-1, 1) + if char !~# g:NERDTreeUI.MarkupReg() + if currentNode.path.isDirectory + call currentNode.activate() + else + call currentNode.activate({'reuse': 'all', 'where': 'p', 'keepopen':!nerdtree#closeTreeOnOpen()}) + endif + return + endif + endif + endif +endfunction + +" FUNCTION: s:handleMiddleMouse() {{{1 +function! s:handleMiddleMouse() abort + + " A middle mouse click does not automatically position the cursor as one + " would expect. Forcing the execution of a regular left mouse click here + " fixes this problem. + execute "normal! \" + + let l:currentNode = g:NERDTreeFileNode.GetSelected() + if empty(l:currentNode) + call nerdtree#echoError('use the pointer to select a node') + return + endif + + if l:currentNode.path.isDirectory + call l:currentNode.openExplorer() + else + call l:currentNode.open({'where': 'h'}) + endif +endfunction + +" FUNCTION: nerdtree#ui_glue#invokeKeyMap(key) {{{1 +"this is needed since I cant figure out how to invoke dict functions from a +"key map +function! nerdtree#ui_glue#invokeKeyMap(key) abort + call g:NERDTreeKeyMap.Invoke(a:key) +endfunction + +" FUNCTION: s:jumpToFirstChild(node) {{{1 +function! s:jumpToFirstChild(node) abort + call s:jumpToChild(a:node, 0) +endfunction + +" FUNCTION: s:jumpToLastChild(node) {{{1 +function! s:jumpToLastChild(node) abort + call s:jumpToChild(a:node, 1) +endfunction + +" FUNCTION: s:jumpToChild(node, last) {{{1 +" Jump to the first or last child node at the same file system level. +" +" Args: +" node: the node on which the cursor currently sits +" last: 1 (true) if jumping to last child, 0 (false) if jumping to first +function! s:jumpToChild(node, last) abort + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node + + if l:node.isRoot() + return + endif + + let l:parent = l:node.parent + let l:children = l:parent.getVisibleChildren() + + let l:target = a:last ? l:children[len(l:children) - 1] : l:children[0] + + call l:target.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:jumpToParent(node) {{{1 +" Move the cursor to the parent of the specified node. For a cascade, move to +" the parent of the cascade's first node. At the root node, do nothing. +function! s:jumpToParent(node) abort + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node + + if l:node.isRoot() + return + endif + + if empty(l:node.parent) + call nerdtree#echo('could not jump to parent node') + return + endif + + call l:node.parent.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:jumpToRoot() {{{1 +" moves the cursor to the root node +function! s:jumpToRoot() abort + call b:NERDTree.root.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: s:jumpToNextSibling(node) {{{1 +function! s:jumpToNextSibling(node) abort + call s:jumpToSibling(a:node, 1) +endfunction + +" FUNCTION: s:jumpToPrevSibling(node) {{{1 +function! s:jumpToPrevSibling(node) abort + call s:jumpToSibling(a:node, 0) +endfunction + +" FUNCTION: s:jumpToSibling(node, forward) {{{1 +" Move the cursor to the next or previous node at the same file system level. +" +" Args: +" node: the node on which the cursor currently sits +" forward: 0 to jump to previous sibling, 1 to jump to next sibling +function! s:jumpToSibling(node, forward) abort + let l:node = a:node.path.isDirectory ? a:node.getCascadeRoot() : a:node + let l:sibling = l:node.findSibling(a:forward) + + if empty(l:sibling) + return + endif + + call l:sibling.putCursorHere(1, 0) + call b:NERDTree.ui.centerView() +endfunction + +" FUNCTION: nerdtree#ui_glue#openBookmark(name) {{{1 +" Open the Bookmark that has the specified name. This function provides the +" implementation for the :OpenBookmark command. +function! nerdtree#ui_glue#openBookmark(name) abort + try + let l:bookmark = g:NERDTreeBookmark.BookmarkFor(a:name) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echoError('bookmark "' . a:name . '" not found') + return + endtry + if l:bookmark.path.isDirectory + call l:bookmark.open(b:NERDTree) + return + endif + + call l:bookmark.open(b:NERDTree, s:initCustomOpenArgs().file) +endfunction + +" FUNCTION: s:openHSplit(target) {{{1 +function! s:openHSplit(target) abort + call a:target.activate({'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()}) +endfunction + +" FUNCTION: s:openVSplit(target) {{{1 +function! s:openVSplit(target) abort + call a:target.activate({'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()}) +endfunction + +"FUNCTION: s:openHSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openHSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'h', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) +endfunction + +"FUNCTION: s:openVSplitBookmark(bookmark) {{{1 +"handle the user activating a bookmark +function! s:openVSplitBookmark(bm) abort + call a:bm.activate(b:NERDTree, !a:bm.path.isDirectory ? {'where': 'v', 'keepopen': !nerdtree#closeTreeOnOpen()} : {}) +endfunction + +" FUNCTION: s:previewHSplitBookmark(bookmark) {{{1 +function! s:previewNodeHSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'h', 'keepopen': 1} : {}) +endfunction + +" FUNCTION: s:previewVSplitBookmark(bookmark) {{{1 +function! s:previewNodeVSplitBookmark(bookmark) abort + call a:bookmark.activate(b:NERDTree, !a:bookmark.path.isDirectory ? {'stay': 1, 'where': 'v', 'keepopen': 1} : {}) +endfunction + +" FUNCTION: s:openExplorer(node) {{{1 +function! s:openExplorer(node) abort + call a:node.openExplorer() +endfunction + +" FUNCTION: s:openInNewTab(target) {{{1 +function! s:openInNewTab(target) abort + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen()}) + call l:opener.open(a:target) +endfunction + +" FUNCTION: s:openInNewTabSilent(target) {{{1 +function! s:openInNewTabSilent(target) abort + let l:opener = g:NERDTreeOpener.New(a:target.path, {'where': 't', 'keepopen': !nerdtree#closeTreeOnOpen(), 'stay': 1}) + call l:opener.open(a:target) +endfunction + +" FUNCTION: s:openNodeRecursively(node) {{{1 +function! s:openNodeRecursively(node) abort + call nerdtree#echo('Recursively opening node. Please wait...') + call a:node.openRecursively() + call b:NERDTree.render() + call nerdtree#echo('') +endfunction + +" FUNCTION: s:previewBookmark(bookmark) {{{1 +function! s:previewBookmark(bookmark) abort + if a:bookmark.path.isDirectory + execute 'NERDTreeFind '.a:bookmark.path.str() + else + call a:bookmark.activate(b:NERDTree, {'stay': 1, 'where': 'p', 'keepopen': 1}) + endif +endfunction + +"FUNCTION: s:previewNodeCurrent(node) {{{1 +function! s:previewNodeCurrent(node) abort + call a:node.open({'stay': 1, 'where': 'p', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeHSplit(node) {{{1 +function! s:previewNodeHSplit(node) abort + call a:node.open({'stay': 1, 'where': 'h', 'keepopen': 1}) +endfunction + +"FUNCTION: s:previewNodeVSplit(node) {{{1 +function! s:previewNodeVSplit(node) abort + call a:node.open({'stay': 1, 'where': 'v', 'keepopen': 1}) +endfunction + +" FUNCTION: nerdtree#ui_glue#revealBookmark(name) {{{1 +" put the cursor on the node associate with the given name +function! nerdtree#ui_glue#revealBookmark(name) abort + try + let targetNode = g:NERDTreeBookmark.GetNodeForName(a:name, 0, b:NERDTree) + call targetNode.putCursorHere(0, 1) + catch /^NERDTree.BookmarkNotFoundError/ + call nerdtree#echo('Bookmark isn''t cached under the current root') + endtry +endfunction + +" FUNCTION: s:refreshRoot() {{{1 +" Reloads the current root. All nodes below this will be lost and the root dir +" will be reloaded. +function! s:refreshRoot() abort + if !g:NERDTree.IsOpen() + return + endif + call nerdtree#echo('Refreshing the root node. This could take a while...') + + let l:curWin = winnr() + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', 1) + call b:NERDTree.root.refresh() + call b:NERDTree.render() + redraw + call nerdtree#exec(l:curWin . 'wincmd w', 1) + call nerdtree#echo('') +endfunction + +" FUNCTION: s:refreshCurrent(node) {{{1 +" refreshes the root for the current node +function! s:refreshCurrent(node) abort + let node = a:node + if !node.path.isDirectory + let node = node.parent + endif + + call nerdtree#echo('Refreshing node. This could take a while...') + call node.refresh() + call b:NERDTree.render() + call nerdtree#echo('') +endfunction + +" FUNCTION: nerdtree#ui_glue#setupCommands() {{{1 +function! nerdtree#ui_glue#setupCommands() abort + command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreateTabTree('') + command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.ToggleTabTree('') + command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close() + command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreateTabTree('') + command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror() + command! -n=? -complete=file -bar NERDTreeFind call s:findAndRevealPath('') + command! -n=0 -bar NERDTreeRefreshRoot call s:refreshRoot() + command! -n=0 -bar NERDTreeFocus call NERDTreeFocus() + command! -n=0 -bar NERDTreeCWD call NERDTreeCWD() +endfunction + +" Function: s:SID() {{{1 +function! s:SID() abort + if !exists('s:sid') + let s:sid = matchstr(expand(''), '\zs\d\+\ze_SID$') + endif + return s:sid +endfun + +" FUNCTION: s:showMenu(node) {{{1 +function! s:showMenu(node) abort + let mc = g:NERDTreeMenuController.New(g:NERDTreeMenuItem.AllEnabled()) + call mc.showMenu() +endfunction + +" FUNCTION: s:toggleIgnoreFilter() {{{1 +function! s:toggleIgnoreFilter() abort + call b:NERDTree.ui.toggleIgnoreFilter() +endfunction + +" FUNCTION: s:toggleShowBookmarks() {{{1 +function! s:toggleShowBookmarks() abort + call b:NERDTree.ui.toggleShowBookmarks() +endfunction + +" FUNCTION: s:toggleShowFiles() {{{1 +function! s:toggleShowFiles() abort + call b:NERDTree.ui.toggleShowFiles() +endfunction + +" FUNCTION: s:toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:toggleShowHidden() abort + call b:NERDTree.ui.toggleShowHidden() +endfunction + +" FUNCTION: s:toggleZoom() {{{1 +function! s:toggleZoom() abort + call b:NERDTree.ui.toggleZoom() +endfunction + +" FUNCTION: nerdtree#ui_glue#upDir(preserveState) {{{1 +" Move the NERDTree up one level. +" +" Args: +" preserveState: if 1, the current root is left open when the new tree is +" rendered; if 0, the current root node is closed +function! nerdtree#ui_glue#upDir(preserveState) abort + + try + call b:NERDTree.root.cacheParent() + catch /^NERDTree.CannotCacheParentError/ + call nerdtree#echo('already at root directory') + return + endtry + + let l:oldRoot = b:NERDTree.root + let l:newRoot = b:NERDTree.root.parent + + call l:newRoot.open() + call l:newRoot.transplantChild(l:oldRoot) + + if !a:preserveState + call l:oldRoot.close() + endif + + call b:NERDTree.changeRoot(l:newRoot) + call l:oldRoot.putCursorHere(0, 0) +endfunction + +" FUNCTION: s:upDirCurrentRootOpen() {{{1 +function! s:upDirCurrentRootOpen() abort + call nerdtree#ui_glue#upDir(1) +endfunction + +" FUNCTION: s:upDirCurrentRootClosed() {{{1 +function! s:upDirCurrentRootClosed() abort + call nerdtree#ui_glue#upDir(0) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/doc/NERDTree.txt b/sources_non_forked/nerdtree/doc/NERDTree.txt new file mode 100644 index 00000000..55c25cd1 --- /dev/null +++ b/sources_non_forked/nerdtree/doc/NERDTree.txt @@ -0,0 +1,1534 @@ +*NERDTree.txt* A tree explorer plugin to rule the Vim world. Bwahahaha!! + + # #### #### ~ + ### \/#|### |/#### ~ + d8 888 ##\/#/ \||/##/_/##/_# ~ + d88 888 ee ,e e, ### \/###|/ \/ # ### ~ + d88888 888 88b d88 88b ##_\_#\_\## | #/###_/_#### ~ + 888 888 888 888 , ## #### # \ #| / #### ##/## ~ + 888 888 888 "YeeP" __#_--###`. |{,###---###-~ ~ + \ % @% ~ + Y88b Y88 888'Y88 888 88e 888 88e \%@% 88P'888'Y88 ~ + Y88b Y8 888 ,'Y 888 888D 888 888b %o% P' 888 'Y 888,8, ,e e, ,e e, ~ + b Y88b Y 888C8 888 88" 888 8888D %@% 888 888 " d88 88b d88 88b ~ + 8b Y88b 888 ",d 888 b, 888 888P %@% 888 888 888 , 888 , ~ + 88b Y88b 888,d88 888 88b, 888 88" %@% 888 888 "YeeP" "YeeP" ~ + , -=-%{@%-^- _ ~ + ejm `} Reference Manual ~ + { ~ +============================================================================== +CONTENTS *NERDTree-contents* + + 1.Intro...................................|NERDTree| + 2.Functionality provided..................|NERDTreeFunctionality| + 2.1.Global commands...................|NERDTreeGlobalCommands| + 2.2.Bookmarks.........................|NERDTreeBookmarks| + 2.2.1.The bookmark table..........|NERDTreeBookmarkTable| + 2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands| + 2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks| + 2.3.NERDTree mappings.................|NERDTreeMappings| + 2.4.The NERDTree menu.................|NERDTreeMenu| + 3.Settings................................|NERDTreeSettings| + 3.1.Settings summary..................|NERDTreeSettingsSummary| + 3.2.Settings details..................|NERDTreeSettingsDetails| + 4.The NERDTree API........................|NERDTreeAPI| + 4.1.Key map API.......................|NERDTreeKeymapAPI| + 4.2.Menu API..........................|NERDTreeMenuAPI| + 4.3.Menu API..........................|NERDTreeAddPathFilter()| + 4.4.Path Listener API.................|NERDTreePathListenerAPI| + 5.About...................................|NERDTreeAbout| + 6.License.................................|NERDTreeLicense| + +============================================================================== +1. Intro *NERDTree* + +What is this "NERDTree"?? + +The NERDTree allows you to explore your filesystem and to open files and +directories. It presents the filesystem to you in the form of a tree which you +manipulate with the keyboard and/or mouse. It also allows you to perform +simple filesystem operations. + +The following features and functionality are provided by the NERDTree: + * Files and directories are displayed in a hierarchical tree structure + * Different highlighting is provided for the following types of nodes: + * files + * directories + * sym-links + * windows .lnk files + * read-only files + * executable files + * Many (customisable) mappings are provided to manipulate the tree: + * Mappings to open/close/explore directory nodes + * Mappings to open files in new/existing windows/tabs + * Mappings to change the current root of the tree + * Mappings to navigate around the tree + * ... + * Directories and files can be bookmarked. + * Most NERDTree navigation can also be done with the mouse + * Filtering of tree content (can be toggled at runtime) + * custom file filters to prevent e.g. vim backup files being displayed + * optional displaying of hidden files (. files) + * files can be "turned off" so that only directories are displayed + * The position and size of the NERDTree window can be customised + * The order in which the nodes in the tree are listed can be customised. + * A model of your filesystem is created/maintained as you explore it. This + has several advantages: + * All filesystem information is cached and is only re-read on demand + * If you revisit a part of the tree that you left earlier in your + session, the directory nodes will be opened/closed as you left them + * The script remembers the cursor position and window position in the NERD + tree so you can toggle it off (or just close the tree window) and then + reopen it (with NERDTreeToggle) the NERDTree window will appear exactly + as you left it + * You can have a separate NERDTree for each tab, share trees across tabs, + or a mix of both. + * By default the script overrides the default file browser (netrw), so if + you :edit a directory a (slightly modified) NERDTree will appear in the + current window + * A programmable menu system is provided (simulates right clicking on a + node) + * one default menu plugin is provided to perform basic filesystem + operations (create/delete/move/copy files/directories) + * There's an API for adding your own keymappings + + +============================================================================== +2. Functionality provided *NERDTreeFunctionality* + +------------------------------------------------------------------------------ +2.1. Global Commands *NERDTreeGlobalCommands* + +:NERDTree [ | ] *:NERDTree* + Opens a fresh NERDTree. The root of the tree depends on the argument + given. There are 3 cases: If no argument is given, the current directory + will be used. If a directory is given, that will be used. If a bookmark + name is given, the corresponding directory will be used. For example: > + :NERDTree /home/marty/vim7/src + :NERDTree foo (foo is the name of a bookmark) +< +:NERDTreeVCS [ | ] *:NERDTreeVCS* + Like |:NERDTree|, but searches up the directory tree to find the top of + the version control system repository, and roots the NERDTree there. It + works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A + couple of examples: > + :NERDTreeVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) + :NERDTreeVCS (opens root of repository containing CWD) +< +:NERDTreeFromBookmark *:NERDTreeFromBookmark* + Opens a fresh NERDTree with the root initialized to the directory for + . The only reason to use this command over :NERDTree is for + the completion (which is for bookmarks rather than directories). + +:NERDTreeToggle [ | ] *:NERDTreeToggle* + If a NERDTree already exists for this tab, it is reopened and rendered + again. If or is given, the root of NERDTree + is set to that path. If no NERDTree exists for this tab then this command + acts the same as the |:NERDTree| command. + +:NERDTreeToggleVCS [ | ] *:NERDTreeToggleVCS* + Like |:NERDTreeToggle|, but searches up the directory tree to find the top of + the version control system repository, and roots the NERDTree there. It + works with Git, Subversion, Mercurial, Bazaar, and Darcs repositories. A + couple of examples: > + :NERDTreeToggleVCS /home/marty/nerdtree/doc (opens /home/marty/nerdtree) + :NERDTreeToggleVCS (opens root of repository containing CWD) + +:NERDTreeFocus *:NERDTreeFocus* + Opens (or reopens) the NERDTree if it is not currently visible; + otherwise, the cursor is moved to the already-open NERDTree. + +:NERDTreeMirror *:NERDTreeMirror* + Shares an existing NERDTree, from another tab, in the current tab. + Changes made to one tree are reflected in both as they are actually the + same buffer. + + If only one other NERDTree exists, that tree is automatically mirrored. + If more than one exists, the script will ask which tree to mirror. + +:NERDTreeClose *:NERDTreeClose* + Close the NERDTree in this tab. + +:NERDTreeFind [] *:NERDTreeFind* + Without the optional argument, find and reveal the file for the active + buffer in the NERDTree window. With the argument, find and + reveal the specified path. + + Focus will be shifted to the NERDTree window, and the cursor will be + placed on the tree node for the determined path. If a NERDTree for the + current tab does not exist, a new one will be initialized. + +:NERDTreeCWD *:NERDTreeCWD* + Change the NERDTree root to the current working directory. If no + NERDTree exists for this tab, a new one is opened. + +:NERDTreeRefreshRoot *:NERDTreeRefreshRoot* + Refreshes the NERDTree root node. + +------------------------------------------------------------------------------ +2.2. Bookmarks *NERDTreeBookmarks* + +Bookmarks in the NERDTree are a way to tag files or directories of interest. +For example, you could use bookmarks to tag all of your project directories. + +------------------------------------------------------------------------------ +2.2.1. The Bookmark Table *NERDTreeBookmarkTable* + +If the bookmark table is active (see |NERDTree-B| and +|NERDTreeShowBookmarks|), it will be rendered above the tree. You can double +click bookmarks or use the |NERDTree-o| mapping to activate them. See also, +|NERDTree-t| and |NERDTree-T| + +------------------------------------------------------------------------------ +2.2.2. Bookmark commands *NERDTreeBookmarkCommands* + +Note: The following commands are only available within the NERDTree buffer. + +:Bookmark [] + Bookmark the current node as . If there is already a + bookmark, it is overwritten. must not contain spaces. + If is not provided, it defaults to the file or directory name. + For directories, a trailing slash is present. + +:BookmarkToRoot + Make the directory corresponding to the new root. If a treenode + corresponding to is already cached somewhere in the tree then + the current tree will be used, otherwise a fresh tree will be opened. + Note that if points to a file then its parent will be used + instead. + +:RevealBookmark + If the node is cached under the current root then it will be revealed + (i.e. directory nodes above it will be opened) and the cursor will be + placed on it. + +:OpenBookmark + The Bookmark named is opened as if |NERDTree-o| was applied to + its entry in the Bookmark table. If the Bookmark points to a directory, + it is made the new root of the current NERDTree. If the Bookmark points + to a file, that file is opened for editing in another window. + +:ClearBookmarks [] + Remove all the given bookmarks. If no bookmarks are given then remove all + bookmarks on the current node. + +:ClearAllBookmarks + Remove all bookmarks. + +:EditBookmarks + Opens the bookmarks file for manual editing, e.g. for removing invalid + bookmarks. + +:ReadBookmarks + Re-read the bookmarks in the |NERDTreeBookmarksFile|. + +See also |:NERDTree| and |:NERDTreeFromBookmark|. + +------------------------------------------------------------------------------ +2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks* + +If invalid bookmarks are detected, the script will issue an error message and +the invalid bookmarks will become unavailable for use. + +These bookmarks will still be stored in the bookmarks file (see +|NERDTreeBookmarksFile|), down at the bottom. There will always be a blank line +after the valid bookmarks but before the invalid ones. + +Each line in the bookmarks file represents one bookmark. The proper format is: + + +You can use the :EditBookmarks command to open the bookmarks file for editing. +After you have corrected any invalid bookmarks, either restart vim, or run +:ReadBookmarks from the NERDTree window. + +------------------------------------------------------------------------------ +2.3. NERDTree Mappings *NERDTreeMappings* + +Default~ +Key Description help-tag~ + +o........Open files, directories and bookmarks......................|NERDTree-o| +go.......Open selected file, but leave cursor in the NERDTree......|NERDTree-go| + Find selected bookmark directory in current NERDTree +t........Open selected node/bookmark in a new tab...................|NERDTree-t| +T........Same as 't' but keep the focus on the current tab..........|NERDTree-T| +i........Open selected file in a split window.......................|NERDTree-i| +gi.......Same as i, but leave the cursor on the NERDTree...........|NERDTree-gi| +s........Open selected file in a new vsplit.........................|NERDTree-s| +gs.......Same as s, but leave the cursor on the NERDTree...........|NERDTree-gs| +.....User-definable custom open action.......................|NERDTree-| +O........Recursively open the selected directory....................|NERDTree-O| +x........Close the current nodes parent.............................|NERDTree-x| +X........Recursively close all children of the current node.........|NERDTree-X| +e........Edit the current directory.................................|NERDTree-e| + +double-click....same as |NERDTree-o|. +middle-click....same as |NERDTree-i| for files, and |NERDTree-e| for directories. + +D........Delete the current bookmark ...............................|NERDTree-D| + +P........Jump to the root node......................................|NERDTree-P| +p........Jump to current nodes parent...............................|NERDTree-p| +K........Jump up inside directories at the current tree depth.......|NERDTree-K| +J........Jump down inside directories at the current tree depth.....|NERDTree-J| +....Jump down to next sibling of the current directory.......|NERDTree-C-J| +....Jump up to previous sibling of the current directory.....|NERDTree-C-K| + +C........Change the tree root to the selected directory.............|NERDTree-C| +u........Move the tree root up one directory........................|NERDTree-u| +U........Same as 'u' except the old root node is left open..........|NERDTree-U| +r........Recursively refresh the current directory..................|NERDTree-r| +R........Recursively refresh the current root.......................|NERDTree-R| +m........Display the NERDTree menu..................................|NERDTree-m| +cd.......Change the CWD to the directory of the selected node......|NERDTree-cd| +CD.......Change tree root to the CWD...............................|NERDTree-CD| + +I........Toggle whether hidden files displayed......................|NERDTree-I| +f........Toggle whether the file filters are used...................|NERDTree-f| +F........Toggle whether files are displayed.........................|NERDTree-F| +B........Toggle whether the bookmark table is displayed.............|NERDTree-B| + +q........Close the NERDTree window..................................|NERDTree-q| +A........Zoom (maximize/minimize) the NERDTree window...............|NERDTree-A| +?........Toggle the display of the quick help.......................|NERDTree-?| + +------------------------------------------------------------------------------ + *NERDTree-o* +Default key: o +Map setting: NERDTreeMapActivateNode +Applies to: files and directories. + +If a file node is selected, it is opened in the previous window. + +If a directory is selected it is opened or closed depending on its current +state. + +If a bookmark that links to a directory is selected then that directory +becomes the new root. + +If a bookmark that links to a file is selected then that file is opened in the +previous window. + +------------------------------------------------------------------------------ + *NERDTree-go* +Default key: go +Map setting: NERDTreeMapPreview +Applies to: files. + +If a file node or a bookmark that links to a file is selected, it is opened in +the previous window, but the cursor does not move. + +If a bookmark that links to a directory is selected then that directory +becomes the new root. + +The default key combo for this mapping is "g" + NERDTreeMapActivateNode (see +|NERDTree-o|). + +------------------------------------------------------------------------------ + *NERDTree-t* +Default key: t +Map setting: *NERDTreeMapOpenInTab* +Applies to: files and directories. + +Opens the selected file in a new tab. If a directory is selected, a fresh +NERDTree for that directory is opened in a new tab. + +If a bookmark which points to a directory is selected, open a NERDTree for +that directory in a new tab. If the bookmark points to a file, open that file +in a new tab. + +------------------------------------------------------------------------------ + *NERDTree-T* +Default key: T +Map setting: *NERDTreeMapOpenInTabSilent* +Applies to: files and directories. + +The same as |NERDTree-t| except that the focus is kept in the current tab. + +------------------------------------------------------------------------------ + *NERDTree-i* +Default key: i +Map setting: *NERDTreeMapOpenSplit* +Applies to: files, and bookmarks pointing to files. + +Opens the selected file in a new split window and puts the cursor in the new +window. + +------------------------------------------------------------------------------ + *NERDTree-gi* +Default key: gi +Map setting: *NERDTreeMapPreviewSplit* +Applies to: files, and bookmarks pointing to files. + +The same as |NERDTree-i| except that the cursor is not moved. + +The default key combo for this mapping is "g" + NERDTreeMapOpenSplit (see +|NERDTree-i|). + +------------------------------------------------------------------------------ + *NERDTree-s* +Default key: s +Map setting: *NERDTreeMapOpenVSplit* +Applies to: files, and bookmarks pointing to files. + +Opens the selected file in a new vertically split window and puts the cursor +in the new window. + +------------------------------------------------------------------------------ + *NERDTree-gs* +Default key: gs +Map setting: *NERDTreeMapPreviewVSplit* +Applies to: files, and bookmarks pointing to files. + +The same as |NERDTree-s| except that the cursor is not moved. + +The default key combo for this mapping is "g" + NERDTreeMapOpenVSplit (see +|NERDTree-s|). + +------------------------------------------------------------------------------ + *NERDTree-* +Default key: +Map setting: *NERDTreeMapCustomOpen* +Applies to: files, directories, and bookmarks + +Performs a customized open action on the selected node. This allows the user +to define an action that behaves differently from any of the standard +keys. See |NERDTreeCustomOpenArgs| for more details. +------------------------------------------------------------------------------ + *NERDTree-O* +Default key: O +Map setting: *NERDTreeMapOpenRecursively* +Applies to: directories. + +Recursively opens the selected directory. + +All files and directories are cached, but if a directory would not be +displayed due to file filters (see |NERDTreeIgnore| |NERDTree-f|) or the +hidden file filter (see |NERDTreeShowHidden|) then its contents are not +cached. This is handy, especially if you have .svn directories. + +------------------------------------------------------------------------------ + *NERDTree-x* +Default key: x +Map setting: *NERDTreeMapCloseDir* +Applies to: files and directories. + +Closes the parent of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-X* +Default key: X +Map setting: *NERDTreeMapCloseChildren* +Applies to: directories. + +Recursively closes all children of the selected directory. + +Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. + +------------------------------------------------------------------------------ + *NERDTree-e* +Default key: e +Map setting: *NERDTreeMapOpenExpl* +Applies to: files and directories. + +|:edit|s the selected directory, or the selected file's directory. This could +result in a NERDTree or a netrw being opened, depending on +|NERDTreeHijackNetrw|. + +------------------------------------------------------------------------------ + *NERDTree-D* +Default key: D +Map setting: *NERDTreeMapDeleteBookmark* +Applies to: lines in the bookmarks table + +Deletes the currently selected bookmark. + +------------------------------------------------------------------------------ + *NERDTree-P* +Default key: P +Map setting: *NERDTreeMapJumpRoot* +Applies to: no restrictions. + +Jump to the tree root. + +------------------------------------------------------------------------------ + *NERDTree-p* +Default key: p +Map setting: *NERDTreeMapJumpParent* +Applies to: files and directories. + +Jump to the parent node of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-K* +Default key: K +Map setting: *NERDTreeMapJumpFirstChild* +Applies to: files and directories. + +Jump to the first child of the current nodes parent. + +If the cursor is already on the first node then do the following: + * loop back thru the siblings of the current nodes parent until we find an + open directory with children + * go to the first child of that node + +------------------------------------------------------------------------------ + *NERDTree-J* +Default key: J +Map setting: *NERDTreeMapJumpLastChild* +Applies to: files and directories. + +Jump to the last child of the current nodes parent. + +If the cursor is already on the last node then do the following: + * loop forward thru the siblings of the current nodes parent until we find + an open directory with children + * go to the last child of that node + +------------------------------------------------------------------------------ + *NERDTree-C-J* +Default key: +Map setting: *NERDTreeMapJumpNextSibling* +Applies to: files and directories. + +Jump to the next sibling of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-C-K* +Default key: +Map setting: *NERDTreeMapJumpPrevSibling* +Applies to: files and directories. + +Jump to the previous sibling of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-C* +Default key: C +Map setting: *NERDTreeMapChangeRoot* +Applies to: files and directories. + +Make the selected directory node the new tree root. If a file is selected, its +parent is used. + +------------------------------------------------------------------------------ + *NERDTree-u* +Default key: u +Map setting: *NERDTreeMapUpdir* +Applies to: no restrictions. + +Move the tree root up a directory (like doing a "cd .."). + +------------------------------------------------------------------------------ + *NERDTree-U* +Default key: U +Map setting: *NERDTreeMapUpdirKeepOpen* +Applies to: no restrictions. + +Like |NERDTree-u| except that the old tree root is kept open. + +------------------------------------------------------------------------------ + *NERDTree-r* +Default key: r +Map setting: *NERDTreeMapRefresh* +Applies to: files and directories. + +If a directory is selected, recursively refresh that directory, i.e. scan the +filesystem for changes and represent them in the tree. + +If a file node is selected then the above is done on it's parent. + +------------------------------------------------------------------------------ + *NERDTree-R* +Default key: R +Map setting: *NERDTreeMapRefreshRoot* +Applies to: no restrictions. + +Recursively refresh the tree root. + +------------------------------------------------------------------------------ + *NERDTree-m* +Default key: m +Map setting: *NERDTreeMapMenu* +Applies to: files and directories. + +Display the NERDTree menu. See |NERDTreeMenu| for details. + +------------------------------------------------------------------------------ + *NERDTree-cd* +Default key: cd +Map setting: *NERDTreeMapChdir* +Applies to: files and directories. + +Change Vim's current working directory to that of the selected node. + +------------------------------------------------------------------------------ + *NERDTree-CD* +Default key: CD +Map setting: *NERDTreeMapCWD* +Applies to: no restrictions. + +Change the NERDTree root to Vim's current working directory. + +------------------------------------------------------------------------------ + *NERDTree-I* +Default key: I +Map setting: *NERDTreeMapToggleHidden* +Applies to: no restrictions. + +Toggles whether hidden files (i.e. "dot files") are displayed. + +------------------------------------------------------------------------------ + *NERDTree-f* +Default key: f +Map setting: *NERDTreeMapToggleFilters* +Applies to: no restrictions. + +Toggles whether file filters are used. See |NERDTreeIgnore| for details. + +------------------------------------------------------------------------------ + *NERDTree-F* +Default key: F +Map setting: *NERDTreeMapToggleFiles* +Applies to: no restrictions. + +Toggles whether file nodes are displayed. + +------------------------------------------------------------------------------ + *NERDTree-B* +Default key: B +Map setting: *NERDTreeMapToggleBookmarks* +Applies to: no restrictions. + +Toggles whether the bookmarks table is displayed. + +------------------------------------------------------------------------------ + *NERDTree-q* +Default key: q +Map setting: *NERDTreeMapQuit* +Applies to: no restrictions. + +Closes the NERDTree window. + +------------------------------------------------------------------------------ + *NERDTree-A* +Default key: A +Map setting: *NERDTreeMapToggleZoom* +Applies to: no restrictions. + +Maximize (zoom) and minimize the NERDTree window. + +------------------------------------------------------------------------------ + *NERDTree-?* +Default key: ? +Map setting: *NERDTreeMapHelp* +Applies to: no restrictions. + +Toggles whether the quickhelp is displayed. + +------------------------------------------------------------------------------ + 2.3. The NERDTree menu *NERDTreeMenu* + +The NERDTree has a menu that can be programmed via the an API (see +|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most +file explorers have. + +The script comes with two default menu plugins: exec_menuitem.vim and +fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for +creating/deleting/moving/copying files and directories. exec_menuitem.vim +provides a menu item to execute executable files. + +Related tags: |NERDTree-m| |NERDTreeApi| + +------------------------------------------------------------------------------ + *NERDTreeMenu-j* +Default key: j +Map option: *NERDTreeMenuDown* +Applies to: The NERDTree menu. + +Moves the cursor down. + +------------------------------------------------------------------------------ + *NERDTreeMenu-k* +Default key: k +Map option: *NERDTreeMenuUp* +Applies to: The NERDTree menu. + +Moves the cursor up. + +============================================================================== +3. Customisation *NERDTreeSettings* + + +------------------------------------------------------------------------------ +3.1. Customisation summary *NERDTreeSettingsSummary* + +The plugin provides the following settings that can customise the behaviour +the NERDTree. These settings should be set in your vimrc, using `:let`. + +|loaded_nerd_tree| Turns off the script. + +|NERDTreeAutoCenter| Controls whether the NERDTree window centers + when the cursor moves within a specified + distance to the top/bottom of the window. + +|NERDTreeAutoCenterThreshold| Controls the sensitivity of autocentering. + +|NERDTreeCaseSensitiveSort| Tells the NERDTree whether to be case + sensitive or not when sorting nodes. + +|NERDTreeNaturalSort| Tells the NERDTree whether to use natural sort + order or not when sorting nodes. + +|NERDTreeSortHiddenFirst| Tells the NERDTree whether to take the dot at + the beginning of the hidden file names into + account when sorting nodes. + +|NERDTreeChDirMode| Tells the NERDTree if/when it should change + vim's current working directory. + +|NERDTreeHighlightCursorline| Tell the NERDTree whether to highlight the + current cursor line. + +|NERDTreeHijackNetrw| Tell the NERDTree whether to replace the netrw + autocommands for exploring local directories. + +|NERDTreeIgnore| Tells the NERDTree which files to ignore. + +|NERDTreeRespectWildIgnore| Tells the NERDTree to respect `'wildignore'`. + +|NERDTreeBookmarksFile| Where the bookmarks are stored. + +|NERDTreeBookmarksSort| Control how the Bookmark table is sorted. + +|NERDTreeMarkBookmarks| Render bookmarked nodes with markers. + +|NERDTreeMouseMode| Manage the interpretation of mouse clicks. + +|NERDTreeQuitOnOpen| Closes the tree window or bookmark table after + opening a file. + +|NERDTreeShowBookmarks| Tells the NERDTree whether to display the + bookmarks table on startup. + +|NERDTreeShowFiles| Tells the NERDTree whether to display files in + the tree on startup. + +|NERDTreeShowHidden| Tells the NERDTree whether to display hidden + files on startup. + +|NERDTreeShowLineNumbers| Tells the NERDTree whether to display line + numbers in the tree window. + +|NERDTreeSortOrder| Tell the NERDTree how to sort the nodes in the + tree. + +|NERDTreeStatusline| Set a statusline for NERDTree windows. + +|NERDTreeWinPos| Tells the script where to put the NERDTree + window. + +|NERDTreeWinSize| Sets the window size when the NERDTree is + opened. + +|NERDTreeWinSizeMax| Sets the maximum window size when the NERDTree + is zoomed. + +|NERDTreeMinimalUI| Disables display of the 'Bookmarks' label and + 'Press ? for help' text. + +|NERDTreeMinimalMenu| Use a compact menu that fits on a single line + for adding, copying, deleting, etc + +|NERDTreeCascadeSingleChildDir| + Collapses on the same line directories that have + only one child directory. + +|NERDTreeCascadeOpenSingleChildDir| + Cascade open while selected directory has only + one child that also is a directory. + +|NERDTreeAutoDeleteBuffer| Tells the NERDTree to automatically remove a + buffer when a file is being deleted or renamed + via a context menu command. + +|NERDTreeCreatePrefix| Specify a prefix to be used when creating the + NERDTree window. + +|NERDTreeRemoveFileCmd| Specify a custom shell command to be used when + deleting files. Note that it should include one + space character at the end of the command and it + applies only to files. + +|NERDTreeRemoveDirCmd| Specify a custom shell command to be used when + deleting directories. Note that it should + include one space character at the end of the + command and it applies only to directories. + +|NERDTreeDirArrowCollapsible| These characters indicate when a directory is +|NERDTreeDirArrowExpandable| either collapsible or expandable. + +|NERDTreeNodeDelimiter| A single character that is used to separate the + file or directory name from the rest of the + characters on the line of text. + +|NERDTreeCustomOpenArgs| A dictionary with values that control how a node + is opened with the |NERDTree-| key. + +------------------------------------------------------------------------------ +3.2. Customisation details *NERDTreeSettingsDetails* + +To enable any of the below settings you should put an appropriate > + let = + + let loaded_nerd_tree=1 +< +------------------------------------------------------------------------------ + *NERDTreeAutoCenter* +Values: 0 or 1. +Default: 1 + +If set to 1, the NERDTree window will center around the cursor if it moves to +within |NERDTreeAutoCenterThreshold| lines of the top/bottom of the window. + +This is ONLY done in response to tree navigation mappings, +i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p| +|NERDTree-P| + +The centering is done with a |zz| operation. + +------------------------------------------------------------------------------ + *NERDTreeAutoCenterThreshold* +Values: Any natural number. +Default: 3 + +This setting controls the "sensitivity" of the NERDTree auto centering. See +|NERDTreeAutoCenter| for details. + +------------------------------------------------------------------------------ + *NERDTreeCaseSensitiveSort* +Values: 0 or 1. +Default: 0. + +By default the NERDTree does not sort nodes case sensitively, i.e. nodes +could appear like this: > + bar.c + Baz.c + blarg.c + boner.c + Foo.c +< +But, if you set this setting to 1 then the case of the nodes will be taken +into account. The above nodes would then be sorted like this: > + Baz.c + Foo.c + bar.c + blarg.c + boner.c +< +------------------------------------------------------------------------------ + *NERDTreeNaturalSort* +Values: 0 or 1. +Default: 0. + +By default the NERDTree does not sort nodes in natural sort order, i.e. nodes +could appear like this: > + z1.txt + z10.txt + z100.txt + z11.txt + z110.txt + z2.txt + z20.txt + z3.txt +< +But if you set this setting to 1 then the natural sort order will be used. The +above nodes would then be sorted like this: > + z1.txt + z2.txt + z3.txt + z10.txt + z11.txt + z20.txt + z100.txt + z110.txt +< +------------------------------------------------------------------------------ + *NERDTreeUseTCD* +Values: 0 or 1. +Default: 0. + +By default, NERDTree will use the `:cd` command to change the current working +directory. If this setting is turned on, and the `:tcd` command is available, it +will be used instead. + +------------------------------------------------------------------------------ + *NERDTreeChDirMode* +Values: 0, 1, 2, or 3. +Default: 0. + +Use this setting to tell the script when (if at all) to change the current +working directory (CWD) for vim. + +If it is set to 0 then the CWD is never changed by the NERDTree. + +If set to 1 then the CWD is changed when the NERDTree is first loaded to the +directory it is initialized in. For example, if you start the NERDTree with > + :NERDTree /home/marty/foobar +< +then the CWD will be changed to /home/marty/foobar and will not be changed +again unless you init another NERDTree with a similar command. + +If the setting is set to 2 then it behaves the same as if set to 1 except that +the CWD is changed whenever the tree root is changed. For example, if the CWD +is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new +root then the CWD will become /home/marty/foobar/baz. + +If the set to 3, then it behaves the same as if set to 2, and the CWD is +changed whenever changing tabs to whatever the tree root is on that tab. + +------------------------------------------------------------------------------ + *NERDTreeHighlightCursorline* +Values: 0 or 1. +Default: 1. + +If set to 1, the current cursor line in the NERDTree buffer will be +highlighted. This is done using the `'cursorline'` Vim option. + +------------------------------------------------------------------------------ + *NERDTreeHijackNetrw* +Values: 0 or 1. +Default: 1. + +If set to 1, doing a > + :edit +< +will open up a window level NERDTree instead of a netrw in the target window. + +Window level trees behaves slightly different from a regular trees in the +following respects: + 1. 'o' will open the selected file in the same window as the tree, + replacing it. + 2. you can have one tree per window - instead of per tab. + +------------------------------------------------------------------------------ + *NERDTreeIgnore* +Values: a list of regular expressions. +Default: ['\~$']. + +This setting is used to specify which files the NERDTree should ignore. It +must be a list of regular expressions. When the NERDTree is rendered, any +files/directories that match any of the regex's in NERDTreeIgnore won't be +displayed. + +For example if you put the following line in your vimrc: > + let NERDTreeIgnore=['\.vim$', '\~$'] +< +then all files ending in .vim or ~ will be ignored. + +There are 3 magic flags that can be appended to the end of each regular +expression to specify that the regex should match only filenames, only lowest +level directories, or a full path. These flags are "[[dir]]", "[[file]]", and +"[[path]]". Example: > + let NERDTreeIgnore=['\.d$[[dir]]', '\.o$[[file]]', 'tmp/cache$[[path]]'] +< +This will cause all directories ending in ".d" to be ignored, all files ending +in ".o" to be ignored, and the "cache" subdirectory of any "tmp" directory to +be ignored. All other "cache" directories will be displayed. + +When using the "[[path]]" tag on Windows, make sure you use escaped +backslashes for the separators in the regex, eg. 'Temp\\cache$[[path]]' + +Note: to tell the NERDTree not to ignore any files you must use the following +line: > + let NERDTreeIgnore=[] +< +The file filters can be turned on and off dynamically with the |NERDTree-f| +mapping. + +------------------------------------------------------------------------------ + *NERDTreeRespectWildIgnore* +Values: 0 or 1. +Default: 0. + +If set to 1, the `'wildignore'` setting is respected. + +------------------------------------------------------------------------------ + *NERDTreeBookmarksFile* +Values: a path +Default: $HOME/.NERDTreeBookmarks + +This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. + +------------------------------------------------------------------------------ + *NERDTreeBookmarksSort* +Values: 0, 1, or 2 +Default: 1 + +This setting controls the method by which the list of user bookmarks is +sorted. When sorted, bookmarks will render in alphabetical order by name. + +If set to 0, the bookmarks list is not sorted. +If set to 1, the bookmarks list is sorted in a case-insensitive manner. +If set to 2, the bookmarks list is sorted in a case-sensitive manner. + +------------------------------------------------------------------------------ + *NERDTreeMarkBookmarks* +Values: 0 or 1 +Default: 1 + +If set to 1, Bookmarks will be specially marked whenever the NERDTree is +rendered. Users of the |NERDTreeMinimalUI| setting may prefer to disable +this setting for even less visual clutter. + +------------------------------------------------------------------------------ + *NERDTreeMouseMode* +Values: 1, 2 or 3. +Default: 1. + +If set to 1 then a double click on a node is required to open it. +If set to 2 then a single click will open directory nodes, while a double +click will still be required for file nodes. +If set to 3 then a single click will open any node. + +Note: a double click anywhere on a line that a tree node is on will +activate it, but all single-click activations must be done on name of the node +itself. For example, if you have the following node: > + | | |-application.rb +< +then (to single click activate it) you must click somewhere in +'application.rb'. + +------------------------------------------------------------------------------ + *NERDTreeQuitOnOpen* +Values: 0,1,2 or 3. +Default: 0 + +This setting governs whether the NERDTree window or the bookmarks table closes +after opening a file with the |NERDTree-o|, |NERDTree-i|, |NERDTree-t| and +|NERDTree-T| mappings. + + Value | NERDTree Window Behavior + -------+------------------------------------------------------- + 0 | No change + 1 | Closes after opening a file + 2 | Closes the bookmark table after opening a bookmark + 3(1+2) | Same as both 1 and 2 + +------------------------------------------------------------------------------ + *NERDTreeShowBookmarks* +Values: 0 or 1. +Default: 0. + +If this setting is set to 1 then the bookmarks table will be displayed. + +This setting can be toggled dynamically, per tree, with the |NERDTree-B| +mapping. + +------------------------------------------------------------------------------ + *NERDTreeShowFiles* +Values: 0 or 1. +Default: 1. + +If this setting is set to 1 then files are displayed in the NERDTree. If it +is set to 0 then only directories are displayed. + +This setting can be toggled dynamically, per tree, with the |NERDTree-F| +mapping and is useful for drastically shrinking the tree when you are +navigating to a different part of the tree. + +------------------------------------------------------------------------------ + *NERDTreeShowHidden* +Values: 0 or 1. +Default: 0. + +This setting tells vim whether to display hidden files by default. This +setting can be dynamically toggled, per tree, with the |NERDTree-I| mapping. +Use one of the follow lines for this setting: > + let NERDTreeShowHidden=0 + let NERDTreeShowHidden=1 +< +------------------------------------------------------------------------------ + *NERDTreeShowLineNumbers* +Values: 0 or 1. +Default: 0. + +This setting tells vim whether to display line numbers for the NERDTree +window. Use one of the follow lines for this setting: > + let NERDTreeShowLineNumbers=0 + let NERDTreeShowLineNumbers=1 +< +------------------------------------------------------------------------------ + *NERDTreeSortOrder* +Values: a list of regular expressions. +Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] + +This setting is a list of regular expressions which are used to group or sort +the nodes under their parent. + +For example, if the setting is: > + ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] +< +then all .vim files will be grouped at the top, followed by all .c files then +all .h files. All files containing the string 'foobar' will be placed at the +end. The star is a special flag: it tells the script that every node that +doesn't match any of the other regexps should be placed here. + +If no star is present in NERDTreeSortOrder, then one is automatically +appended to the end of the list. + +The regex '\/$' should be used to match directory nodes. + +Files can also be sorted by 1) the modification timestamp, 2) the size, or 3) +the extension. Directories are always sorted by name. To accomplish this, the +following special flags are used: + [[timestamp]] [[-timestamp]] [[size]] [[-size]] [[extension]] +The hyphen specifies a descending sort; extensions are sorted in ascending +order only. If placed at the beginning of the list, files are sorted according +to these flags first, and then grouped by the remaining items in the list. If +the flags are in any other position of the list, this special sorting is done +secondarily. See examples 4, 5, and 6 below. + +After this sorting is done, the files in each group are sorted alphabetically. + +Examples: > + (1) ['*', '\/$'] + (2) [] + (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] + (4) ['[[-size]]'] + (5) ['\/$', '*', '[[timestamp]]'] + (6) ['foo','\/$','[[extension]]'] +< +1. Directories will appear last, everything else will appear above. +2. Everything will simply appear in alphabetical order. +3. Directories will appear first, then ruby and php. Swap files, bak files + and vim backup files will appear last with everything else preceding them. +4. Everything is sorted by size, largest to smallest, with directories + considered to have size 0 bytes. +5. Directories will appear first alphabetically, followed by files, sorted by + timestamp, oldest first. +6. Files and directories matching 'foo' first, followed by other directories, + then all other files. Each section of files is sorted by file extension. + +------------------------------------------------------------------------------ + *NERDTreeStatusline* +Values: Any valid `'statusline'` setting. +Default: %{exists('b:NERDTree')?b:NERDTree.root.path.str():''} + +Defines the value for the `'statusline'` setting in NERDTree windows. + +Note: The setting is actually applied using |:let-&|, not |:set|, so +escaping spaces is not necessary. + +Setting this to -1 will deactivate it so that your global `'statusline'` +setting is used. + +------------------------------------------------------------------------------ + *NERDTreeWinPos* +Values: "left" or "right" +Default: "left". + +This setting is used to determine where NERDTree window is placed on the +screen. + +This setting makes it possible to use two different explorer plugins +simultaneously. For example, you could have the taglist plugin on the left of +the window and the NERDTree on the right. + +------------------------------------------------------------------------------ + *NERDTreeWinSize* +Values: a positive integer. +Default: 31. + +This setting is used to change the size of the NERDTree when it is loaded. + +------------------------------------------------------------------------------ + *NERDTreeMinimalUI* +Values: 0 or 1 +Default: 0 + +This setting disables the 'Bookmarks' label 'Press ? for help' text. Use one +of the following lines for this setting: > + let NERDTreeMinimalUI=0 + let NERDTreeMinimalUI=1 +< +------------------------------------------------------------------------------ + *NERDTreeMinimalMenu* +Values: 0 or 1 +Default: 0 + +This setting makes NERDTree use a smaller, more compact menu for adding, +copying, deleting nodes. This menu fits on a single line so Vim doesn't need to +scroll down to present it. This setting is recommended for users already +familiar with the menu items. It will look similar to this: + + Menu: [ (a)dd ,m,d,r,o,q,c,l] (Use j/k/enter or shortcut): + +An action can be selected with its shortcut key or with the NERDTreeMenuUp and +NERDTreeMenuDown keys, then pressing enter. + +Use one of the following lines for this setting: > + let NERDTreeMinimalMenu=0 + let NERDTreeMinimalMenu=1 +< +------------------------------------------------------------------------------ + *NERDTreeCascadeSingleChildDir* +Values: 0 or 1 +Default: 1. + +When displaying directory nodes, this setting tells NERDTree to collapse +directories that have only one child. Use one of the following lines for this +setting: > + let NERDTreeCascadeSingleChildDir=0 + let NERDTreeCascadeSingleChildDir=1 +< +------------------------------------------------------------------------------ + *NERDTreeCascadeOpenSingleChildDir* +Values: 0 or 1 +Default: 1. + +When opening directory nodes, this setting tells NERDTree to recursively open +directories that have only one child which is also a directory. NERDTree will +stop when it finds a directory that contains anything but another single +directory. This setting also causes the |NERDTree-x| mapping to close +directories in the same manner. This setting may be useful for Java projects. +Use one of the following lines for this setting: > + let NERDTreeCascadeOpenSingleChildDir=0 + let NERDTreeCascadeOpenSingleChildDir=1 +< +------------------------------------------------------------------------------ + *NERDTreeAutoDeleteBuffer* +Values: 0 or 1 +Default: 0. + +When using a context menu to delete or rename a file you may also want to +delete the buffer which is no more valid. If the setting is not set you will +see a confirmation if you really want to delete an old buffer. If you always +press 'y' then it's worth it to set this setting to 1. Use one of the +following lines for this setting: > + let NERDTreeAutoDeleteBuffer=0 + let NERDTreeAutoDeleteBuffer=1 +< +------------------------------------------------------------------------------ + *NERDTreeCreatePrefix* +Values: Any valid command prefix. +Default: "silent". + +Internally, NERDTree uses the |:edit| command to create a buffer in which to +display its tree view. You can augment this behavior by specifying a prefix +string such as "keepalt" or similar. For example, to have NERDTree create its +tree window using `silent keepalt keepjumps edit`: > + let NERDTreeCreatePrefix='silent keepalt keepjumps' +< +------------------------------------------------------------------------------ + *NERDTreeDirArrowCollapsible* *NERDTreeDirArrowExpandable* +Values: Any single character. +Defaults: Windows: ~ and + Others: ▾ and ▸ + +These characters indicate whether a directory is collapsible or expandable. +Example: > + let NERDTreeDirArrowExpandable=">" + let NERDTreeDirArrowCollapsible="v" +< +They can be set to "\u00a0" to replace the arrows with a non-breaking space. +If you do this you may need to change the node delimiter. See +|NERDTreeNodeDelimiter|. You cannot use the same character for both the arrows +and the delimiter. + +Alternatively, they can be set to '' (an empty string). This removes the +arrows and the single space that follows them, shifting the entire tree two +character positions to the left. + +------------------------------------------------------------------------------ + *NERDTreeNodeDelimiter* +Values: Any single character. +Default: varies (see below) + +This character is used to separate the file or directory name from the rest of +the characters in the line of text. It allows filenames to contain special +characters that are otherwise used in the NERDTree, such as square brackets, +braces, trailing asterisk, and leading space. For more details, see the +responsible pull request: https://github.com/preservim/nerdtree/pull/868. + +The default value of this variable depends on the features compiled into your +vim and the values of |NERDTreeDirArrowCollapsible| and +|NERDTreeDirArrowExpandable|. + * If your vim is compiled with the +conceal feature, it is the "\x07" + (BEL) character, and it is hidden by setting 'conceallevel' to 2. If you + use autocommands, make sure none of them change that setting in the + NERD_Tree_* buffers. + * If your vim does NOT have the +conceal feature and you're using "\u00a0" + (non-breaking space) to hide the directory arrows, "\u00b7" (middle dot) + is used as the default delimiter. + * If neither condition above applies, NERDTree uses "\u00a0" (non-breaking + space) as the default delimiter. + +In the 2nd and 3rd cases, NERDTree will use the Ignore highlight group to +"hide" the delimiter. It should appear as an empty space. + +Other plugins can interfere with these defaults, so if you need to change the +delimiter, be sure to choose a character that won't appear in your filenames +or any of the flags set by your installed NERDTree plugins. The suggestions +below are but a few of the many possibilities. Remember to use double quotes +when specifying by hex or Unicode. > + let NERDTreeNodeDelimiter="\x07" "bell + let NERDTreeNodeDelimiter="\u00b7" "middle dot + let NERDTreeNodeDelimiter="\u00a0" "non-breaking space + let NERDTreeNodeDelimiter="😀" "smiley face +< +------------------------------------------------------------------------------ + *NERDTreeCustomOpenArgs* +Values: A nested dictionary, as described below +Default: {'file': {'reuse': 'all', 'where': 'p'}, 'dir': {}} + +This dictionary contains two keys, 'file' and 'dir', whose values each are +another dictionary. The inner dictionary is a set of parameters used by +|NERDTree-| to open a file or directory. Setting these parameters allows you +to customize the way the node is opened. The default value matches what +|NERDTree-o| does. To change that behavior, use these keys and +values in the inner dictionaries: + +'where': specifies whether the node should be opened in a new split ("h" or + "v"), in a new tab ("t") or, in the last window ("p"). +'reuse': if file is already shown in a window, jump there; takes values + "all", "currenttab", or empty +'keepopen': boolean (0 or 1); if true, the tree window will not be closed +'stay': boolean (0 or 1); if true, remain in tree window after opening + +For example: +To open files and directories (creating a new NERDTree) in a new tab, > + {'file':{'where': 't'}, 'dir':{'where':'t'}} +< +To open a file always in the current tab, and expand directories in place, > + {'file': {'reuse':'currenttab', 'where':'p', 'keepopen':1, 'stay':1}} +< +============================================================================== +4. The NERDTree API *NERDTreeAPI* + +The NERDTree script allows you to add custom key mappings and menu items via +a set of API calls. Any scripts that use this API should be placed in +~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows). + +The script exposes some prototype objects that can be used to manipulate the +tree and/or get information from it: > + g:NERDTreePath + g:NERDTreeDirNode + g:NERDTreeFileNode + g:NERDTreeBookmark +< +See the code/comments in NERD_tree.vim to find how to use these objects. The +following code conventions are used: + * class members start with a capital letter + * instance members start with a lower case letter + * private members start with an underscore + +See this blog post for more details: + http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html + +A number of API functions take a callback argument to call. The callback can +be either a string with the name of a function to call, or a |Funcref| object +which will be called directly. + +------------------------------------------------------------------------------ +4.1. Key map API *NERDTreeKeymapAPI* + +NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* + Adds a new keymapping for all NERDTree buffers. + {options} must be a dictionary, and must contain the following keys: + "key" - the trigger key for the new mapping + "callback" - the function the new mapping will be bound to + "quickhelpText" - the text that will appear in the quickhelp (see + |NERDTree-?|) + "override" - if 1 then this new mapping will override whatever previous + mapping was defined for the key/scope combo. Useful for overriding the + default mappings. + + Additionally, a "scope" argument may be supplied. This constrains the + mapping so that it is only activated if the cursor is on a certain object. + That object is then passed into the handling method. Possible values are: + + "FileNode" .... a file node + "DirNode" ..... a directory node + "Node" ........ a file node OR a directory node + "Bookmark" .... a bookmark + "all" ......... global scope; handler receives no arguments (default) + + Example: > + call NERDTreeAddKeyMap({ + \ 'key': 'foo', + \ 'callback': 'NERDTreeEchoPathHandler', + \ 'quickhelpText': 'echo full path of current node', + \ 'scope': 'DirNode' }) + + function! NERDTreeEchoPathHandler(dirnode) + echo a:dirnode.path.str() + endfunction +< + This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. + It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of + the current directory node. Note this mapping will only fire when the + cursor is on a directory node. + +------------------------------------------------------------------------------ +4.2. Menu API *NERDTreeMenuAPI* + +NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* + Creates and returns a new submenu. + + {options} must be a dictionary and must contain the following keys: + "text" - the text of the submenu that the user will see + "shortcut" - a shortcut key for the submenu (need not be unique) + + The following keys are optional: + "isActiveCallback" - a function that will be called to determine whether + this submenu item will be displayed or not. The callback function must + return 0 or 1. + "parent" - the parent submenu of the new submenu (returned from a previous + invocation of NERDTreeAddSubmenu()). If this key is left out then the new + submenu will sit under the top level menu. + + See below for an example. + +NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* + Adds a new menu item to the NERDTree menu (see |NERDTreeMenu|). + + {options} must be a dictionary and must contain the + following keys: + "text" - the text of the menu item which the user will see + "shortcut" - a shortcut key for the menu item (need not be unique) + "callback" - the function that will be called when the user activates the + menu item. + + The following keys are optional: + "isActiveCallback" - a function that will be called to determine whether + this menu item will be displayed or not. The callback function must return + 0 or 1. + "parent" - if the menu item belongs under a submenu then this key must be + specified. This value for this key will be the object that + was returned when the submenu was created with |NERDTreeAddSubmenu()|. + + See below for an example. + +NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()* + Adds a menu separator (a row of dashes). + + {options} is an optional dictionary that may contain the following keys: + "isActiveCallback" - see description in |NERDTreeAddMenuItem()|. + +Below is an example of the menu API in action. > + call NERDTreeAddMenuSeparator() + + call NERDTreeAddMenuItem({ + \ 'text': 'a (t)op level menu item', + \ 'shortcut': 't', + \ 'callback': 'SomeFunction' }) + + let submenu = NERDTreeAddSubmenu({ + \ 'text': 'a (s)ub menu', + \ 'shortcut': 's' }) + + call NERDTreeAddMenuItem({ + \ 'text': '(n)ested item 1', + \ 'shortcut': 'n', + \ 'callback': 'SomeFunction', + \ 'parent': submenu }) + + call NERDTreeAddMenuItem({ + \ 'text': '(n)ested item 2', + \ 'shortcut': 'n', + \ 'callback': 'SomeFunction', + \ 'parent': submenu }) +< +This will create the following menu: > + -------------------- + a (t)op level menu item + a (s)ub menu +< +Where selecting "a (s)ub menu" will lead to a second menu: > + (n)ested item 1 + (n)ested item 2 +< +When any of the 3 concrete menu items are selected the function "SomeFunction" +will be called. + +------------------------------------------------------------------------------ +4.3 NERDTreeAddPathFilter(callback) *NERDTreeAddPathFilter()* + +Path filters are essentially a more powerful version of |NERDTreeIgnore|. +If the simple regex matching in |NERDTreeIgnore| is not enough then use +|NERDTreeAddPathFilter()| to add a callback function that paths will be +checked against when the decision to ignore them is made. Example > + + call NERDTreeAddPathFilter('MyFilter') + + function! MyFilter(params) + "params is a dict containing keys: 'nerdtree' and 'path' which are + "g:NERDTree and g:NERDTreePath objects + + "return 1 to ignore params['path'] or 0 otherwise + endfunction +< +------------------------------------------------------------------------------ +4.4 Path Listener API *NERDTreePathListenerAPI* + +Use this API if you want to run a callback for events on Path objects. E.G > + + call g:NERDTreePathNotifier.AddListener("init", "MyListener") + + ".... + + function! MyListener(event) + "This function will be called whenever a Path object is created. + + "a:event is an object that contains a bunch of relevant info - + "including the affected path. See lib/nerdtree/event.vim for details. + endfunction +< +Current events supported: + init ~ + refresh ~ + refreshFlags ~ + +------------------------------------------------------------------------------ +NERDTreeRender() *NERDTreeRender()* + Re-renders the NERDTree buffer. Useful if you change the state of the + tree and you want to it to be reflected in the UI. + +============================================================================== +5. About *NERDTreeAbout* + +The author of the NERDTree is a terrible terrible monster called Martyzilla +who gobbles up small children with milk and sugar for breakfast. + +He can be reached at martin.grenfell at gmail dot com. He would love to hear +from you, so feel free to send him suggestions and/or comments about this +plugin. Don't be shy --- the worst he can do is slaughter you and stuff you +in the fridge for later ;) + +Martyzilla recruited two other unwitting accomplices to become his minions in +his quest to conquer the Vim plugin world. While he may still love to receive +your emails, the best way to send suggestions, bug reports, and questions is +to submit an issue at http://github.com/preservim/nerdtree/issues. + +The latest stable and development versions are on Github. + Stable: http://github.com/preservim/nerdtree (master branch) + Development: http://github.com/preservim/nerdtree/branches + +Title Credit: + * http://ascii.co.uk/art/tree + + * Patrick Gillespie's Text ASCII Art Generator + http://patorjk.com/software/taag + http://patorjk.com/software/taag/#p=display&f=Rozzo&t=the%20NERD%20Tree + +============================================================================== +6. License *NERDTreeLicense* + +The NERDTree is released under the wtfpl. +See http://sam.zoy.org/wtfpl/COPYING. + +------------------------------------------------------------------------------ + vim:tw=78:ts=8:ft=help:noet:nospell diff --git a/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim new file mode 100644 index 00000000..37be451c --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/bookmark.vim @@ -0,0 +1,365 @@ +" ============================================================================ +" CLASS: Bookmark +" +" The Bookmark class serves two purposes: +" (1) It is the top-level prototype for new, concrete Bookmark objects. +" (2) It provides an interface for client code to query and manipulate the +" global list of Bookmark objects within the current Vim session. +" ============================================================================ + + +let s:Bookmark = {} +let g:NERDTreeBookmark = s:Bookmark + +" FUNCTION: Bookmark.activate(nerdtree) {{{1 +function! s:Bookmark.activate(nerdtree, ...) + call self.open(a:nerdtree, a:0 ? a:1 : {}) +endfunction + +" FUNCTION: Bookmark.AddBookmark(name, path) {{{1 +" Class method to add a new bookmark to the list, if a previous bookmark exists +" with the same name, just update the path for that bookmark +function! s:Bookmark.AddBookmark(name, path) + for i in s:Bookmark.Bookmarks() + if i.name ==# a:name + let i.path = a:path + return + endif + endfor + call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) +endfunction + +" FUNCTION: Bookmark.Bookmarks() {{{1 +" Class method to get all bookmarks. Lazily initializes the bookmarks global +" variable +function! s:Bookmark.Bookmarks() + if !exists('g:NERDTreeBookmarks') + let g:NERDTreeBookmarks = [] + endif + return g:NERDTreeBookmarks +endfunction + +" FUNCTION: Bookmark.BookmarkExistsFor(name) {{{1 +" class method that returns 1 if a bookmark with the given name is found, 0 +" otherwise +function! s:Bookmark.BookmarkExistsFor(name) + try + call s:Bookmark.BookmarkFor(a:name) + return 1 + catch /^NERDTree.BookmarkNotFoundError/ + return 0 + endtry +endfunction + +" FUNCTION: Bookmark.BookmarkFor(name) {{{1 +" Class method that returns the Bookmark object having the specified name. +" Throws NERDTree.BookmarkNotFoundError if no Bookmark is found. +function! s:Bookmark.BookmarkFor(name) + let l:result = {} + for l:bookmark in s:Bookmark.Bookmarks() + if l:bookmark.name ==# a:name + let l:result = l:bookmark + break + endif + endfor + if empty(l:result) + throw 'NERDTree.BookmarkNotFoundError: "' . a:name . '" not found' + endif + return l:result +endfunction + +" FUNCTION: Bookmark.BookmarkNames() {{{1 +" Class method to return an array of all bookmark names +function! s:Bookmark.BookmarkNames() + let names = [] + for i in s:Bookmark.Bookmarks() + call add(names, i.name) + endfor + return names +endfunction + +" FUNCTION: Bookmark.CacheBookmarks(silent) {{{1 +" Class method to read all bookmarks from the bookmarks file initialize +" bookmark objects for each one. +" +" Args: +" silent - dont echo an error msg if invalid bookmarks are found +function! s:Bookmark.CacheBookmarks(silent) + if filereadable(g:NERDTreeBookmarksFile) + let g:NERDTreeBookmarks = [] + let g:NERDTreeInvalidBookmarks = [] + let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) + let invalidBookmarksFound = 0 + for i in bookmarkStrings + + "ignore blank lines + if i !=# '' + + let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') + let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') + let path = fnamemodify(path, ':p') + + try + let bookmark = s:Bookmark.New(name, g:NERDTreePath.New(path)) + call add(g:NERDTreeBookmarks, bookmark) + catch /^NERDTree.InvalidArgumentsError/ + call add(g:NERDTreeInvalidBookmarks, i) + let invalidBookmarksFound += 1 + endtry + endif + endfor + if invalidBookmarksFound + call s:Bookmark.Write() + if !a:silent + call nerdtree#echo(invalidBookmarksFound . ' invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.') + endif + endif + endif +endfunction + +" FUNCTION: Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) {{{1 +" Class method that indicates the relative position of two bookmarks when +" placed in alphabetical order by name. Case-sensitivity is determined by an +" option. Supports the s:Bookmark.SortBookmarksList() method. +function! s:Bookmark.CompareBookmarksByName(firstBookmark, secondBookmark) + let l:result = 0 + if g:NERDTreeBookmarksSort ==# 1 + if a:firstBookmark.name ? a:secondBookmark.name + let l:result = 1 + endif + elseif g:NERDTreeBookmarksSort ==# 2 + if a:firstBookmark.name <# a:secondBookmark.name + let l:result = -1 + elseif a:firstBookmark.name ># a:secondBookmark.name + let l:result = 1 + endif + endif + return l:result +endfunction + +" FUNCTION: Bookmark.ClearAll() {{{1 +" Class method to delete all bookmarks. +function! s:Bookmark.ClearAll() + for i in s:Bookmark.Bookmarks() + call i.delete() + endfor + call s:Bookmark.Write() +endfunction + +" FUNCTION: Bookmark.delete() {{{1 +" Delete this bookmark. If the node for this bookmark is under the current +" root, then recache bookmarks for its Path object +function! s:Bookmark.delete() + call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) + call s:Bookmark.Write() +endfunction + +" FUNCTION: s:Edit() {{{1 +" opens the NERDTreeBookmarks file for manual editing +function! s:Bookmark.Edit() + call nerdtree#exec('wincmd w', 1) + call nerdtree#exec('edit '.g:NERDTreeBookmarksFile, 1) +endfunction + +" FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 +" Returns the tree node object associated with this Bookmark. +" Throws NERDTree.BookmarkedNodeNotFoundError if the node is not found. +" +" Args: +" searchFromAbsoluteRoot: boolean flag, search from the highest cached node +" if true and from the current tree root if false +function! s:Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) + if a:searchFromAbsoluteRoot + let l:searchRoot = a:nerdtree.root.AbsoluteTreeRoot() + else + let l:searchRoot = a:nerdtree.root + endif + let l:targetNode = l:searchRoot.findNode(self.path) + if empty(l:targetNode) + throw 'NERDTree.BookmarkedNodeNotFoundError: node for bookmark "' . self.name . '" not found' + endif + return l:targetNode +endfunction + +" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) {{{1 +" Class method that returns the tree node object for the Bookmark with the +" given name. Throws NERDTree.BookmarkNotFoundError if a Bookmark with the +" name does not exist. Throws NERDTree.BookmarkedNodeNotFoundError if a +" tree node for the named Bookmark could not be found. +function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot, nerdtree) + let l:bookmark = s:Bookmark.BookmarkFor(a:name) + return l:bookmark.getNode(a:nerdtree, a:searchFromAbsoluteRoot) +endfunction + +" FUNCTION: Bookmark.GetSelected() {{{1 +" returns the Bookmark the cursor is over, or {} +function! s:Bookmark.GetSelected() + let line = getline('.') + let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') + if name !=# line + try + return s:Bookmark.BookmarkFor(name) + catch /^NERDTree.BookmarkNotFoundError/ + return {} + endtry + endif + return {} +endfunction + +" FUNCTION: Bookmark.InvalidBookmarks() {{{1 +" Class method to get all invalid bookmark strings read from the bookmarks +" file +function! s:Bookmark.InvalidBookmarks() + if !exists('g:NERDTreeInvalidBookmarks') + let g:NERDTreeInvalidBookmarks = [] + endif + return g:NERDTreeInvalidBookmarks +endfunction + +" FUNCTION: Bookmark.mustExist() {{{1 +function! s:Bookmark.mustExist() + if !self.path.exists() + call s:Bookmark.CacheBookmarks(1) + throw 'NERDTree.BookmarkPointsToInvalidLocationError: the bookmark "'. + \ self.name .'" points to a non existing location: "'. self.path.str() + endif +endfunction + +" FUNCTION: Bookmark.New(name, path) {{{1 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.New(name, path) + if a:name =~# ' ' + throw 'NERDTree.IllegalBookmarkNameError: illegal name:' . a:name + endif + + let newBookmark = copy(self) + let newBookmark.name = a:name + let newBookmark.path = a:path + return newBookmark +endfunction + +" FUNCTION: Bookmark.open(nerdtree, [options]) {{{1 +"Args: +" +"nerdtree: the tree to load open the bookmark in +" +"A dictionary containing the following keys (all optional): +" 'where': Specifies whether the node should be opened in new split/tab or in +" the previous window. Can be either 'v' (vertical split), 'h' +" (horizontal split), 't' (new tab) or 'p' (previous window). +" 'reuse': if a window is displaying the file then jump the cursor there +" 'keepopen': dont close the tree window +" 'stay': open the file, but keep the cursor in the tree win +" +function! s:Bookmark.open(nerdtree, ...) + let opts = a:0 ? a:1 : {} + + if nerdtree#closeBookmarksOnOpen() + call a:nerdtree.ui.toggleShowBookmarks() + endif + + if self.path.isDirectory && !has_key(opts, 'where') + call self.toRoot(a:nerdtree) + else + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) + endif +endfunction + +" FUNCTION: Bookmark.openInNewTab(options) {{{1 +" Create a new bookmark object with the given name and path object +function! s:Bookmark.openInNewTab(options) + call nerdtree#deprecated('Bookmark.openInNewTab', 'is deprecated, use open() instead') + call self.open(a:options) +endfunction + +" FUNCTION: Bookmark.setPath(path) {{{1 +" makes this bookmark point to the given path +function! s:Bookmark.setPath(path) + let self.path = a:path +endfunction + +" FUNCTION: Bookmark.SortBookmarksList() {{{1 +" Class method that sorts the global list of bookmarks alphabetically by name. +" Note that case-sensitivity is determined by a user option. +function! s:Bookmark.SortBookmarksList() + call sort(s:Bookmark.Bookmarks(), s:Bookmark.CompareBookmarksByName, s:Bookmark) +endfunction + +" FUNCTION: Bookmark.str() {{{1 +" Get the string that should be rendered in the view for this bookmark +function! s:Bookmark.str() + let pathStrMaxLen = winwidth(g:NERDTree.GetWinNum()) - 4 - strdisplaywidth(self.name) + if &number + let pathStrMaxLen = pathStrMaxLen - &numberwidth + endif + + let pathStr = self.path.str({'format': 'UI'}) + if strdisplaywidth(pathStr) > pathStrMaxLen + while strdisplaywidth(pathStr) > pathStrMaxLen && strchars(pathStr) > 0 + let pathStr = substitute(pathStr, '^.', '', '') + endwhile + let pathStr = '<' . pathStr + endif + return '>' . self.name . ' ' . pathStr +endfunction + +" FUNCTION: Bookmark.toRoot(nerdtree) {{{1 +" Set the root of the given NERDTree to the node for this Bookmark. If a node +" for this Bookmark does not exist, a new one is initialized. +function! s:Bookmark.toRoot(nerdtree) + if self.validate() + try + let l:targetNode = self.getNode(a:nerdtree, 1) + call l:targetNode.closeChildren() + catch /^NERDTree.BookmarkedNodeNotFoundError/ + let l:targetNode = g:NERDTreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path, a:nerdtree) + endtry + call a:nerdtree.changeRoot(l:targetNode) + endif +endfunction + +" FUNCTION: Bookmark.ToRoot(name, nerdtree) {{{1 +" Class method that makes the Bookmark with the given name the root of +" specified NERDTree. +function! s:Bookmark.ToRoot(name, nerdtree) + let l:bookmark = s:Bookmark.BookmarkFor(a:name) + call l:bookmark.toRoot(a:nerdtree) +endfunction + +" FUNCTION: Bookmark.validate() {{{1 +function! s:Bookmark.validate() + if self.path.exists() + return 1 + else + call s:Bookmark.CacheBookmarks(1) + call nerdtree#echo(self.name . 'now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.') + return 0 + endif +endfunction + +" FUNCTION: Bookmark.Write() {{{1 +" Class method to write all bookmarks to the bookmarks file +function! s:Bookmark.Write() + let bookmarkStrings = [] + for i in s:Bookmark.Bookmarks() + call add(bookmarkStrings, i.name . ' ' . fnamemodify(i.path.str(), ':~')) + endfor + + "add a blank line before the invalid ones + call add(bookmarkStrings, '') + + for j in s:Bookmark.InvalidBookmarks() + call add(bookmarkStrings, j) + endfor + + try + call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) + catch + call nerdtree#echoError('Failed to write bookmarks file. Make sure g:NERDTreeBookmarksFile points to a valid location.') + endtry +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/creator.vim b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim new file mode 100644 index 00000000..b9d45dc9 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/creator.vim @@ -0,0 +1,402 @@ +" ============================================================================ +" CLASS: Creator +" +" This class is responsible for creating NERDTree instances. The new NERDTree +" may be a tab tree, a window tree, or a mirrored tree. In the process of +" creating a NERDTree, it sets up all of the window and buffer options and key +" mappings etc. +" ============================================================================ + + +let s:Creator = {} +let g:NERDTreeCreator = s:Creator + +" FUNCTION: s:Creator._bindMappings() {{{1 +function! s:Creator._bindMappings() + call g:NERDTreeKeyMap.BindAll() + + command! -buffer -nargs=? Bookmark :call nerdtree#ui_glue#bookmarkNode('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 RevealBookmark :call nerdtree#ui_glue#revealBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=1 OpenBookmark call nerdtree#ui_glue#openBookmark('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=* ClearBookmarks call nerdtree#ui_glue#clearBookmarks('') + command! -buffer -complete=customlist,nerdtree#completeBookmarks -nargs=+ BookmarkToRoot call g:NERDTreeBookmark.ToRoot('', b:NERDTree) + command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() + command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() + command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() + command! -buffer -nargs=0 EditBookmarks call g:NERDTreeBookmark.Edit() +endfunction + +" FUNCTION: s:Creator._broadcastInitEvent() {{{1 +function! s:Creator._broadcastInitEvent() + if exists('#User#NERDTreeInit') + doautocmd User NERDTreeInit + endif +endfunction + +" FUNCTION: s:Creator.BufNamePrefix() {{{1 +function! s:Creator.BufNamePrefix() + return 'NERD_tree_' +endfunction + +" FUNCTION: s:Creator.CreateTabTree(a:name) {{{1 +function! s:Creator.CreateTabTree(name) + let creator = s:Creator.New() + call creator.createTabTree(a:name) +endfunction + +" FUNCTION: s:Creator.createTabTree(a:name) {{{1 +" name: the name of a bookmark or a directory +function! s:Creator.createTabTree(name) + let l:path = self._pathForString(a:name) + + " Abort if an exception was thrown (i.e., if the bookmark or directory + " does not exist). + if empty(l:path) + return + endif + + " Obey the user's preferences for changing the working directory. + if g:NERDTreeChDirMode != 0 + call l:path.changeToDir() + endif + + if g:NERDTree.ExistsForTab() + call g:NERDTree.Close() + call self._removeTreeBufForTab() + endif + + call self._createTreeWin() + call self._createNERDTree(l:path, 'tab') + call b:NERDTree.render() + call b:NERDTree.root.putCursorHere(0, 0) + + call self._broadcastInitEvent() +endfunction + +" FUNCTION: s:Creator.CreateWindowTree(dir) {{{1 +function! s:Creator.CreateWindowTree(dir) + let creator = s:Creator.New() + call creator.createWindowTree(a:dir) +endfunction + +" FUNCTION: s:Creator.createWindowTree(dir) {{{1 +function! s:Creator.createWindowTree(dir) + try + let path = g:NERDTreePath.New(a:dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('Invalid directory name:' . a:dir) + return + endtry + + "we want the directory buffer to disappear when we do the :edit below + setlocal bufhidden=wipe + + let previousBuf = expand('#') + + "we need a unique name for each window tree buffer to ensure they are + "all independent + exec g:NERDTreeCreatePrefix . ' edit ' . self._nextBufferName() + + call self._createNERDTree(path, 'window') + let b:NERDTree._previousBuf = bufnr(previousBuf) + call self._setCommonBufOptions() + + call b:NERDTree.render() + + call self._broadcastInitEvent() +endfunction + +" FUNCTION: s:Creator._createNERDTree(path) {{{1 +function! s:Creator._createNERDTree(path, type) + let b:NERDTree = g:NERDTree.New(a:path, a:type) + + " TODO: This assignment is kept for compatibility reasons. Many other + " plugins use b:NERDTreeRoot instead of b:NERDTree.root. Remove this + " assignment in the future. + let b:NERDTreeRoot = b:NERDTree.root + + call b:NERDTree.root.open() +endfunction + +" FUNCTION: s:Creator.CreateMirror() {{{1 +function! s:Creator.CreateMirror() + let creator = s:Creator.New() + call creator.createMirror() +endfunction + +" FUNCTION: s:Creator.createMirror() {{{1 +function! s:Creator.createMirror() + "get the names off all the nerd tree buffers + let treeBufNames = [] + for i in range(1, tabpagenr('$')) + let nextName = self._tabpagevar(i, 'NERDTreeBufName') + if nextName != -1 && (!exists('t:NERDTreeBufName') || nextName != t:NERDTreeBufName) + call add(treeBufNames, nextName) + endif + endfor + let treeBufNames = self._uniq(treeBufNames) + + "map the option names (that the user will be prompted with) to the nerd + "tree buffer names + let options = {} + let i = 0 + while i < len(treeBufNames) + let bufName = treeBufNames[i] + let treeRoot = getbufvar(bufName, 'NERDTree').root + let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName + let i = i + 1 + endwhile + + "work out which tree to mirror, if there is more than 1 then ask the user + let bufferName = '' + if len(keys(options)) > 1 + let choices = ['Choose a tree to mirror'] + let choices = extend(choices, sort(keys(options))) + let choice = inputlist(choices) + if choice < 1 || choice > len(options) || choice ==# '' + return + endif + + let bufferName = options[sort(keys(options))[choice-1]] + elseif len(keys(options)) ==# 1 + let bufferName = values(options)[0] + else + call nerdtree#echo('No trees to mirror') + return + endif + + if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen() + call g:NERDTree.Close() + endif + + let t:NERDTreeBufName = bufferName + call self._createTreeWin() + exec 'buffer ' . bufferName + call b:NERDTree.ui.restoreScreenState() + if !&hidden + call b:NERDTree.render() + endif +endfunction + +" FUNCTION: s:Creator._createTreeWin() {{{1 +" Initialize the NERDTree window. Open the window, size it properly, set all +" local options, etc. +function! s:Creator._createTreeWin() + let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright ' + let l:splitSize = g:NERDTreeWinSize + + if !g:NERDTree.ExistsForTab() + let t:NERDTreeBufName = self._nextBufferName() + silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new' + silent! execute 'edit ' . t:NERDTreeBufName + silent! execute 'vertical resize '. l:splitSize + else + silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split' + silent! execute 'buffer ' . t:NERDTreeBufName + endif + + setlocal winfixwidth + + call self._setCommonBufOptions() + + if has('patch-7.4.1925') + clearjumps + endif + +endfunction + +" FUNCTION: s:Creator._isBufHidden(nr) {{{1 +function! s:Creator._isBufHidden(nr) + redir => bufs + silent ls! + redir END + + return bufs =~ a:nr . '..h' +endfunction + +" FUNCTION: s:Creator.New() {{{1 +function! s:Creator.New() + let newCreator = copy(self) + return newCreator +endfunction + +" FUNCTION: s:Creator._nextBufferName() {{{1 +" returns the buffer name for the next nerd tree +function! s:Creator._nextBufferName() + let name = s:Creator.BufNamePrefix() . self._nextBufferNumber() + return name +endfunction + +" FUNCTION: s:Creator._nextBufferNumber() {{{1 +" the number to add to the nerd tree buffer name to make the buf name unique +function! s:Creator._nextBufferNumber() + if !exists('s:Creator._NextBufNum') + let s:Creator._NextBufNum = 1 + else + let s:Creator._NextBufNum += 1 + endif + + return s:Creator._NextBufNum +endfunction + +" FUNCTION: s:Creator._pathForString(str) {{{1 +" find a bookmark or adirectory for the given string +function! s:Creator._pathForString(str) + let path = {} + if g:NERDTreeBookmark.BookmarkExistsFor(a:str) + let path = g:NERDTreeBookmark.BookmarkFor(a:str).path + else + let dir = a:str ==# '' ? getcwd() : a:str + + "hack to get an absolute path if a relative path is given + if dir =~# '^\.' + let dir = getcwd() . nerdtree#slash() . dir + endif + + "hack to prevent removing slash if dir is the root of the file system. + if dir !=# '/' + let dir = g:NERDTreePath.Resolve(dir) + endif + + try + let path = g:NERDTreePath.New(dir) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echo('No bookmark or directory found for: ' . a:str) + return {} + endtry + endif + if !path.isDirectory + let path = path.getParent() + endif + + return path +endfunction + +" Function: s:Creator._removeTreeBufForTab() {{{1 +function! s:Creator._removeTreeBufForTab() + let buf = bufnr(t:NERDTreeBufName) + + "if &hidden is not set then it will already be gone + if buf != -1 + + "nerdtree buf may be mirrored/displayed elsewhere + if self._isBufHidden(buf) + exec 'bwipeout ' . buf + endif + + endif + + unlet t:NERDTreeBufName +endfunction + +" FUNCTION: s:Creator._setCommonBufOptions() {{{1 +function! s:Creator._setCommonBufOptions() + + " Options for a non-file/control buffer. + setlocal bufhidden=hide + setlocal buftype=nofile + setlocal noswapfile + + " Options for controlling buffer/window appearance. + setlocal foldcolumn=0 + setlocal foldmethod=manual + setlocal nobuflisted + setlocal nofoldenable + setlocal nolist + setlocal nospell + setlocal nowrap + + if g:NERDTreeShowLineNumbers + setlocal number + else + setlocal nonumber + if v:version >= 703 + setlocal norelativenumber + endif + endif + + iabc + + if g:NERDTreeHighlightCursorline + setlocal cursorline + endif + + call self._setupStatusline() + call self._bindMappings() + + setlocal filetype=nerdtree +endfunction + +" FUNCTION: s:Creator._setupStatusline() {{{1 +function! s:Creator._setupStatusline() + if g:NERDTreeStatusline != -1 + let &l:statusline = g:NERDTreeStatusline + endif +endfunction + +" FUNCTION: s:Creator._tabpagevar(tabnr, var) {{{1 +function! s:Creator._tabpagevar(tabnr, var) + let currentTab = tabpagenr() + let old_ei = &eventignore + set eventignore=all + + try + exec 'tabnext ' . a:tabnr + let v = -1 + if exists('t:' . a:var) + exec 'let v = t:' . a:var + endif + exec 'tabnext ' . currentTab + + finally + let &eventignore = old_ei + endtry + + return v +endfunction + +" FUNCTION: s:Creator.ToggleTabTree(dir) {{{1 +function! s:Creator.ToggleTabTree(dir) + let creator = s:Creator.New() + call creator.toggleTabTree(a:dir) +endfunction + +" FUNCTION: s:Creator.toggleTabTree(dir) {{{1 +" Toggles the NERD tree. I.e if the NERD tree is open, it is closed. If it is +" closed, it is restored or initialized. If dir is not empty, it will be set +" as the new root. +" +" Args: +" dir: the full path for the root node (is used if the NERD tree is being +" initialized, or to change the root to a new dir.) +function! s:Creator.toggleTabTree(dir) + if g:NERDTree.ExistsForTab() + if !g:NERDTree.IsOpen() + call self._createTreeWin() + if !empty(a:dir) && a:dir !=# b:NERDTree.root.path.str() + call self.createTabTree(a:dir) + elseif !&hidden + call b:NERDTree.render() + endif + call b:NERDTree.ui.restoreScreenState() + else + call g:NERDTree.Close() + endif + else + call self.createTabTree(a:dir) + endif +endfunction + +" Function: s:Creator._uniq(list) {{{1 +" returns a:list without duplicates +function! s:Creator._uniq(list) + let uniqlist = [] + for elem in a:list + if index(uniqlist, elem) ==# -1 + let uniqlist += [elem] + endif + endfor + return uniqlist +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/event.vim b/sources_non_forked/nerdtree/lib/nerdtree/event.vim new file mode 100644 index 00000000..964e8ff4 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/event.vim @@ -0,0 +1,13 @@ +"CLASS: Event +"============================================================ +let s:Event = {} +let g:NERDTreeEvent = s:Event + +function! s:Event.New(nerdtree, subject, action, params) abort + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + let newObj.subject = a:subject + let newObj.action = a:action + let newObj.params = a:params + return newObj +endfunction diff --git a/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim b/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim new file mode 100644 index 00000000..75528674 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/flag_set.vim @@ -0,0 +1,58 @@ +"CLASS: FlagSet +"============================================================ +let s:FlagSet = {} +let g:NERDTreeFlagSet = s:FlagSet + +"FUNCTION: FlagSet.addFlag(scope, flag) {{{1 +function! s:FlagSet.addFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + if index(flags, a:flag) == -1 + call add(flags, a:flag) + end +endfunction + +"FUNCTION: FlagSet.clearFlags(scope) {{{1 +function! s:FlagSet.clearFlags(scope) + let self._flags[a:scope] = [] +endfunction + +"FUNCTION: FlagSet._flagsForScope(scope) {{{1 +function! s:FlagSet._flagsForScope(scope) + if !has_key(self._flags, a:scope) + let self._flags[a:scope] = [] + endif + return self._flags[a:scope] +endfunction + +"FUNCTION: FlagSet.New() {{{1 +function! s:FlagSet.New() + let newObj = copy(self) + let newObj._flags = {} + return newObj +endfunction + +"FUNCTION: FlagSet.removeFlag(scope, flag) {{{1 +function! s:FlagSet.removeFlag(scope, flag) + let flags = self._flagsForScope(a:scope) + + let i = index(flags, a:flag) + if i >= 0 + call remove(flags, i) + endif +endfunction + +"FUNCTION: FlagSet.renderToString() {{{1 +function! s:FlagSet.renderToString() + let flagstring = '' + for i in values(self._flags) + let flagstring .= join(i) + endfor + + if len(flagstring) == 0 + return '' + endif + + return '[' . flagstring . ']' +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim new file mode 100644 index 00000000..ed791677 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/key_map.vim @@ -0,0 +1,164 @@ +"CLASS: KeyMap +"============================================================ +let s:KeyMap = {} +let g:NERDTreeKeyMap = s:KeyMap +let s:keyMaps = {} + +"FUNCTION: KeyMap.All() {{{1 +function! s:KeyMap.All() + let sortedKeyMaps = values(s:keyMaps) + call sort(sortedKeyMaps, s:KeyMap.Compare, s:KeyMap) + + return sortedKeyMaps +endfunction + +"FUNCTION: KeyMap.Compare(keyMap1, keyMap2) {{{1 +function! s:KeyMap.Compare(keyMap1, keyMap2) + + if a:keyMap1.key >? a:keyMap2.key + return 1 + endif + + if a:keyMap1.key ' notation, we + " must replace each of the '<' characters with '' to ensure the string + " is not translated into its corresponding keycode during the later part + " of the map command below + " :he <> + let specialNotationRegex = '\m<\([[:alnum:]_-]\+>\)' + if self.key =~# specialNotationRegex + let keymapInvokeString = substitute(self.key, specialNotationRegex, '\1', 'g') + else + let keymapInvokeString = self.key + endif + let keymapInvokeString = escape(keymapInvokeString, '\"') + + let premap = self.key ==# '' ? ' ' : ' ' + + exec 'nnoremap '. self.key . premap . ':call nerdtree#ui_glue#invokeKeyMap("'. keymapInvokeString .'")' +endfunction + +"FUNCTION: KeyMap.Remove(key, scope) {{{1 +function! s:KeyMap.Remove(key, scope) + return remove(s:keyMaps, a:key . a:scope) +endfunction + +"FUNCTION: KeyMap.invoke() {{{1 +"Call the KeyMaps callback function +function! s:KeyMap.invoke(...) + let l:Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) + if a:0 + call l:Callback(a:1) + else + call l:Callback() + endif +endfunction + +"FUNCTION: KeyMap.Invoke() {{{1 +"Find a keymapping for a:key and the current scope invoke it. +" +"Scope is determined as follows: +" * if the cursor is on a dir node then DirNode +" * if the cursor is on a file node then FileNode +" * if the cursor is on a bookmark then Bookmark +" +"If a keymap has the scope of 'all' then it will be called if no other keymap +"is found for a:key and the scope. +function! s:KeyMap.Invoke(key) + + "required because clicking the command window below another window still + "invokes the mapping - but changes the window cursor + "is in first + " + "TODO: remove this check when the vim bug is fixed + if !g:NERDTree.ExistsForBuf() + return {} + endif + + let node = g:NERDTreeFileNode.GetSelected() + if !empty(node) + + "try file node + if !node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, 'FileNode') + if !empty(km) + return km.invoke(node) + endif + endif + + "try dir node + if node.path.isDirectory + let km = s:KeyMap.FindFor(a:key, 'DirNode') + if !empty(km) + return km.invoke(node) + endif + endif + + "try generic node + let km = s:KeyMap.FindFor(a:key, 'Node') + if !empty(km) + return km.invoke(node) + endif + + endif + + "try bookmark + let bm = g:NERDTreeBookmark.GetSelected() + if !empty(bm) + let km = s:KeyMap.FindFor(a:key, 'Bookmark') + if !empty(km) + return km.invoke(bm) + endif + endif + + "try all + let km = s:KeyMap.FindFor(a:key, 'all') + if !empty(km) + return km.invoke() + endif +endfunction + +"FUNCTION: KeyMap.Create(options) {{{1 +function! s:KeyMap.Create(options) + let opts = extend({'scope': 'all', 'quickhelpText': ''}, copy(a:options)) + + "dont override other mappings unless the 'override' option is given + if get(opts, 'override', 0) ==# 0 && !empty(s:KeyMap.FindFor(opts['key'], opts['scope'])) + return + end + + let newKeyMap = copy(self) + let newKeyMap.key = opts['key'] + let newKeyMap.quickhelpText = opts['quickhelpText'] + let newKeyMap.callback = opts['callback'] + let newKeyMap.scope = opts['scope'] + + call s:KeyMap.Add(newKeyMap) +endfunction + +"FUNCTION: KeyMap.Add(keymap) {{{1 +function! s:KeyMap.Add(keymap) + let s:keyMaps[a:keymap.key . a:keymap.scope] = a:keymap +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim new file mode 100644 index 00000000..952c67bd --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/menu_controller.vim @@ -0,0 +1,211 @@ +"CLASS: MenuController +"============================================================ +let s:MenuController = {} +let g:NERDTreeMenuController = s:MenuController + +"FUNCTION: MenuController.New(menuItems) {{{1 +"create a new menu controller that operates on the given menu items +function! s:MenuController.New(menuItems) + let newMenuController = copy(self) + if a:menuItems[0].isSeparator() + let newMenuController.menuItems = a:menuItems[1:-1] + else + let newMenuController.menuItems = a:menuItems + endif + return newMenuController +endfunction + +" FUNCTION: s:MenuController.isMinimal() {{{1 +function! s:MenuController.isMinimal() + return g:NERDTreeMinimalMenu +endfunction + +" FUNCTION: MenuController.showMenu() {{{1 +" Enter the main loop of the NERDTree menu, prompting the user to select +" a menu item. +function! s:MenuController.showMenu() + call self._saveOptions() + + try + let self.selection = 0 + let l:done = 0 + + while !l:done + if has('nvim') + mode + else + redraw! + endif + call self._echoPrompt() + + let l:key = nr2char(getchar()) + let l:done = self._handleKeypress(l:key) + endwhile + finally + call self._restoreOptions() + + " Redraw when Ctrl-C or Esc is received. + if !l:done || self.selection ==# -1 + redraw! + endif + endtry + + if self.selection !=# -1 + let l:m = self._current() + call l:m.execute() + endif +endfunction + +"FUNCTION: MenuController._echoPrompt() {{{1 +function! s:MenuController._echoPrompt() + let navHelp = 'Use ' . g:NERDTreeMenuDown . '/' . g:NERDTreeMenuUp . '/enter' + + if self.isMinimal() + let selection = self.menuItems[self.selection].text + let keyword = matchstr(selection, '[^ ]*([^ ]*') + + let shortcuts = map(copy(self.menuItems), "v:val['shortcut']") + let shortcuts[self.selection] = ' ' . keyword . ' ' + + echo 'Menu: [' . join(shortcuts, ',') . '] (' . navHelp . ' or shortcut): ' + else + echo 'NERDTree Menu. ' . navHelp . ', or the shortcuts indicated' + echo '=========================================================' + + for i in range(0, len(self.menuItems)-1) + if self.selection ==# i + echo '> ' . self.menuItems[i].text + else + echo ' ' . self.menuItems[i].text + endif + endfor + endif +endfunction + +"FUNCTION: MenuController._current(key) {{{1 +"get the MenuItem that is currently selected +function! s:MenuController._current() + return self.menuItems[self.selection] +endfunction + +"FUNCTION: MenuController._handleKeypress(key) {{{1 +"change the selection (if appropriate) and return 1 if the user has made +"their choice, 0 otherwise +function! s:MenuController._handleKeypress(key) + if a:key ==# g:NERDTreeMenuDown + call self._cursorDown() + elseif a:key ==# g:NERDTreeMenuUp + call self._cursorUp() + elseif a:key ==# nr2char(27) "escape + let self.selection = -1 + return 1 + elseif a:key ==# "\r" || a:key ==# "\n" "enter and ctrl-j + return 1 + else + let index = self._nextIndexFor(a:key) + if index !=# -1 + let self.selection = index + if len(self._allIndexesFor(a:key)) ==# 1 + return 1 + endif + endif + endif + + return 0 +endfunction + +"FUNCTION: MenuController._allIndexesFor(shortcut) {{{1 +"get indexes to all menu items with the given shortcut +function! s:MenuController._allIndexesFor(shortcut) + let toReturn = [] + + for i in range(0, len(self.menuItems)-1) + if self.menuItems[i].shortcut ==# a:shortcut + call add(toReturn, i) + endif + endfor + + return toReturn +endfunction + +"FUNCTION: MenuController._nextIndexFor(shortcut) {{{1 +"get the index to the next menu item with the given shortcut, starts from the +"current cursor location and wraps around to the top again if need be +function! s:MenuController._nextIndexFor(shortcut) + for i in range(self.selection+1, len(self.menuItems)-1) + if self.menuItems[i].shortcut ==# a:shortcut + return i + endif + endfor + + for i in range(0, self.selection) + if self.menuItems[i].shortcut ==# a:shortcut + return i + endif + endfor + + return -1 +endfunction + +"FUNCTION: MenuController._setCmdheight() {{{1 +"sets &cmdheight to whatever is needed to display the menu +function! s:MenuController._setCmdheight() + if self.isMinimal() + let &cmdheight = 1 + else + let &cmdheight = len(self.menuItems) + 3 + endif +endfunction + +"FUNCTION: MenuController._saveOptions() {{{1 +"set any vim options that are required to make the menu work (saving their old +"values) +function! s:MenuController._saveOptions() + let self._oldLazyredraw = &lazyredraw + let self._oldCmdheight = &cmdheight + set nolazyredraw + call self._setCmdheight() +endfunction + +"FUNCTION: MenuController._restoreOptions() {{{1 +"restore the options we saved in _saveOptions() +function! s:MenuController._restoreOptions() + let &cmdheight = self._oldCmdheight + let &lazyredraw = self._oldLazyredraw +endfunction + +"FUNCTION: MenuController._cursorDown() {{{1 +"move the cursor to the next menu item, skipping separators +function! s:MenuController._cursorDown() + let done = 0 + while !done + if self.selection < len(self.menuItems)-1 + let self.selection += 1 + else + let self.selection = 0 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + +"FUNCTION: MenuController._cursorUp() {{{1 +"move the cursor to the previous menu item, skipping separators +function! s:MenuController._cursorUp() + let done = 0 + while !done + if self.selection > 0 + let self.selection -= 1 + else + let self.selection = len(self.menuItems)-1 + endif + + if !self._current().isSeparator() + let done = 1 + endif + endwhile +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim b/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim new file mode 100644 index 00000000..7f259171 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/menu_item.vim @@ -0,0 +1,118 @@ +"CLASS: MenuItem +"============================================================ +let s:MenuItem = {} +let g:NERDTreeMenuItem = s:MenuItem + +"FUNCTION: MenuItem.All() {{{1 +"get all top level menu items +function! s:MenuItem.All() + if !exists('s:menuItems') + let s:menuItems = [] + endif + return s:menuItems +endfunction + +"FUNCTION: MenuItem.AllEnabled() {{{1 +"get all top level menu items that are currently enabled +function! s:MenuItem.AllEnabled() + let toReturn = [] + for i in s:MenuItem.All() + if i.enabled() + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +"FUNCTION: MenuItem.Create(options) {{{1 +"make a new menu item and add it to the global list +function! s:MenuItem.Create(options) + let newMenuItem = copy(self) + + let newMenuItem.text = a:options['text'] + let newMenuItem.shortcut = a:options['shortcut'] + let newMenuItem.children = [] + + let newMenuItem.isActiveCallback = -1 + if has_key(a:options, 'isActiveCallback') + let newMenuItem.isActiveCallback = a:options['isActiveCallback'] + endif + + let newMenuItem.callback = -1 + if has_key(a:options, 'callback') + let newMenuItem.callback = a:options['callback'] + endif + + if has_key(a:options, 'parent') + call add(a:options['parent'].children, newMenuItem) + else + call add(s:MenuItem.All(), newMenuItem) + endif + + return newMenuItem +endfunction + +"FUNCTION: MenuItem.CreateSeparator(options) {{{1 +"make a new separator menu item and add it to the global list +function! s:MenuItem.CreateSeparator(options) + let standard_options = { 'text': '--------------------', + \ 'shortcut': -1, + \ 'callback': -1 } + let options = extend(a:options, standard_options, 'force') + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.CreateSubmenu(options) {{{1 +"make a new submenu and add it to global list +function! s:MenuItem.CreateSubmenu(options) + let standard_options = { 'callback': -1 } + let options = extend(a:options, standard_options, 'force') + + return s:MenuItem.Create(options) +endfunction + +"FUNCTION: MenuItem.enabled() {{{1 +"return 1 if this menu item should be displayed +" +"delegates off to the isActiveCallback, and defaults to 1 if no callback was +"specified +function! s:MenuItem.enabled() + if self.isActiveCallback != -1 + return type(self.isActiveCallback) == type(function('tr')) ? self.isActiveCallback() : {self.isActiveCallback}() + endif + return 1 +endfunction + +"FUNCTION: MenuItem.execute() {{{1 +"perform the action behind this menu item, if this menuitem has children then +"display a new menu for them, otherwise deletegate off to the menuitem's +"callback +function! s:MenuItem.execute() + if len(self.children) + let mc = g:NERDTreeMenuController.New(self.children) + call mc.showMenu() + else + if self.callback != -1 + if type(self.callback) == type(function('tr')) + call self.callback() + else + call {self.callback}() + endif + endif + endif +endfunction + +"FUNCTION: MenuItem.isSeparator() {{{1 +"return 1 if this menuitem is a separator +function! s:MenuItem.isSeparator() + return self.callback == -1 && self.children == [] +endfunction + +"FUNCTION: MenuItem.isSubmenu() {{{1 +"return 1 if this menuitem is a submenu +function! s:MenuItem.isSubmenu() + return self.callback == -1 && !empty(self.children) +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim new file mode 100644 index 00000000..61a11a96 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/nerdtree.vim @@ -0,0 +1,209 @@ +"CLASS: NERDTree +"============================================================ +let s:NERDTree = {} +let g:NERDTree = s:NERDTree + +"FUNCTION: s:NERDTree.AddPathFilter() {{{1 +function! s:NERDTree.AddPathFilter(callback) + call add(s:NERDTree.PathFilters(), a:callback) +endfunction + +"FUNCTION: s:NERDTree.changeRoot(node) {{{1 +function! s:NERDTree.changeRoot(node) + if a:node.path.isDirectory + let self.root = a:node + else + call a:node.cacheParent() + let self.root = a:node.parent + endif + + call self.root.open() + + "change dir to the dir of the new root if instructed to + if g:NERDTreeChDirMode >= 2 + call self.root.path.changeToDir() + endif + + call self.render() + call self.root.putCursorHere(0, 0) + + if exists('#User#NERDTreeNewRoot') + doautocmd User NERDTreeNewRoot + endif +endfunction + +"FUNCTION: s:NERDTree.Close() {{{1 +"Closes the tab tree window for this tab +function! s:NERDTree.Close() + if !s:NERDTree.IsOpen() + return + endif + + if winnr('$') !=# 1 + " Use the window ID to identify the currently active window or fall + " back on the buffer ID if win_getid/win_gotoid are not available, in + " which case we'll focus an arbitrary window showing the buffer. + let l:useWinId = exists('*win_getid') && exists('*win_gotoid') + + if winnr() ==# s:NERDTree.GetWinNum() + call nerdtree#exec('wincmd p', 1) + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') + call nerdtree#exec('wincmd p', 1) + else + let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr('') + endif + + call nerdtree#exec(s:NERDTree.GetWinNum() . ' wincmd w', 1) + call nerdtree#exec('close', 0) + if l:useWinId + call nerdtree#exec('call win_gotoid(' . l:activeBufOrWin . ')', 0) + else + call nerdtree#exec(bufwinnr(l:activeBufOrWin) . ' wincmd w', 0) + endif + else + close + endif +endfunction + +"FUNCTION: s:NERDTree.CursorToBookmarkTable(){{{1 +"Places the cursor at the top of the bookmarks table +function! s:NERDTree.CursorToBookmarkTable() + if !b:NERDTree.ui.getShowBookmarks() + throw 'NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active' + endif + + if g:NERDTreeMinimalUI + return cursor(1, 2) + endif + + let rootNodeLine = b:NERDTree.ui.getRootLineNum() + + let line = 1 + while getline(line) !~# '^>-\+Bookmarks-\+$' + let line = line + 1 + if line >= rootNodeLine + throw 'NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table' + endif + endwhile + call cursor(line, 2) +endfunction + +"FUNCTION: s:NERDTree.CursorToTreeWin(){{{1 +"Places the cursor in the nerd tree window +function! s:NERDTree.CursorToTreeWin(...) + call g:NERDTree.MustBeOpen() + call nerdtree#exec(g:NERDTree.GetWinNum() . 'wincmd w', a:0 >0 ? a:1 : 1) +endfunction + +" Function: s:NERDTree.ExistsForBuffer() {{{1 +" Returns 1 if a nerd tree root exists in the current buffer +function! s:NERDTree.ExistsForBuf() + return exists('b:NERDTree') +endfunction + +" Function: s:NERDTree.ExistsForTab() {{{1 +" Returns 1 if a nerd tree root exists in the current tab +function! s:NERDTree.ExistsForTab() + if !exists('t:NERDTreeBufName') + return + end + + "check b:NERDTree is still there and hasn't been e.g. :bdeleted + return !empty(getbufvar(bufnr(t:NERDTreeBufName), 'NERDTree')) +endfunction + +function! s:NERDTree.ForCurrentBuf() + if s:NERDTree.ExistsForBuf() + return b:NERDTree + else + return {} + endif +endfunction + +"FUNCTION: s:NERDTree.ForCurrentTab() {{{1 +function! s:NERDTree.ForCurrentTab() + if !s:NERDTree.ExistsForTab() + return + endif + + let bufnr = bufnr(t:NERDTreeBufName) + return getbufvar(bufnr, 'NERDTree') +endfunction + +"FUNCTION: s:NERDTree.getRoot() {{{1 +function! s:NERDTree.getRoot() + return self.root +endfunction + +"FUNCTION: s:NERDTree.GetWinNum() {{{1 +"gets the nerd tree window number for this tab +function! s:NERDTree.GetWinNum() + if exists('t:NERDTreeBufName') + return bufwinnr(t:NERDTreeBufName) + endif + + " If WindowTree, there is no t:NERDTreeBufName variable. Search all windows. + for w in range(1,winnr('$')) + if bufname(winbufnr(w)) =~# '^' . g:NERDTreeCreator.BufNamePrefix() . '\d\+$' + return w + endif + endfor + + return -1 +endfunction + +"FUNCTION: s:NERDTree.IsOpen() {{{1 +function! s:NERDTree.IsOpen() + return s:NERDTree.GetWinNum() !=# -1 +endfunction + +"FUNCTION: s:NERDTree.isTabTree() {{{1 +function! s:NERDTree.isTabTree() + return self._type ==# 'tab' +endfunction + +"FUNCTION: s:NERDTree.isWinTree() {{{1 +function! s:NERDTree.isWinTree() + return self._type ==# 'window' +endfunction + +"FUNCTION: s:NERDTree.MustBeOpen() {{{1 +function! s:NERDTree.MustBeOpen() + if !s:NERDTree.IsOpen() + throw 'NERDTree.TreeNotOpen' + endif +endfunction + +"FUNCTION: s:NERDTree.New() {{{1 +function! s:NERDTree.New(path, type) + let newObj = copy(self) + let newObj.ui = g:NERDTreeUI.New(newObj) + let newObj.root = g:NERDTreeDirNode.New(a:path, newObj) + let newObj._type = a:type + return newObj +endfunction + +"FUNCTION: s:NERDTree.PathFilters() {{{1 +function! s:NERDTree.PathFilters() + if !exists('s:NERDTree._PathFilters') + let s:NERDTree._PathFilters = [] + endif + return s:NERDTree._PathFilters +endfunction + +"FUNCTION: s:NERDTree.previousBuf() {{{1 +function! s:NERDTree.previousBuf() + return self._previousBuf +endfunction + +function! s:NERDTree.setPreviousBuf(bnum) + let self._previousBuf = a:bnum +endfunction + +"FUNCTION: s:NERDTree.render() {{{1 +"A convenience function - since this is called often +function! s:NERDTree.render() + call self.ui.render() +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim new file mode 100644 index 00000000..ffa2853a --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/notifier.vim @@ -0,0 +1,35 @@ +"CLASS: Notifier +"============================================================ +let s:Notifier = {} + +function! s:Notifier.AddListener(event, funcname) + let listeners = s:Notifier.GetListenersForEvent(a:event) + if listeners == [] + let listenersMap = s:Notifier.GetListenersMap() + let listenersMap[a:event] = listeners + endif + call add(listeners, a:funcname) +endfunction + +function! s:Notifier.NotifyListeners(event, path, nerdtree, params) + let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) + + for Listener in s:Notifier.GetListenersForEvent(a:event) + let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) + call l:Callback(event) + endfor +endfunction + +function! s:Notifier.GetListenersMap() + if !exists('s:refreshListenersMap') + let s:refreshListenersMap = {} + endif + return s:refreshListenersMap +endfunction + +function! s:Notifier.GetListenersForEvent(name) + let listenersMap = s:Notifier.GetListenersMap() + return get(listenersMap, a:name, []) +endfunction + +let g:NERDTreePathNotifier = deepcopy(s:Notifier) diff --git a/sources_non_forked/nerdtree/lib/nerdtree/opener.vim b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim new file mode 100644 index 00000000..27993ac7 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/opener.vim @@ -0,0 +1,326 @@ +" ============================================================================ +" CLASS: Opener +" +" The Opener class defines an API for 'opening' operations. +" ============================================================================ + + +let s:Opener = {} +let g:NERDTreeOpener = s:Opener + +" FUNCTION: s:Opener._bufInWindows(bnum) {{{1 +" [[STOLEN FROM VTREEEXPLORER.VIM]] +" Determine the number of windows open to this buffer number. +" Care of Yegappan Lakshman. Thanks! +" +" Args: +" bnum: the subject buffers buffer number +function! s:Opener._bufInWindows(bnum) + let cnt = 0 + let winnum = 1 + while 1 + let bufnum = winbufnr(winnum) + if bufnum < 0 + break + endif + if bufnum ==# a:bnum + let cnt = cnt + 1 + endif + let winnum = winnum + 1 + endwhile + + return cnt +endfunction + +" FUNCTION: Opener._checkToCloseTree(newtab) {{{1 +" Check the class options to see if the tree should be closed now. +" +" Args: +" a:newtab - boolean. If set, only close the tree now if we are opening the +" target in a new tab. This is needed because we have to close tree before we +" leave the tab +function! s:Opener._checkToCloseTree(newtab) + if self._keepopen + return + endif + + if (a:newtab && self._where ==# 't') || !a:newtab + call g:NERDTree.Close() + endif +endfunction + +" FUNCTION: s:Opener._firstUsableWindow() {{{1 +" find the window number of the first normal window +function! s:Opener._firstUsableWindow() + let i = 1 + while i <= winnr('$') + let bnum = winbufnr(i) + if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# '' + \ && !getwinvar(i, '&previewwindow') + \ && (!getbufvar(bnum, '&modified') || &hidden) + return i + endif + + let i += 1 + endwhile + return -1 +endfunction + +" FUNCTION: Opener._gotoTargetWin() {{{1 +function! s:Opener._gotoTargetWin() + if b:NERDTree.isWinTree() + if self._where ==# 'v' + call self._newVSplit() + elseif self._where ==# 'h' + call self._newSplit() + elseif self._where ==# 't' + tabnew + endif + else + call self._checkToCloseTree(1) + + if self._where ==# 'v' + call self._newVSplit() + elseif self._where ==# 'h' + call self._newSplit() + elseif self._where ==# 't' + tabnew + elseif self._where ==# 'p' + call self._previousWindow() + endif + + call self._checkToCloseTree(0) + endif +endfunction + +" FUNCTION: s:Opener._isWindowUsable(winnumber) {{{1 +" Returns 0 if opening a file from the tree in the given window requires it to +" be split, 1 otherwise +" +" Args: +" winnumber: the number of the window in question +function! s:Opener._isWindowUsable(winnumber) + "gotta split if theres only one window (i.e. the NERD tree) + if winnr('$') ==# 1 + return 0 + endif + + let oldwinnr = winnr() + call nerdtree#exec(a:winnumber . 'wincmd p', 1) + let specialWindow = getbufvar('%', '&buftype') !=# '' || getwinvar('%', '&previewwindow') + let modified = &modified + call nerdtree#exec(oldwinnr . 'wincmd p', 1) + + "if its a special window e.g. quickfix or another explorer plugin then we + "have to split + if specialWindow + return 0 + endif + + if &hidden + return 1 + endif + + return !modified || self._bufInWindows(winbufnr(a:winnumber)) >= 2 +endfunction + +" FUNCTION: Opener.New(path, opts) {{{1 +" Instantiate a new NERDTreeOpener object. +" Args: +" a:path: the path object that is to be opened +" a:opts: a dictionary containing the following optional keys... +" 'where': specifies whether the node should be opened in new split, in +" a new tab or, in the last window; takes values 'v', 'h', or 't' +" 'reuse': if file is already shown in a window, jump there; takes values +" 'all', 'currenttab', or empty +" 'keepopen': boolean (0 or 1); if true, the tree window will not be closed +" 'stay': boolean (0 or 1); if true, remain in tree window after opening +function! s:Opener.New(path, opts) + let l:newOpener = copy(self) + + let l:newOpener._keepopen = nerdtree#has_opt(a:opts, 'keepopen') + let l:newOpener._nerdtree = b:NERDTree + let l:newOpener._path = a:path + let l:newOpener._reuse = has_key(a:opts, 'reuse') ? a:opts['reuse'] : '' + let l:newOpener._stay = nerdtree#has_opt(a:opts, 'stay') + let l:newOpener._where = has_key(a:opts, 'where') ? a:opts['where'] : '' + + call l:newOpener._saveCursorPos() + + return l:newOpener +endfunction + +" FUNCTION: Opener._newSplit() {{{1 +function! s:Opener._newSplit() + let onlyOneWin = (winnr('$') ==# 1) + let savesplitright = &splitright + if onlyOneWin + let &splitright = (g:NERDTreeWinPos ==# 'left') + endif + " If only one window (ie. NERDTree), split vertically instead. + let splitMode = onlyOneWin ? 'vertical' : '' + + " Open the new window + try + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec(splitMode . ' split',1) + catch /^Vim\%((\a\+)\)\=:E37/ + call g:NERDTree.CursorToTreeWin() + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' + catch /^Vim\%((\a\+)\)\=:/ + "do nothing + endtry + + "resize the tree window if no other window was open before + if onlyOneWin + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('silent '. splitMode .' resize '. g:NERDTreeWinSize, 1) + call nerdtree#exec('wincmd p', 0) + endif + + let &splitright=savesplitright +endfunction + +" FUNCTION: Opener._newVSplit() {{{1 +function! s:Opener._newVSplit() + let l:winwidth = winwidth('.') + + let onlyOneWin = (winnr('$') ==# 1) + let savesplitright = &splitright + if onlyOneWin + let &splitright = (g:NERDTreeWinPos ==# 'left') + let l:winwidth = g:NERDTreeWinSize + endif + + call nerdtree#exec('wincmd p', 1) + call nerdtree#exec('vsplit', 1) + + let l:currentWindowNumber = winnr() + + " Restore the NERDTree to its original width. + call g:NERDTree.CursorToTreeWin() + execute 'silent vertical resize ' . l:winwidth + + call nerdtree#exec(l:currentWindowNumber . 'wincmd w', 0) + let &splitright=savesplitright +endfunction + +" FUNCTION: Opener.open(target) {{{1 +function! s:Opener.open(target) + if self._path.isDirectory + call self._openDirectory(a:target) + return + endif + + call self._openFile() +endfunction + +" FUNCTION: Opener._openFile() {{{1 +function! s:Opener._openFile() + if !self._stay && self._keepopen && get(b:, 'NERDTreeZoomed', 0) + call b:NERDTree.ui.toggleZoom() + endif + + if self._reuseWindow() + return + endif + + call self._gotoTargetWin() + + if self._stay + silent call self._path.edit() + call self._restoreCursorPos() + return + endif + + call self._path.edit() +endfunction + +" FUNCTION: Opener._openDirectory(node) {{{1 +function! s:Opener._openDirectory(node) + call self._gotoTargetWin() + + if self._nerdtree.isWinTree() + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) + else + if empty(self._where) + call b:NERDTree.changeRoot(a:node) + elseif self._where ==# 't' + call g:NERDTreeCreator.CreateTabTree(a:node.path.str()) + else + call g:NERDTreeCreator.CreateWindowTree(a:node.path.str()) + endif + endif + + if self._stay + call self._restoreCursorPos() + endif +endfunction + +" FUNCTION: Opener._previousWindow() {{{1 +function! s:Opener._previousWindow() + if !self._isWindowUsable(winnr('#')) && self._firstUsableWindow() ==# -1 + call self._newSplit() + else + try + if !self._isWindowUsable(winnr('#')) + call nerdtree#exec(self._firstUsableWindow() . 'wincmd w', 1) + else + call nerdtree#exec('wincmd p', 1) + endif + catch /^Vim\%((\a\+)\)\=:E37/ + call g:NERDTree.CursorToTreeWin() + throw 'NERDTree.FileAlreadyOpenAndModifiedError: '. self._path.str() .' is already open and modified.' + catch /^Vim\%((\a\+)\)\=:/ + echo v:exception + endtry + endif +endfunction + +" FUNCTION: Opener._restoreCursorPos() {{{1 +function! s:Opener._restoreCursorPos() + call nerdtree#exec(self._tabnr . 'tabnext', 1) + call nerdtree#exec(bufwinnr(self._bufnr) . 'wincmd w', 1) +endfunction + +" FUNCTION: Opener._reuseWindow() {{{1 +" put the cursor in the first window we find for this file +" +" return 1 if we were successful +function! s:Opener._reuseWindow() + if empty(self._reuse) + return 0 + endif + + "check the current tab for the window + let winnr = bufwinnr('^' . self._path.str() . '$') + if winnr !=# -1 + call nerdtree#exec(winnr . 'wincmd w', 0) + call self._checkToCloseTree(0) + return 1 + endif + + if self._reuse ==# 'currenttab' + return 0 + endif + + "check other tabs + let tabnr = self._path.tabnr() + if tabnr + call self._checkToCloseTree(1) + call nerdtree#exec(tabnr . 'tabnext', 1) + let winnr = bufwinnr('^' . self._path.str() . '$') + call nerdtree#exec(winnr . 'wincmd w', 0) + return 1 + endif + + return 0 +endfunction + +" FUNCTION: Opener._saveCursorPos() {{{1 +function! s:Opener._saveCursorPos() + let self._bufnr = bufnr('') + let self._tabnr = tabpagenr() +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/path.vim b/sources_non_forked/nerdtree/lib/nerdtree/path.vim new file mode 100644 index 00000000..997abf37 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/path.vim @@ -0,0 +1,852 @@ +" ============================================================================ +" CLASS: Path +" +" The Path class provides an abstracted representation of a file system +" pathname. Various operations on pathnames are provided and a number of +" representations of a given path name can be accessed here. +" ============================================================================ + + +let s:Path = {} +let g:NERDTreePath = s:Path + +" FUNCTION: Path.AbsolutePathFor(pathStr) {{{1 +function! s:Path.AbsolutePathFor(pathStr) + let l:prependWorkingDir = 0 + + if nerdtree#runningWindows() + let l:prependWorkingDir = a:pathStr !~# '^.:\(\\\|\/\)\?' && a:pathStr !~# '^\(\\\\\|\/\/\)' + else + let l:prependWorkingDir = a:pathStr !~# '^/' + endif + + let l:result = a:pathStr + + if l:prependWorkingDir + let l:result = getcwd() + + if l:result[-1:] == nerdtree#slash() + let l:result = l:result . a:pathStr + else + let l:result = l:result . nerdtree#slash() . a:pathStr + endif + endif + + return l:result +endfunction + +" FUNCTION: Path.bookmarkNames() {{{1 +function! s:Path.bookmarkNames() + if !exists('self._bookmarkNames') + call self.cacheDisplayString() + endif + return self._bookmarkNames +endfunction + +" FUNCTION: Path.cacheDisplayString() {{{1 +function! s:Path.cacheDisplayString() abort + let self.cachedDisplayString = g:NERDTreeNodeDelimiter . self.getLastPathComponent(1) + + if self.isExecutable + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . '*' + endif + + let self._bookmarkNames = [] + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self) + call add(self._bookmarkNames, i.name) + endif + endfor + if !empty(self._bookmarkNames) && g:NERDTreeMarkBookmarks ==# 1 + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' {' . join(self._bookmarkNames) . '}' + endif + + if self.isSymLink + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' -> ' . self.symLinkDest + endif + + if self.isReadOnly + let self.cachedDisplayString = self.addDelimiter(self.cachedDisplayString) . ' ['.g:NERDTreeGlyphReadOnly.']' + endif +endfunction + +" FUNCTION: Path.addDelimiter() {{{1 +function! s:Path.addDelimiter(line) + if a:line =~# '\(.*' . g:NERDTreeNodeDelimiter . '\)\{2}' + return a:line + else + return a:line . g:NERDTreeNodeDelimiter + endif +endfunction + +" FUNCTION: Path.changeToDir() {{{1 +function! s:Path.changeToDir() + let dir = self.str({'format': 'Cd'}) + if self.isDirectory ==# 0 + let dir = self.getParent().str({'format': 'Cd'}) + endif + + try + if g:NERDTreeUseTCD && exists(':tcd') ==# 2 + execute 'tcd ' . dir + call nerdtree#echo("Tab's CWD is now: " . getcwd()) + else + execute 'cd ' . dir + call nerdtree#echo('CWD is now: ' . getcwd()) + endif + catch + throw 'NERDTree.PathChangeError: cannot change CWD to ' . dir + endtry +endfunction + +" FUNCTION: Path.Create(fullpath) {{{1 +" +" Factory method. +" +" Creates a path object with the given path. The path is also created on the +" filesystem. If the path already exists, a NERDTree.Path.Exists exception is +" thrown. If any other errors occur, a NERDTree.Path exception is thrown. +" +" Args: +" fullpath: the full filesystem path to the file/dir to create +function! s:Path.Create(fullpath) + "bail if the a:fullpath already exists + if isdirectory(a:fullpath) || filereadable(a:fullpath) + throw "NERDTree.CreatePathError: Directory Exists: '" . a:fullpath . "'" + endif + + try + + "if it ends with a slash, assume its a dir create it + if a:fullpath =~# '\(\\\|\/\)$' + "whack the trailing slash off the end if it exists + let fullpath = substitute(a:fullpath, '\(\\\|\/\)$', '', '') + + call mkdir(fullpath, 'p') + + "assume its a file and create + else + call s:Path.createParentDirectories(a:fullpath) + call writefile([], a:fullpath) + endif + catch + throw "NERDTree.CreatePathError: Could not create path: '" . a:fullpath . "'" + endtry + + return s:Path.New(a:fullpath) +endfunction + +" FUNCTION: Path.copy(dest) {{{1 +" +" Copies the file/dir represented by this Path to the given location +" +" Args: +" dest: the location to copy this dir/file to +function! s:Path.copy(dest) + if !s:Path.CopyingSupported() + throw 'NERDTree.CopyingNotSupportedError: Copying is not supported on this OS' + endif + + call s:Path.createParentDirectories(a:dest) + + if exists('g:NERDTreeCopyCmd') + let cmd_prefix = g:NERDTreeCopyCmd + else + let cmd_prefix = (self.isDirectory ? g:NERDTreeCopyDirCmd : g:NERDTreeCopyFileCmd) + endif + + let cmd = cmd_prefix . ' ' . shellescape(self.str()) . ' ' . shellescape(a:dest) + let success = system(cmd) + if v:shell_error !=# 0 + throw "NERDTree.CopyError: Could not copy '". self.str() ."' to: '" . a:dest . "'" + endif +endfunction + +" FUNCTION: Path.CopyingSupported() {{{1 +" +" returns 1 if copying is supported for this OS +function! s:Path.CopyingSupported() + return exists('g:NERDTreeCopyCmd') || (exists('g:NERDTreeCopyDirCmd') && exists('g:NERDTreeCopyFileCmd')) +endfunction + +" FUNCTION: Path.copyingWillOverwrite(dest) {{{1 +" +" returns 1 if copy this path to the given location will cause files to +" overwritten +" +" Args: +" dest: the location this path will be copied to +function! s:Path.copyingWillOverwrite(dest) + if filereadable(a:dest) + return 1 + endif + + if isdirectory(a:dest) + let path = s:Path.JoinPathStrings(a:dest, self.getLastPathComponent(0)) + if filereadable(path) + return 1 + endif + endif +endfunction + +" FUNCTION: Path.createParentDirectories(path) {{{1 +" +" create parent directories for this path if needed +" without throwing any errors if those directories already exist +" +" Args: +" path: full path of the node whose parent directories may need to be created +function! s:Path.createParentDirectories(path) + let dir_path = fnamemodify(a:path, ':h') + if !isdirectory(dir_path) + call mkdir(dir_path, 'p') + endif +endfunction + +" FUNCTION: Path.delete() {{{1 +" +" Deletes the file or directory represented by this path. +" +" Throws NERDTree.Path.Deletion exceptions +function! s:Path.delete() + if self.isDirectory + + let cmd = g:NERDTreeRemoveDirCmd . self.str({'escape': 1}) + let success = system(cmd) + + if v:shell_error !=# 0 + throw "NERDTree.PathDeletionError: Could not delete directory: '" . self.str() . "'" + endif + else + if exists('g:NERDTreeRemoveFileCmd') + let cmd = g:NERDTreeRemoveFileCmd . self.str({'escape': 1}) + let success = system(cmd) + else + let success = delete(self.str()) + endif + + if success !=# 0 + throw "NERDTree.PathDeletionError: Could not delete file: '" . self.str() . "'" + endif + endif + + "delete all bookmarks for this path + for i in self.bookmarkNames() + let bookmark = g:NERDTreeBookmark.BookmarkFor(i) + call bookmark.delete() + endfor +endfunction + +" FUNCTION: Path.displayString() {{{1 +" +" Returns a string that specifies how the path should be represented as a +" string +function! s:Path.displayString() + if self.cachedDisplayString ==# '' + call self.cacheDisplayString() + endif + + return self.cachedDisplayString +endfunction + +" FUNCTION: Path.edit() {{{1 +function! s:Path.edit() + let l:bufname = self.str({'format': 'Edit'}) + if bufname('%') !=# l:bufname + exec 'edit ' . l:bufname + endif +endfunction + +" FUNCTION: Path.extractDriveLetter(fullpath) {{{1 +" +" If running windows, cache the drive letter for this path +function! s:Path.extractDriveLetter(fullpath) + if nerdtree#runningWindows() + if a:fullpath =~# '^\(\\\\\|\/\/\)' + "For network shares, the 'drive' consists of the first two parts of the path, i.e. \\boxname\share + let self.drive = substitute(a:fullpath, '^\(\(\\\\\|\/\/\)[^\\\/]*\(\\\|\/\)[^\\\/]*\).*', '\1', '') + let self.drive = substitute(self.drive, '/', '\', 'g') + else + let self.drive = substitute(a:fullpath, '\(^[a-zA-Z]:\).*', '\1', '') + endif + else + let self.drive = '' + endif + +endfunction + +" FUNCTION: Path.exists() {{{1 +" return 1 if this path points to a location that is readable or is a directory +function! s:Path.exists() + let p = self.str() + return filereadable(p) || isdirectory(p) +endfunction + +" FUNCTION: Path._escChars() {{{1 +function! s:Path._escChars() + if nerdtree#runningWindows() + return " `\|\"#%&,?()\*^<>$" + endif + + return " \\`\|\"#%&,?()\*^<>[]{}$" +endfunction + +" FUNCTION: Path.getDir() {{{1 +" +" Returns this path if it is a directory, else this paths parent. +" +" Return: +" a Path object +function! s:Path.getDir() + if self.isDirectory + return self + else + return self.getParent() + endif +endfunction + +" FUNCTION: Path.getParent() {{{1 +" +" Returns a new path object for this paths parent +" +" Return: +" a new Path object +function! s:Path.getParent() + if nerdtree#runningWindows() + let path = self.drive . '\' . join(self.pathSegments[0:-2], '\') + else + let path = '/'. join(self.pathSegments[0:-2], '/') + endif + + return s:Path.New(path) +endfunction + +" FUNCTION: Path.getLastPathComponent(dirSlash) {{{1 +" +" Gets the last part of this path. +" +" Args: +" dirSlash: if 1 then a trailing slash will be added to the returned value for +" directory nodes. +function! s:Path.getLastPathComponent(dirSlash) + if empty(self.pathSegments) + return '' + endif + let toReturn = self.pathSegments[-1] + if a:dirSlash && self.isDirectory + let toReturn = toReturn . '/' + endif + return toReturn +endfunction + +" FUNCTION: Path.getSortOrderIndex() {{{1 +" returns the index of the pattern in g:NERDTreeSortOrder that this path matches +function! s:Path.getSortOrderIndex() + let i = 0 + while i < len(g:NERDTreeSortOrder) + if g:NERDTreeSortOrder[i] !~? '\[\[-\?\(timestamp\|size\|extension\)\]\]' && + \ self.getLastPathComponent(1) =~# g:NERDTreeSortOrder[i] + return i + endif + let i = i + 1 + endwhile + + return index(g:NERDTreeSortOrder, '*') +endfunction + +" FUNCTION: Path._splitChunks(path) {{{1 +" returns a list of path chunks +function! s:Path._splitChunks(path) + let chunks = split(a:path, '\(\D\+\|\d\+\)\zs') + let i = 0 + while i < len(chunks) + "convert number literals to numbers + if match(chunks[i], '^\d\+$') ==# 0 + let chunks[i] = str2nr(chunks[i]) + endif + let i = i + 1 + endwhile + return chunks +endfunction + +" FUNCTION: Path.getSortKey() {{{1 +" returns a key used in compare function for sorting +function! s:Path.getSortKey() + if !exists('self._sortKey') || g:NERDTreeSortOrder !=# g:NERDTreeOldSortOrder + " Look for file metadata tags: [[timestamp]], [[extension]], [[size]] + let metadata = [] + for tag in g:NERDTreeSortOrder + if tag =~? '\[\[-\?timestamp\]\]' + let metadata += [self.isDirectory ? 0 : getftime(self.str()) * (tag =~# '-' ? -1 : 1)] + elseif tag =~? '\[\[-\?size\]\]' + let metadata += [self.isDirectory ? 0 : getfsize(self.str()) * (tag =~# '-' ? -1 : 1)] + elseif tag =~? '\[\[extension\]\]' + let extension = matchstr(self.getLastPathComponent(0), '[^.]\+\.\zs[^.]\+$') + let metadata += [self.isDirectory ? '' : (extension ==# '' ? nr2char(str2nr('0x10ffff',16)) : extension)] + endif + endfor + + if g:NERDTreeSortOrder[0] =~# '\[\[.*\]\]' + " Apply tags' sorting first if specified first. + let self._sortKey = metadata + [self.getSortOrderIndex()] + else + " Otherwise, do regex grouping first. + let self._sortKey = [self.getSortOrderIndex()] + metadata + endif + + let path = self.getLastPathComponent(0) + if !g:NERDTreeSortHiddenFirst + let path = substitute(path, '^[._]', '', '') + endif + if !g:NERDTreeCaseSensitiveSort + let path = tolower(path) + endif + + call extend(self._sortKey, (g:NERDTreeNaturalSort ? self._splitChunks(path) : [path])) + endif + return self._sortKey +endfunction + +" FUNCTION: Path.isHiddenUnder(path) {{{1 +function! s:Path.isHiddenUnder(path) + + if !self.isUnder(a:path) + return 0 + endif + + let l:startIndex = len(a:path.pathSegments) + let l:segments = self.pathSegments[l:startIndex : ] + + for l:segment in l:segments + + if l:segment =~# '^\.' + return 1 + endif + endfor + + return 0 +endfunction + +" FUNCTION: Path.isUnixHiddenFile() {{{1 +" check for unix hidden files +function! s:Path.isUnixHiddenFile() + return self.getLastPathComponent(0) =~# '^\.' +endfunction + +" FUNCTION: Path.isUnixHiddenPath() {{{1 +" check for unix path with hidden components +function! s:Path.isUnixHiddenPath() + if self.getLastPathComponent(0) =~# '^\.' + return 1 + else + for segment in self.pathSegments + if segment =~# '^\.' + return 1 + endif + endfor + return 0 + endif +endfunction + +" FUNCTION: Path.ignore(nerdtree) {{{1 +" returns true if this path should be ignored +function! s:Path.ignore(nerdtree) + "filter out the user specified paths to ignore + if a:nerdtree.ui.isIgnoreFilterEnabled() + for i in g:NERDTreeIgnore + if self._ignorePatternMatches(i) + return 1 + endif + endfor + + for l:Callback in g:NERDTree.PathFilters() + let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback) + if l:Callback({'path': self, 'nerdtree': a:nerdtree}) + return 1 + endif + endfor + endif + + "dont show hidden files unless instructed to + if !a:nerdtree.ui.getShowHidden() && self.isUnixHiddenFile() + return 1 + endif + + if a:nerdtree.ui.getShowFiles() ==# 0 && self.isDirectory ==# 0 + return 1 + endif + + return 0 +endfunction + +" FUNCTION: Path._ignorePatternMatches(pattern) {{{1 +" returns true if this path matches the given ignore pattern +function! s:Path._ignorePatternMatches(pattern) + let pat = a:pattern + if strpart(pat,len(pat)-8) ==# '[[path]]' + let pat = strpart(pat,0, len(pat)-8) + return self.str() =~# pat + elseif strpart(pat,len(pat)-7) ==# '[[dir]]' + if !self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-7) + elseif strpart(pat,len(pat)-8) ==# '[[file]]' + if self.isDirectory + return 0 + endif + let pat = strpart(pat,0, len(pat)-8) + endif + + return self.getLastPathComponent(0) =~# pat +endfunction + +" FUNCTION: Path.isAncestor(path) {{{1 +" return 1 if this path is somewhere above the given path in the filesystem. +" +" a:path should be a dir +function! s:Path.isAncestor(child) + return a:child.isUnder(self) +endfunction + +" FUNCTION: Path.isUnder(path) {{{1 +" return 1 if this path is somewhere under the given path in the filesystem. +function! s:Path.isUnder(parent) + if a:parent.isDirectory ==# 0 + return 0 + endif + if nerdtree#runningWindows() && a:parent.drive !=# self.drive + return 0 + endif + let l:this_count = len(self.pathSegments) + if l:this_count ==# 0 + return 0 + endif + let l:that_count = len(a:parent.pathSegments) + if l:that_count ==# 0 + return 1 + endif + if l:that_count >= l:this_count + return 0 + endif + for i in range(0, l:that_count-1) + if self.pathSegments[i] !=# a:parent.pathSegments[i] + return 0 + endif + endfor + return 1 +endfunction + +" FUNCTION: Path.JoinPathStrings(...) {{{1 +function! s:Path.JoinPathStrings(...) + let components = [] + for i in a:000 + let components = extend(components, split(i, '/')) + endfor + return '/' . join(components, '/') +endfunction + +" FUNCTION: Path.equals() {{{1 +" +" Determines whether 2 path objects are "equal". +" They are equal if the paths they represent are the same +" +" Args: +" path: the other path obj to compare this with +function! s:Path.equals(path) + if nerdtree#runningWindows() + return self.str() ==? a:path.str() + else + return self.str() ==# a:path.str() + endif +endfunction + +" FUNCTION: Path.New(pathStr) {{{1 +function! s:Path.New(pathStr) + let l:newPath = copy(self) + + call l:newPath.readInfoFromDisk(s:Path.AbsolutePathFor(a:pathStr)) + + let l:newPath.cachedDisplayString = '' + let l:newPath.flagSet = g:NERDTreeFlagSet.New() + + return l:newPath +endfunction + +" FUNCTION: Path.Resolve() {{{1 +" Invoke the vim resolve() function and return the result +" This is necessary because in some versions of vim resolve() removes trailing +" slashes while in other versions it doesn't. This always removes the trailing +" slash +function! s:Path.Resolve(path) + let tmp = resolve(a:path) + return tmp =~# '.\+/$' ? substitute(tmp, '/$', '', '') : tmp +endfunction + +" FUNCTION: Path.readInfoFromDisk(fullpath) {{{1 +" +" +" Throws NERDTree.Path.InvalidArguments exception. +function! s:Path.readInfoFromDisk(fullpath) + call self.extractDriveLetter(a:fullpath) + + let fullpath = s:Path.WinToUnixPath(a:fullpath) + + if getftype(fullpath) ==# 'fifo' + throw 'NERDTree.InvalidFiletypeError: Cant handle FIFO files: ' . a:fullpath + endif + + let self.pathSegments = filter(split(fullpath, '/'), '!empty(v:val)') + + let self.isReadOnly = 0 + if isdirectory(a:fullpath) + let self.isDirectory = 1 + elseif filereadable(a:fullpath) + let self.isDirectory = 0 + let self.isReadOnly = filewritable(a:fullpath) ==# 0 + else + throw 'NERDTree.InvalidArgumentsError: Invalid path = ' . a:fullpath + endif + + let self.isExecutable = 0 + if !self.isDirectory + let self.isExecutable = getfperm(a:fullpath) =~# 'x' + endif + + "grab the last part of the path (minus the trailing slash) + let lastPathComponent = self.getLastPathComponent(0) + + "get the path to the new node with the parent dir fully resolved + let hardPath = s:Path.Resolve(self.strTrunk()) . '/' . lastPathComponent + + "if the last part of the path is a symlink then flag it as such + let self.isSymLink = (s:Path.Resolve(hardPath) !=# hardPath) + if self.isSymLink + let self.symLinkDest = s:Path.Resolve(fullpath) + + "if the link is a dir then slap a / on the end of its dest + if isdirectory(self.symLinkDest) + + "we always wanna treat MS windows shortcuts as files for + "simplicity + if hardPath !~# '\.lnk$' + + let self.symLinkDest = self.symLinkDest . '/' + endif + endif + endif +endfunction + +" FUNCTION: Path.refresh(nerdtree) {{{1 +function! s:Path.refresh(nerdtree) + call self.readInfoFromDisk(self.str()) + call g:NERDTreePathNotifier.NotifyListeners('refresh', self, a:nerdtree, {}) + call self.cacheDisplayString() +endfunction + +" FUNCTION: Path.refreshFlags(nerdtree) {{{1 +function! s:Path.refreshFlags(nerdtree) + call g:NERDTreePathNotifier.NotifyListeners('refreshFlags', self, a:nerdtree, {}) + call self.cacheDisplayString() +endfunction + +" FUNCTION: Path.rename() {{{1 +" +" Renames this node on the filesystem +function! s:Path.rename(newPath) + if a:newPath ==# '' + throw 'NERDTree.InvalidArgumentsError: Invalid newPath for renaming = '. a:newPath + endif + + call s:Path.createParentDirectories(a:newPath) + + let success = rename(self.str(), a:newPath) + if success !=# 0 + throw "NERDTree.PathRenameError: Could not rename: '" . self.str() . "'" . 'to:' . a:newPath + endif + call self.readInfoFromDisk(a:newPath) + + for i in self.bookmarkNames() + let b = g:NERDTreeBookmark.BookmarkFor(i) + call b.setPath(copy(self)) + endfor + call g:NERDTreeBookmark.Write() +endfunction + +" FUNCTION: Path.str() {{{1 +" Return a string representation of this Path object. +" +" Args: +" This function takes a single dictionary (optional) with keys and values that +" specify how the returned pathname should be formatted. +" +" The dictionary may have the following keys: +" 'format' +" 'escape' +" 'truncateTo' +" +" The 'format' key may have a value of: +" 'Cd' - a string to be used with ":cd" and similar commands +" 'Edit' - a string to be used with ":edit" and similar commands +" 'UI' - a string to be displayed in the NERDTree user interface +" +" The 'escape' key, if specified, will cause the output to be escaped with +" Vim's internal "shellescape()" function. +" +" The 'truncateTo' key shortens the length of the path to that given by the +" value associated with 'truncateTo'. A '<' is prepended. +function! s:Path.str(...) + let options = a:0 ? a:1 : {} + let toReturn = '' + + if has_key(options, 'format') + let format = options['format'] + if has_key(self, '_strFor' . format) + exec 'let toReturn = self._strFor' . format . '()' + else + throw 'NERDTree.UnknownFormatError: unknown format "'. format .'"' + endif + else + let toReturn = self._str() + endif + + if nerdtree#has_opt(options, 'escape') + let toReturn = shellescape(toReturn) + endif + + if has_key(options, 'truncateTo') + let limit = options['truncateTo'] + if strdisplaywidth(toReturn) > limit-1 + while strdisplaywidth(toReturn) > limit-1 && strchars(toReturn) > 0 + let toReturn = substitute(toReturn, '^.', '', '') + endwhile + if len(split(toReturn, '/')) > 1 + let toReturn = ' 0) ? a:1 : {} + + call self.toggleOpen(l:options) + + " Note that we only re-render the NERDTree for this node if we did NOT + " create a new node and render it in a new window or tab. In the latter + " case, rendering the NERDTree for this node could overwrite the text of + " the new NERDTree! + if !has_key(l:options, 'where') || empty(l:options['where']) + call self.getNerdtree().render() + call self.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{1 +" Adds the given treenode to the list of children for this node +" +" Args: +" -treenode: the node to add +" -inOrder: 1 if the new node should be inserted in sorted order +function! s:TreeDirNode.addChild(treenode, inOrder) + call add(self.children, a:treenode) + let a:treenode.parent = self + + if a:inOrder + call self.sortChildren() + endif +endfunction + +" FUNCTION: TreeDirNode.close() {{{1 +" Mark this TreeDirNode as closed. +function! s:TreeDirNode.close() + + " Close all directories in this directory node's cascade. This is + " necessary to ensure consistency when cascades are rendered. + for l:dirNode in self.getCascade() + let l:dirNode.isOpen = 0 + endfor +endfunction + +" FUNCTION: TreeDirNode.closeChildren() {{{1 +" Recursively close any directory nodes that are descendants of this node. +function! s:TreeDirNode.closeChildren() + for l:child in self.children + if l:child.path.isDirectory + call l:child.close() + call l:child.closeChildren() + endif + endfor +endfunction + +" FUNCTION: TreeDirNode.createChild(path, inOrder) {{{1 +" Instantiates a new child node for this node with the given path. The new +" nodes parent is set to this node. +" +" Args: +" path: a Path object that this node will represent/contain +" inOrder: 1 if the new node should be inserted in sorted order +" +" Returns: +" the newly created node +function! s:TreeDirNode.createChild(path, inOrder) + let newTreeNode = g:NERDTreeFileNode.New(a:path, self.getNerdtree()) + call self.addChild(newTreeNode, a:inOrder) + return newTreeNode +endfunction + +" FUNCTION: TreeDirNode.displayString() {{{1 +" Assemble and return a string that can represent this TreeDirNode object in +" the NERDTree window. +function! s:TreeDirNode.displayString() + let l:result = '' + + " Build a label that identifies this TreeDirNode. + let l:label = '' + let l:cascade = self.getCascade() + for l:dirNode in l:cascade + let l:next = l:dirNode.path.displayString() + let l:label .= l:label ==# '' ? l:next : substitute(l:next,'^.','','') + endfor + + " Select the appropriate open/closed status indicator symbol. + let l:symbol = (l:cascade[-1].isOpen ? g:NERDTreeDirArrowCollapsible : g:NERDTreeDirArrowExpandable ) + let l:symbol .= (g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') + let l:flags = l:cascade[-1].path.flagSet.renderToString() + + return l:symbol . l:flags . l:label +endfunction + +" FUNCTION: TreeDirNode.findNode(path) {{{1 +" Will find one of the children (recursively) that has the given path +" +" Args: +" path: a path object +unlet s:TreeDirNode.findNode +function! s:TreeDirNode.findNode(path) + if a:path.equals(self.path) + return self + endif + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return {} + endif + + if self.path.isDirectory + for i in self.children + let retVal = i.findNode(a:path) + if retVal !=# {} + return retVal + endif + endfor + endif + return {} +endfunction + +" FUNCTION: TreeDirNode.getCascade() {{{1 +" Return an array of dir nodes (starting from self) that can be cascade opened. +function! s:TreeDirNode.getCascade() + if !self.isCascadable() + return [self] + endif + + let vc = self.getVisibleChildren() + let visChild = vc[0] + + return [self] + visChild.getCascade() +endfunction + +" FUNCTION: TreeDirNode.getCascadeRoot() {{{1 +" Return the first directory node in the cascade in which this directory node +" is rendered. +function! s:TreeDirNode.getCascadeRoot() + + " Don't search above the current NERDTree root node. + if self.isRoot() + return self + endif + + let l:cascadeRoot = self + let l:parent = self.parent + + while !empty(l:parent) && !l:parent.isRoot() + + if index(l:parent.getCascade(), self) ==# -1 + break + endif + + let l:cascadeRoot = l:parent + let l:parent = l:parent.parent + endwhile + + return l:cascadeRoot +endfunction + +" FUNCTION: TreeDirNode.getChildCount() {{{1 +" Returns the number of children this node has +function! s:TreeDirNode.getChildCount() + return len(self.children) +endfunction + +" FUNCTION: TreeDirNode.getChild(path) {{{1 +" Returns child node of this node that has the given path or {} if no such node +" exists. +" +" This function doesnt not recurse into child dir nodes +" +" Args: +" path: a path object +function! s:TreeDirNode.getChild(path) + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return {} + endif + + let index = self.getChildIndex(a:path) + if index ==# -1 + return {} + else + return self.children[index] + endif + +endfunction + +" FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{1 +" returns the child at the given index +" +" Args: +" indx: the index to get the child from +" visible: 1 if only the visible children array should be used, 0 if all the +" children should be searched. +function! s:TreeDirNode.getChildByIndex(indx, visible) + let array_to_search = a:visible? self.getVisibleChildren() : self.children + if a:indx > len(array_to_search) + throw 'NERDTree.InvalidArgumentsError: Index is out of bounds.' + endif + return array_to_search[a:indx] +endfunction + +" FUNCTION: TreeDirNode.getChildIndex(path) {{{1 +" Returns the index of the child node of this node that has the given path or +" -1 if no such node exists. +" +" This function doesnt not recurse into child dir nodes +" +" Args: +" path: a path object +function! s:TreeDirNode.getChildIndex(path) + if stridx(a:path.str(), self.path.str(), 0) ==# -1 + return -1 + endif + + "do a binary search for the child + let a = 0 + let z = self.getChildCount() + while a < z + let mid = (a+z)/2 + let diff = nerdtree#compareNodePaths(a:path, self.children[mid].path) + + if diff ==# -1 + let z = mid + elseif diff ==# 1 + let a = mid+1 + else + return mid + endif + endwhile + return -1 +endfunction + +" FUNCTION: TreeDirNode.getDirChildren() {{{1 +" Return a list of all child nodes from 'self.children' that are of type +" TreeDirNode. This function supports http://github.com/scrooloose/nerdtree-project-plugin.git. +function! s:TreeDirNode.getDirChildren() + return filter(copy(self.children), 'v:val.path.isDirectory ==# 1') +endfunction + +" FUNCTION: TreeDirNode._glob(pattern, all) {{{1 +" Return a list of strings naming the descendants of the directory in this +" TreeDirNode object that match the specified glob pattern. +" +" Args: +" pattern: (string) the glob pattern to apply +" all: (0 or 1) if 1, include '.' and '..' if they match 'pattern'; if 0, +" always exclude them +" +" Note: If the pathnames in the result list are below the working directory, +" they are returned as pathnames relative to that directory. This is because +" this function, internally, attempts to obey 'wildignore' rules that use +" relative paths. +function! s:TreeDirNode._glob(pattern, all) + + " Construct a path specification such that globpath() will return + " relative pathnames, if possible. + if self.path.str() ==# getcwd() + let l:pathSpec = ',' + else + let l:pathSpec = escape(fnamemodify(self.path.str({'format': 'Glob'}), ':.'), ',') + + " On Windows, the drive letter may be removed by "fnamemodify()". + if nerdtree#runningWindows() && l:pathSpec[0] == nerdtree#slash() + let l:pathSpec = self.path.drive . l:pathSpec + endif + endif + + let l:globList = [] + + " See ':h version7.txt' and ':h version8.txt' for details on the + " development of the glob() and globpath() functions. + if v:version > 704 || (v:version ==# 704 && has('patch654')) + let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1, 0) + elseif v:version ==# 704 && has('patch279') + let l:globList = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore, 1) + elseif v:version > 702 || (v:version ==# 702 && has('patch051')) + let l:globString = globpath(l:pathSpec, a:pattern, !g:NERDTreeRespectWildIgnore) + let l:globList = split(l:globString, "\n") + else + let l:globString = globpath(l:pathSpec, a:pattern) + let l:globList = split(l:globString, "\n") + endif + + " If a:all is false, filter '.' and '..' from the output. + if !a:all + let l:toRemove = [] + + for l:file in l:globList + let l:tail = fnamemodify(l:file, ':t') + + " If l:file has a trailing slash, then its :tail will be ''. Use + " :h to drop the slash and the empty string after it; then use :t + " to get the directory name. + if l:tail ==# '' + let l:tail = fnamemodify(l:file, ':h:t') + endif + + if l:tail ==# '.' || l:tail ==# '..' + call add(l:toRemove, l:file) + if len(l:toRemove) ==# 2 + break + endif + endif + endfor + + for l:file in l:toRemove + call remove(l:globList, index(l:globList, l:file)) + endfor + endif + + return l:globList +endfunction + +" FUNCTION: TreeDirNode.GetSelected() {{{1 +" Returns the current node if it is a dir node, or else returns the current +" nodes parent +unlet s:TreeDirNode.GetSelected +function! s:TreeDirNode.GetSelected() + let currentDir = g:NERDTreeFileNode.GetSelected() + if currentDir !=# {} && !currentDir.isRoot() + if currentDir.path.isDirectory ==# 0 + let currentDir = currentDir.parent + endif + endif + return currentDir +endfunction + +" FUNCTION: TreeDirNode.getVisibleChildCount() {{{1 +" Returns the number of visible children this node has +function! s:TreeDirNode.getVisibleChildCount() + return len(self.getVisibleChildren()) +endfunction + +" FUNCTION: TreeDirNode.getVisibleChildren() {{{1 +" Returns a list of children to display for this node, in the correct order +" +" Return: +" an array of treenodes +function! s:TreeDirNode.getVisibleChildren() + let toReturn = [] + for i in self.children + if i.path.ignore(self.getNerdtree()) ==# 0 + call add(toReturn, i) + endif + endfor + return toReturn +endfunction + +" FUNCTION: TreeDirNode.hasVisibleChildren() {{{1 +" returns 1 if this node has any childre, 0 otherwise.. +function! s:TreeDirNode.hasVisibleChildren() + return self.getVisibleChildCount() !=# 0 +endfunction + +" FUNCTION: TreeDirNode.isCascadable() {{{1 +" true if this dir has only one visible child that is also a dir +" false if this dir is bookmarked or symlinked. Why? Two reasons: +" 1. If cascaded, we don't know which dir is bookmarked or is a symlink. +" 2. If the parent is a symlink or is bookmarked, you end up with unparsable +" text, and NERDTree cannot get the path of any child node. +" Also, return false if this directory is the tree root, which should never be +" part of a cascade. +function! s:TreeDirNode.isCascadable() + if g:NERDTreeCascadeSingleChildDir ==# 0 + return 0 + endif + + if self.isRoot() + return 0 + endif + + if self.path.isSymLink + return 0 + endif + + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self.path) + return 0 + endif + endfor + + let c = self.getVisibleChildren() + return len(c) ==# 1 && c[0].path.isDirectory +endfunction + +" FUNCTION: TreeDirNode._initChildren() {{{1 +" Removes all childen from this node and re-reads them +" +" Args: +" silent: 1 if the function should not echo any 'please wait' messages for +" large directories +" +" Return: the number of child nodes read +function! s:TreeDirNode._initChildren(silent) + "remove all the current child nodes + let self.children = [] + + let files = self._glob('*', 1) + self._glob('.*', 0) + + if !a:silent && len(files) > g:NERDTreeNotificationThreshold + call nerdtree#echo('Please wait, caching a large dir ...') + endif + + let invalidFilesFound = 0 + for i in files + try + let path = g:NERDTreePath.New(i) + call self.createChild(path, 0) + call g:NERDTreePathNotifier.NotifyListeners('init', path, self.getNerdtree(), {}) + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound += 1 + endtry + endfor + + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder + call self.sortChildren() + + call nerdtree#echo('') + + if invalidFilesFound + call nerdtree#echoWarning(invalidFilesFound . ' file(s) could not be loaded into the NERD tree') + endif + return self.getChildCount() +endfunction + +" FUNCTION: TreeDirNode.New(path, nerdtree) {{{1 +" Return a new TreeDirNode object with the given path and parent. +" +" Args: +" path: dir that the node represents +" nerdtree: the tree the node belongs to +function! s:TreeDirNode.New(path, nerdtree) + if a:path.isDirectory !=# 1 + throw 'NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object.' + endif + + let newTreeNode = copy(self) + let newTreeNode.path = a:path + + let newTreeNode.isOpen = 0 + let newTreeNode.children = [] + + let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree + + return newTreeNode +endfunction + +" FUNCTION: TreeDirNode.open([options]) {{{1 +" Open this directory node in the current tree or elsewhere if special options +" are provided. Return 0 if options were processed. Otherwise, return the +" number of new cached nodes. +function! s:TreeDirNode.open(...) + let l:options = a:0 ? a:1 : {} + + " If special options were specified, process them and return. + if has_key(l:options, 'where') && !empty(l:options['where']) + let l:opener = g:NERDTreeOpener.New(self.path, l:options) + call l:opener.open(self) + return 0 + endif + + " Open any ancestors of this node that render within the same cascade. + let l:parent = self.parent + while !empty(l:parent) && !l:parent.isRoot() + if index(l:parent.getCascade(), self) >= 0 + let l:parent.isOpen = 1 + let l:parent = l:parent.parent + else + break + endif + endwhile + + let self.isOpen = 1 + + let l:numChildrenCached = 0 + if empty(self.children) + let l:numChildrenCached = self._initChildren(0) + endif + + return l:numChildrenCached +endfunction + +" FUNCTION: TreeDirNode.openAlong([opts]) {{{1 +" recursive open the dir if it has only one directory child. +" +" return the level of opened directories. +function! s:TreeDirNode.openAlong(...) + let opts = a:0 ? a:1 : {} + let level = 0 + + let node = self + while node.path.isDirectory + call node.open(opts) + let level += 1 + if node.getVisibleChildCount() ==# 1 + let node = node.getChildByIndex(0, 1) + else + break + endif + endwhile + return level +endfunction + +" FUNCTION: TreeDirNode.openExplorer() {{{1 +" Open an explorer window for this node in the previous window. The explorer +" can be a NERDTree window or a netrw window. +function! s:TreeDirNode.openExplorer() + execute 'wincmd p' + execute 'edit '.self.path.str({'format':'Edit'}) +endfunction + +" FUNCTION: TreeDirNode.openInNewTab(options) {{{1 +unlet s:TreeDirNode.openInNewTab +function! s:TreeDirNode.openInNewTab(options) + call nerdtree#deprecated('TreeDirNode.openInNewTab', 'is deprecated, use open() instead') + call self.open({'where': 't'}) +endfunction + +" FUNCTION: TreeDirNode._openInNewTab() {{{1 +function! s:TreeDirNode._openInNewTab() + tabnew + call g:NERDTreeCreator.CreateTabTree(self.path.str()) +endfunction + +" FUNCTION: TreeDirNode.openRecursively() {{{1 +" Open this directory node and any descendant directory nodes whose pathnames +" are not ignored. +function! s:TreeDirNode.openRecursively() + silent call self.open() + + for l:child in self.children + if l:child.path.isDirectory && !l:child.path.ignore(l:child.getNerdtree()) + call l:child.openRecursively() + endif + endfor +endfunction + +" FUNCTION: TreeDirNode.refresh() {{{1 +function! s:TreeDirNode.refresh() + call self.path.refresh(self.getNerdtree()) + + "if this node was ever opened, refresh its children + if self.isOpen || !empty(self.children) + let files = self._glob('*', 1) + self._glob('.*', 0) + let newChildNodes = [] + let invalidFilesFound = 0 + for i in files + try + "create a new path and see if it exists in this nodes children + let path = g:NERDTreePath.New(i) + let newNode = self.getChild(path) + if newNode !=# {} + call newNode.refresh() + call add(newChildNodes, newNode) + + "the node doesnt exist so create it + else + let newNode = g:NERDTreeFileNode.New(path, self.getNerdtree()) + let newNode.parent = self + call add(newChildNodes, newNode) + endif + catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ + let invalidFilesFound = 1 + endtry + endfor + + "swap this nodes children out for the children we just read/refreshed + let self.children = newChildNodes + call self.sortChildren() + + if invalidFilesFound + call nerdtree#echoWarning('some files could not be loaded into the NERD tree') + endif + endif +endfunction + +" FUNCTION: TreeDirNode.refreshFlags() {{{1 +unlet s:TreeDirNode.refreshFlags +function! s:TreeDirNode.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) + for i in self.children + call i.refreshFlags() + endfor +endfunction + +" FUNCTION: TreeDirNode.refreshDirFlags() {{{1 +function! s:TreeDirNode.refreshDirFlags() + call self.path.refreshFlags(self.getNerdtree()) +endfunction + +" FUNCTION: TreeDirNode.reveal(path) {{{1 +" reveal the given path, i.e. cache and open all treenodes needed to display it +" in the UI +" Returns the revealed node +function! s:TreeDirNode.reveal(path, ...) + let opts = a:0 ? a:1 : {} + + if !a:path.isUnder(self.path) + throw 'NERDTree.InvalidArgumentsError: ' . a:path.str() . ' should be under ' . self.path.str() + endif + + call self.open() + + if self.path.equals(a:path.getParent()) + let n = self.findNode(a:path) + " We may be looking for a newly-saved file that isn't in the tree yet. + if n ==# {} + call self.refresh() + let n = self.findNode(a:path) + endif + if has_key(opts, 'open') + call n.open() + endif + return n + endif + + let p = a:path + while !p.getParent().equals(self.path) + let p = p.getParent() + endwhile + + let n = self.findNode(p) + return n.reveal(a:path, opts) +endfunction + +" FUNCTION: TreeDirNode.removeChild(treenode) {{{1 +" Remove the given treenode from self.children. +" Throws NERDTree.ChildNotFoundError if the node is not found. +" +" Args: +" treenode: the node object to remove +function! s:TreeDirNode.removeChild(treenode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:treenode) + call remove(self.children, i) + return + endif + endfor + + throw 'NERDTree.ChildNotFoundError: child node was not found' +endfunction + +" FUNCTION: TreeDirNode.sortChildren() {{{1 +" Sort self.children by alphabetical order and directory priority. +function! s:TreeDirNode.sortChildren() + if count(g:NERDTreeSortOrder, '*') < 1 + call add(g:NERDTreeSortOrder, '*') + endif + let CompareFunc = function('nerdtree#compareNodes') + call sort(self.children, CompareFunc) + let g:NERDTreeOldSortOrder = g:NERDTreeSortOrder +endfunction + +" FUNCTION: TreeDirNode.toggleOpen([options]) {{{1 +" Opens this directory if it is closed and vice versa +function! s:TreeDirNode.toggleOpen(...) + let opts = a:0 ? a:1 : {} + if self.isOpen ==# 1 + call self.close() + else + if g:NERDTreeCascadeOpenSingleChildDir ==# 0 + call self.open(opts) + else + call self.openAlong(opts) + endif + endif +endfunction + +" FUNCTION: TreeDirNode.transplantChild(newNode) {{{1 +" Replaces the child of this with the given node (where the child node's full +" path matches a:newNode's fullpath). The search for the matching node is +" non-recursive +" +" Arg: +" newNode: the node to graft into the tree +function! s:TreeDirNode.transplantChild(newNode) + for i in range(0, self.getChildCount()-1) + if self.children[i].equals(a:newNode) + let self.children[i] = a:newNode + let a:newNode.parent = self + break + endif + endfor +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim new file mode 100644 index 00000000..957b98ac --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/tree_file_node.vim @@ -0,0 +1,349 @@ +" ============================================================================ +" CLASS: TreeFileNode +" +" This class is the parent of the TreeDirNode class and is the 'Component' +" part of the composite design pattern between the NERDTree node classes. +" ============================================================================ + + +let s:TreeFileNode = {} +let g:NERDTreeFileNode = s:TreeFileNode + +" FUNCTION: TreeFileNode.activate(...) {{{1 +function! s:TreeFileNode.activate(...) + call self.open(a:0 ? a:1 : {}) +endfunction + +" FUNCTION: TreeFileNode.bookmark(name) {{{1 +" bookmark this node with a:name +function! s:TreeFileNode.bookmark(name) + + " if a bookmark exists with the same name and the node is cached then save + " it so we can update its display string + let oldMarkedNode = {} + try + let oldMarkedNode = g:NERDTreeBookmark.GetNodeForName(a:name, 1, self.getNerdtree()) + catch /^NERDTree.BookmarkNotFoundError/ + catch /^NERDTree.BookmarkedNodeNotFoundError/ + endtry + + call g:NERDTreeBookmark.AddBookmark(a:name, self.path) + call self.path.cacheDisplayString() + call g:NERDTreeBookmark.Write() + + if !empty(oldMarkedNode) + call oldMarkedNode.path.cacheDisplayString() + endif +endfunction + +" FUNCTION: TreeFileNode.cacheParent() {{{1 +" initializes self.parent if it isnt already +function! s:TreeFileNode.cacheParent() + if empty(self.parent) + let parentPath = self.path.getParent() + if parentPath.equals(self.path) + throw 'NERDTree.CannotCacheParentError: already at root' + endif + let self.parent = s:TreeFileNode.New(parentPath, self.getNerdtree()) + endif +endfunction + +" FUNCTION: TreeFileNode.clearBookmarks() {{{1 +function! s:TreeFileNode.clearBookmarks() + for i in g:NERDTreeBookmark.Bookmarks() + if i.path.equals(self.path) + call i.delete() + end + endfor + call self.path.cacheDisplayString() +endfunction + +" FUNCTION: TreeFileNode.copy(dest) {{{1 +function! s:TreeFileNode.copy(dest) + call self.path.copy(a:dest) + let newPath = g:NERDTreePath.New(a:dest) + let parent = self.getNerdtree().root.findNode(newPath.getParent()) + if !empty(parent) + call parent.refresh() + return parent.findNode(newPath) + else + return {} + endif +endfunction + +" FUNCTION: TreeFileNode.delete {{{1 +" Removes this node from the tree and calls the Delete method for its path obj +function! s:TreeFileNode.delete() + call self.path.delete() + call self.parent.removeChild(self) +endfunction + +" FUNCTION: TreeFileNode.displayString() {{{1 +" +" Returns a string that specifies how the node should be represented as a +" string +" +" Return: +" a string that can be used in the view to represent this node +function! s:TreeFileNode.displayString() + return self.path.flagSet.renderToString() . self.path.displayString() +endfunction + +" FUNCTION: TreeFileNode.equals(treenode) {{{1 +" +" Compares this treenode to the input treenode and returns 1 if they are the +" same node. +" +" Use this method instead of == because sometimes when the treenodes contain +" many children, vim seg faults when doing == +" +" Args: +" treenode: the other treenode to compare to +function! s:TreeFileNode.equals(treenode) + return self.path.str() ==# a:treenode.path.str() +endfunction + +" FUNCTION: TreeFileNode.findNode(path) {{{1 +" Returns self if this node.path.Equals the given path. +" Returns {} if not equal. +" +" Args: +" path: the path object to compare against +function! s:TreeFileNode.findNode(path) + if a:path.equals(self.path) + return self + endif + return {} +endfunction + +" FUNCTION: TreeFileNode.findSibling(direction) {{{1 +" Find the next or previous sibling of this node. +" +" Args: +" direction: 0 for previous, 1 for next +" +" Return: +" The next/previous TreeFileNode object or an empty dictionary if not found. +function! s:TreeFileNode.findSibling(direction) + + " There can be no siblings if there is no parent. + if empty(self.parent) + return {} + endif + + let l:nodeIndex = self.parent.getChildIndex(self.path) + + if l:nodeIndex == -1 + return {} + endif + + " Get the next index to begin the search. + let l:nodeIndex += a:direction ? 1 : -1 + + while 0 <= l:nodeIndex && l:nodeIndex < self.parent.getChildCount() + + " Return the next node if it is not ignored. + if !self.parent.children[l:nodeIndex].path.ignore(self.getNerdtree()) + return self.parent.children[l:nodeIndex] + endif + + let l:nodeIndex += a:direction ? 1 : -1 + endwhile + + return {} +endfunction + +" FUNCTION: TreeFileNode.getNerdtree(){{{1 +function! s:TreeFileNode.getNerdtree() + return self._nerdtree +endfunction + +" FUNCTION: TreeFileNode.GetRootForTab(){{{1 +" get the root node for this tab +function! s:TreeFileNode.GetRootForTab() + if g:NERDTree.ExistsForTab() + return getbufvar(t:NERDTreeBufName, 'NERDTree').root + end + return {} +endfunction + +" FUNCTION: TreeFileNode.GetSelected() {{{1 +" If the cursor is currently positioned on a tree node, return the node. +" Otherwise, return the empty dictionary. +function! s:TreeFileNode.GetSelected() + + try + let l:path = b:NERDTree.ui.getPath(line('.')) + + if empty(l:path) + return {} + endif + + return b:NERDTree.root.findNode(l:path) + catch + return {} + endtry +endfunction + +" FUNCTION: TreeFileNode.isVisible() {{{1 +" returns 1 if this node should be visible according to the tree filters and +" hidden file filters (and their on/off status) +function! s:TreeFileNode.isVisible() + return !self.path.ignore(self.getNerdtree()) +endfunction + +" FUNCTION: TreeFileNode.isRoot() {{{1 +function! s:TreeFileNode.isRoot() + if !g:NERDTree.ExistsForBuf() + throw 'NERDTree.NoTreeError: No tree exists for the current buffer' + endif + + return self.equals(self.getNerdtree().root) +endfunction + +" FUNCTION: TreeFileNode.New(path, nerdtree) {{{1 +" Returns a new TreeNode object with the given path and parent +" +" Args: +" path: file/dir that the node represents +" nerdtree: the tree the node belongs to +function! s:TreeFileNode.New(path, nerdtree) + if a:path.isDirectory + return g:NERDTreeDirNode.New(a:path, a:nerdtree) + else + let newTreeNode = copy(self) + let newTreeNode.path = a:path + let newTreeNode.parent = {} + let newTreeNode._nerdtree = a:nerdtree + return newTreeNode + endif +endfunction + +" FUNCTION: TreeFileNode.open() {{{1 +function! s:TreeFileNode.open(...) + let opts = a:0 ? a:1 : {} + let opener = g:NERDTreeOpener.New(self.path, opts) + call opener.open(self) +endfunction + +" FUNCTION: TreeFileNode.openSplit() {{{1 +" Open this node in a new window +function! s:TreeFileNode.openSplit() + call nerdtree#deprecated('TreeFileNode.openSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'h'}) +endfunction + +" FUNCTION: TreeFileNode.openVSplit() {{{1 +" Open this node in a new vertical window +function! s:TreeFileNode.openVSplit() + call nerdtree#deprecated('TreeFileNode.openVSplit', 'is deprecated, use .open() instead.') + call self.open({'where': 'v'}) +endfunction + +" FUNCTION: TreeFileNode.openInNewTab(options) {{{1 +function! s:TreeFileNode.openInNewTab(options) + call nerdtree#deprecated('TreeFileNode.openinNewTab', 'is deprecated, use .open() instead.') + call self.open(extend({'where': 't'}, a:options)) +endfunction + +" FUNCTION: TreeFileNode.openExplorer() +function! s:TreeFileNode.openExplorer() + execute 'wincmd p' + execute 'edit '.self.path.getParent().str({'format':'Edit'}) +endfunction + +" FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{1 +" Places the cursor on the line number this node is rendered on +" +" Args: +" isJump: 1 if this cursor movement should be counted as a jump by vim +" recurseUpward: try to put the cursor on the parent if the this node isnt +" visible +function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) + let ln = self.getNerdtree().ui.getLineNum(self) + if ln != -1 + if a:isJump + mark ' + endif + call cursor(ln, col('.')) + else + if a:recurseUpward + let node = self + while node != {} && self.getNerdtree().ui.getLineNum(node) ==# -1 + let node = node.parent + call node.open() + endwhile + call self._nerdtree.render() + call node.putCursorHere(a:isJump, 0) + endif + endif +endfunction + +" FUNCTION: TreeFileNode.refresh() {{{1 +function! s:TreeFileNode.refresh() + call self.path.refresh(self.getNerdtree()) +endfunction + +" FUNCTION: TreeFileNode.refreshFlags() {{{1 +function! s:TreeFileNode.refreshFlags() + call self.path.refreshFlags(self.getNerdtree()) +endfunction + +" FUNCTION: TreeFileNode.rename() {{{1 +" Calls the rename method for this nodes path obj +function! s:TreeFileNode.rename(newName) + let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') + call self.path.rename(newName) + call self.parent.removeChild(self) + + let parentPath = self.path.getParent() + let newParent = self.getNerdtree().root.findNode(parentPath) + + if newParent != {} + call newParent.createChild(self.path, 1) + call newParent.refresh() + endif +endfunction + +" FUNCTION: TreeFileNode.renderToString {{{1 +" returns a string representation for this tree to be rendered in the view +function! s:TreeFileNode.renderToString() + return self._renderToString(0, 0) +endfunction + +" Args: +" depth: the current depth in the tree for this call +" drawText: 1 if we should actually draw the line for this node (if 0 then the +" child nodes are rendered only) +" for each depth in the tree +function! s:TreeFileNode._renderToString(depth, drawText) + let output = '' + if a:drawText ==# 1 + + let treeParts = repeat(' ', a:depth - 1) + let treeParts .= (self.path.isDirectory || g:NERDTreeDirArrowExpandable ==# '' ? '' : ' ') + + let line = treeParts . self.displayString() + let output = output . line . "\n" + endif + + " if the node is an open dir, draw its children + if self.path.isDirectory ==# 1 && self.isOpen ==# 1 + + let childNodesToDraw = self.getVisibleChildren() + + if self.isCascadable() && a:depth > 0 + + let output = output . childNodesToDraw[0]._renderToString(a:depth, 0) + + elseif len(childNodesToDraw) > 0 + for i in childNodesToDraw + let output = output . i._renderToString(a:depth + 1, 1) + endfor + endif + endif + + return output +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/lib/nerdtree/ui.vim b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim new file mode 100644 index 00000000..a481ba47 --- /dev/null +++ b/sources_non_forked/nerdtree/lib/nerdtree/ui.vim @@ -0,0 +1,532 @@ +" ============================================================================ +" CLASS: UI +" ============================================================================ + + +let s:UI = {} +let g:NERDTreeUI = s:UI + +" FUNCTION: s:UI.centerView() {{{1 +" centers the nerd tree window around the cursor (provided the nerd tree +" options permit) +function! s:UI.centerView() + if g:NERDTreeAutoCenter + let current_line = winline() + let lines_to_top = current_line + let lines_to_bottom = winheight(g:NERDTree.GetWinNum()) - current_line + if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold + normal! zz + endif + endif +endfunction + +" FUNCTION: s:UI._dumpHelp {{{1 +" prints out the quick help +function! s:UI._dumpHelp() + if self.getShowHelp() + let help = "\" NERDTree (" . nerdtree#version() . ") quickhelp~\n" + let help .= "\" ============================\n" + let help .= "\" File node mappings~\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 3 ? 'single' : 'double') ."-click,\n" + if self.nerdtree.isTabTree() + let help .= '" '. g:NERDTreeMapActivateNode .": open in prev window\n" + else + let help .= '" '. g:NERDTreeMapActivateNode .": open in current window\n" + endif + if self.nerdtree.isTabTree() + let help .= '" '. g:NERDTreeMapPreview .": preview\n" + endif + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= "\" middle-click,\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Directory node mappings~\n" + let help .= '" '. (g:NERDTreeMouseMode ==# 1 ? 'double' : 'single') ."-click,\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open & close node\n" + let help .= '" '. g:NERDTreeMapOpenRecursively .": recursively open node\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapCloseDir .": close parent of node\n" + let help .= '" '. g:NERDTreeMapCloseChildren .": close all child nodes of\n" + let help .= "\" current node recursively\n" + let help .= "\" middle-click,\n" + let help .= '" '. g:NERDTreeMapOpenExpl.": explore selected dir\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark table mappings~\n" + let help .= "\" double-click,\n" + let help .= '" '. g:NERDTreeMapActivateNode .": open bookmark\n" + let help .= '" '. g:NERDTreeMapPreview .": preview file\n" + let help .= '" '. g:NERDTreeMapPreview .": find dir in tree\n" + let help .= '" '. g:NERDTreeMapOpenInTab.": open in new tab\n" + let help .= '" '. g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" + let help .= '" '. g:NERDTreeMapOpenSplit .": open split\n" + let help .= '" '. g:NERDTreeMapPreviewSplit .": preview split\n" + let help .= '" '. g:NERDTreeMapOpenVSplit .": open vsplit\n" + let help .= '" '. g:NERDTreeMapPreviewVSplit .": preview vsplit\n" + let help .= '" '. g:NERDTreeMapCustomOpen .": custom open\n" + let help .= '" '. g:NERDTreeMapDeleteBookmark .": delete bookmark\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree navigation mappings~\n" + let help .= '" '. g:NERDTreeMapJumpRoot .": go to root\n" + let help .= '" '. g:NERDTreeMapJumpParent .": go to parent\n" + let help .= '" '. g:NERDTreeMapJumpFirstChild .": go to first child\n" + let help .= '" '. g:NERDTreeMapJumpLastChild .": go to last child\n" + let help .= '" '. g:NERDTreeMapJumpNextSibling .": go to next sibling\n" + let help .= '" '. g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Filesystem mappings~\n" + let help .= '" '. g:NERDTreeMapChangeRoot .": change tree root to the\n" + let help .= "\" selected dir\n" + let help .= '" '. g:NERDTreeMapUpdir .": move tree root up a dir\n" + let help .= '" '. g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" + let help .= "\" but leave old root open\n" + let help .= '" '. g:NERDTreeMapRefresh .": refresh cursor dir\n" + let help .= '" '. g:NERDTreeMapRefreshRoot .": refresh current root\n" + let help .= '" '. g:NERDTreeMapMenu .": Show menu\n" + let help .= '" '. g:NERDTreeMapChdir .":change the CWD to the\n" + let help .= "\" selected dir\n" + let help .= '" '. g:NERDTreeMapCWD .":change tree root to CWD\n" + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Tree filtering mappings~\n" + let help .= '" '. g:NERDTreeMapToggleHidden .': hidden files (' . (self.getShowHidden() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFilters .': file filters (' . (self.isIgnoreFilterEnabled() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleFiles .': files (' . (self.getShowFiles() ? 'on' : 'off') . ")\n" + let help .= '" '. g:NERDTreeMapToggleBookmarks .': bookmarks (' . (self.getShowBookmarks() ? 'on' : 'off') . ")\n" + + " add quickhelp entries for each custom key map + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Custom mappings~\n" + for i in g:NERDTreeKeyMap.All() + if !empty(i.quickhelpText) + let help .= '" '. i.key .': '. i.quickhelpText ."\n" + endif + endfor + + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Other mappings~\n" + let help .= '" '. g:NERDTreeMapQuit .": Close the NERDTree window\n" + let help .= '" '. g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let help .= "\" the NERDTree window\n" + let help .= '" '. g:NERDTreeMapHelp .": toggle help\n" + let help .= "\"\n\" ----------------------------\n" + let help .= "\" Bookmark commands~\n" + let help .= "\" :Bookmark []\n" + let help .= "\" :BookmarkToRoot \n" + let help .= "\" :RevealBookmark \n" + let help .= "\" :OpenBookmark \n" + let help .= "\" :ClearBookmarks []\n" + let help .= "\" :ClearAllBookmarks\n" + let help .= "\" :ReadBookmarks\n" + let help .= "\" :WriteBookmarks\n" + let help .= "\" :EditBookmarks\n" + silent! put =help + elseif !self.isMinimal() + let help ='" Press '. g:NERDTreeMapHelp ." for help\n" + silent! put =help + endif +endfunction + + +" FUNCTION: s:UI.new(nerdtree) {{{1 +function! s:UI.New(nerdtree) + let newObj = copy(self) + let newObj.nerdtree = a:nerdtree + let newObj._showHelp = 0 + let newObj._ignoreEnabled = 1 + let newObj._showFiles = g:NERDTreeShowFiles + let newObj._showHidden = g:NERDTreeShowHidden + let newObj._showBookmarks = g:NERDTreeShowBookmarks + + return newObj +endfunction + +" FUNCTION: s:UI.getPath(ln) {{{1 +" Return the Path object for the node that is rendered on the given line +" number. If the 'up a dir' line is selected, return the Path object for +" the parent of the root. Return the empty dictionary if the given line +" does not reference a tree node. +function! s:UI.getPath(ln) + let line = getline(a:ln) + + let rootLine = self.getRootLineNum() + + if a:ln ==# rootLine + return self.nerdtree.root.path + endif + + if line ==# s:UI.UpDirLine() + return self.nerdtree.root.path.getParent() + endif + + if a:ln < rootLine + return {} + endif + + let indent = self._indentLevelFor(line) + + " remove the tree parts and the leading space + let curFile = self._stripMarkup(line) + + let dir = '' + let lnum = a:ln + while lnum > 0 + let lnum = lnum - 1 + let curLine = getline(lnum) + let curLineStripped = self._stripMarkup(curLine) + + " have we reached the top of the tree? + if lnum ==# rootLine + let dir = self.nerdtree.root.path.str({'format': 'UI'}) . dir + break + endif + if curLineStripped =~# '/$' + let lpindent = self._indentLevelFor(curLine) + if lpindent < indent + let indent = indent - 1 + + let dir = substitute (curLineStripped,'^\\', '', '') . dir + continue + endif + endif + endwhile + let curFile = self.nerdtree.root.path.drive . dir . curFile + let toReturn = g:NERDTreePath.New(curFile) + return toReturn +endfunction + +" FUNCTION: s:UI.getLineNum(node) {{{1 +" Return the line number where the given node is rendered. Return -1 if the +" given node is not visible. +function! s:UI.getLineNum(node) + + if a:node.isRoot() + return self.getRootLineNum() + endif + + let l:pathComponents = [substitute(self.nerdtree.root.path.str({'format': 'UI'}), '/\s*$', '', '')] + let l:currentPathComponent = 1 + + let l:fullPath = a:node.path.str({'format': 'UI'}) + + for l:lineNumber in range(self.getRootLineNum() + 1, line('$')) + let l:currentLine = getline(l:lineNumber) + let l:indentLevel = self._indentLevelFor(l:currentLine) + + if l:indentLevel !=# l:currentPathComponent + continue + endif + + let l:currentLine = self._stripMarkup(l:currentLine) + let l:currentPath = join(l:pathComponents, '/') . '/' . l:currentLine + + " Directories: If the current path 'starts with' the full path, then + " either the paths are equal or the line is a cascade containing the + " full path. + if l:fullPath[-1:] ==# '/' && stridx(l:currentPath, l:fullPath) ==# 0 + return l:lineNumber + endif + + " Files: The paths must exactly match. + if l:fullPath ==# l:currentPath + return l:lineNumber + endif + + " Otherwise: If the full path starts with the current path and the + " current path is a directory, we add a new path component. + if stridx(l:fullPath, l:currentPath) ==# 0 && l:currentPath[-1:] ==# '/' + let l:currentLine = substitute(l:currentLine, '/\s*$', '', '') + call add(l:pathComponents, l:currentLine) + let l:currentPathComponent += 1 + endif + endfor + + return -1 +endfunction + +" FUNCTION: s:UI.getRootLineNum(){{{1 +" gets the line number of the root node +function! s:UI.getRootLineNum() + let rootLine = 1 + while rootLine <= line('$') && getline(rootLine) !~# '^\(/\|<\)' + let rootLine = rootLine + 1 + endwhile + return rootLine +endfunction + +" FUNCTION: s:UI.getShowBookmarks() {{{1 +function! s:UI.getShowBookmarks() + return self._showBookmarks +endfunction + +" FUNCTION: s:UI.getShowFiles() {{{1 +function! s:UI.getShowFiles() + return self._showFiles +endfunction + +" FUNCTION: s:UI.getShowHelp() {{{1 +function! s:UI.getShowHelp() + return self._showHelp +endfunction + +" FUNCTION: s:UI.getShowHidden() {{{1 +function! s:UI.getShowHidden() + return self._showHidden +endfunction + +" FUNCTION: s:UI._indentLevelFor(line) {{{1 +function! s:UI._indentLevelFor(line) + " Replace multi-character DirArrows with a single space so the + " indentation calculation doesn't get messed up. + if g:NERDTreeDirArrowExpandable ==# '' + let l:line = ' '.a:line + else + let l:line = substitute(substitute(a:line, '\V'.g:NERDTreeDirArrowExpandable, ' ', ''), '\V'.g:NERDTreeDirArrowCollapsible, ' ', '') + endif + let leadChars = match(l:line, '\M\[^ ]') + return leadChars / s:UI.IndentWid() +endfunction + +" FUNCTION: s:UI.IndentWid() {{{1 +function! s:UI.IndentWid() + return 2 +endfunction + +" FUNCTION: s:UI.isIgnoreFilterEnabled() {{{1 +function! s:UI.isIgnoreFilterEnabled() + return self._ignoreEnabled ==# 1 +endfunction + +" FUNCTION: s:UI.isMinimal() {{{1 +function! s:UI.isMinimal() + return g:NERDTreeMinimalUI +endfunction + +" FUNCTION: s:UI.MarkupReg() {{{1 +function! s:UI.MarkupReg() + return '^ *['.g:NERDTreeDirArrowExpandable.g:NERDTreeDirArrowCollapsible.']\? ' +endfunction + +" FUNCTION: s:UI._renderBookmarks {{{1 +function! s:UI._renderBookmarks() + + if !self.isMinimal() + call setline(line('.')+1, '>----------Bookmarks----------') + call cursor(line('.')+1, col('.')) + endif + + if g:NERDTreeBookmarksSort ==# 1 || g:NERDTreeBookmarksSort ==# 2 + call g:NERDTreeBookmark.SortBookmarksList() + endif + + for i in g:NERDTreeBookmark.Bookmarks() + call setline(line('.')+1, i.str()) + call cursor(line('.')+1, col('.')) + endfor + + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) +endfunction + +" FUNCTION: s:UI.restoreScreenState() {{{1 +" +" Sets the screen state back to what it was when nerdtree#saveScreenState was last +" called. +" +" Assumes the cursor is in the NERDTree window +function! s:UI.restoreScreenState() + if !has_key(self, '_screenState') + return + endif + call nerdtree#exec('silent vertical resize ' . self._screenState['oldWindowSize'], 1) + + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(self._screenState['oldTopLine'], 0) + normal! zt + call setpos('.', self._screenState['oldPos']) + let &scrolloff=old_scrolloff +endfunction + +" FUNCTION: s:UI.saveScreenState() {{{1 +" Saves the current cursor position in the current buffer and the window +" scroll position +function! s:UI.saveScreenState() + let win = winnr() + let self._screenState = {} + try + call g:NERDTree.CursorToTreeWin() + let self._screenState['oldPos'] = getpos('.') + let self._screenState['oldTopLine'] = line('w0') + let self._screenState['oldWindowSize'] = winnr('$')==1 ? g:NERDTreeWinSize : winwidth('') + call nerdtree#exec(win . 'wincmd w', 1) + catch + endtry +endfunction + +" FUNCTION: s:UI.setShowHidden(val) {{{1 +function! s:UI.setShowHidden(val) + let self._showHidden = a:val +endfunction + +" FUNCTION: s:UI._stripMarkup(line){{{1 +" find the filename in the given line, and return it. +" +" Args: +" line: the subject line +function! s:UI._stripMarkup(line) + let l:line = substitute(a:line, '^.\{-}' . g:NERDTreeNodeDelimiter, '', '') + return substitute(l:line, g:NERDTreeNodeDelimiter.'.*$', '', '') +endfunction + +" FUNCTION: s:UI.render() {{{1 +function! s:UI.render() + setlocal noreadonly modifiable + + " remember the top line of the buffer and the current line so we can + " restore the view exactly how it was + let curLine = line('.') + let curCol = col('.') + let topLine = line('w0') + + " delete all lines in the buffer (being careful not to clobber a register) + silent 1,$delete _ + + call self._dumpHelp() + + " delete the blank line before the help and add one after it + if !self.isMinimal() + call setline(line('.')+1, '') + call cursor(line('.')+1, col('.')) + endif + + if self.getShowBookmarks() + call self._renderBookmarks() + endif + + " add the 'up a dir' line + if !self.isMinimal() + call setline(line('.')+1, s:UI.UpDirLine()) + call cursor(line('.')+1, col('.')) + endif + + " draw the header line + let header = self.nerdtree.root.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) + call setline(line('.')+1, header) + call cursor(line('.')+1, col('.')) + + " draw the tree + silent put =self.nerdtree.root.renderToString() + + " delete the blank line at the top of the buffer + silent 1,1delete _ + + " restore the view + let old_scrolloff=&scrolloff + let &scrolloff=0 + call cursor(topLine, 1) + normal! zt + call cursor(curLine, curCol) + let &scrolloff = old_scrolloff + + setlocal readonly nomodifiable +endfunction + + +" FUNCTION: UI.renderViewSavingPosition {{{1 +" Renders the tree and ensures the cursor stays on the current node or the +" current nodes parent if it is no longer available upon re-rendering +function! s:UI.renderViewSavingPosition() + let currentNode = g:NERDTreeFileNode.GetSelected() + + " go up the tree till we find a node that will be visible or till we run + " out of nodes + while currentNode !=# {} && !currentNode.isVisible() && !currentNode.isRoot() + let currentNode = currentNode.parent + endwhile + + call self.render() + + if currentNode !=# {} + call currentNode.putCursorHere(0, 0) + endif +endfunction + +" FUNCTION: s:UI.toggleHelp() {{{1 +function! s:UI.toggleHelp() + let self._showHelp = !self._showHelp +endfunction + +" FUNCTION: s:UI.toggleIgnoreFilter() {{{1 +" toggles the use of the NERDTreeIgnore option +function! s:UI.toggleIgnoreFilter() + let self._ignoreEnabled = !self._ignoreEnabled + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowBookmarks() {{{1 +" Toggle the visibility of the Bookmark table. +function! s:UI.toggleShowBookmarks() + let self._showBookmarks = !self._showBookmarks + + if self.getShowBookmarks() + call self.nerdtree.render() + call g:NERDTree.CursorToBookmarkTable() + else + + if empty(g:NERDTreeFileNode.GetSelected()) + call b:NERDTree.root.putCursorHere(0, 0) + normal! 0 + endif + + call self.renderViewSavingPosition() + endif + + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowFiles() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowFiles() + let self._showFiles = !self._showFiles + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleShowHidden() {{{1 +" toggles the display of hidden files +function! s:UI.toggleShowHidden() + let self._showHidden = !self._showHidden + call self.renderViewSavingPosition() + call self.centerView() +endfunction + +" FUNCTION: s:UI.toggleZoom() {{{1 +" zoom (maximize/minimize) the NERDTree window +function! s:UI.toggleZoom() + if exists('b:NERDTreeZoomed') && b:NERDTreeZoomed + call nerdtree#exec('silent vertical resize '. g:NERDTreeWinSize, 1) + let b:NERDTreeZoomed = 0 + else + call nerdtree#exec('vertical resize '. get(g:, 'NERDTreeWinSizeMax', ''), 1) + let b:NERDTreeZoomed = 1 + endif +endfunction + +" FUNCTION: s:UI.UpDirLine() {{{1 +function! s:UI.UpDirLine() + return '.. (up a dir)' +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim new file mode 100644 index 00000000..fb6c4862 --- /dev/null +++ b/sources_non_forked/nerdtree/nerdtree_plugin/exec_menuitem.vim @@ -0,0 +1,40 @@ +" ============================================================================ +" File: exec_menuitem.vim +" Description: plugin for NERD Tree that provides an execute file menu item +" Maintainer: Martin Grenfell +" 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. +" +" ============================================================================ +if exists('g:loaded_nerdtree_exec_menuitem') + finish +endif +let g:loaded_nerdtree_exec_menuitem = 1 + +call NERDTreeAddMenuItem({ + \ 'text': '(!)Execute file', + \ 'shortcut': '!', + \ 'callback': 'NERDTreeExecFile', + \ 'isActiveCallback': 'NERDTreeExecFileActive' }) + +function! NERDTreeExecFileActive() + let node = g:NERDTreeFileNode.GetSelected() + return !node.path.isDirectory && node.path.isExecutable +endfunction + +function! NERDTreeExecFile() + let treenode = g:NERDTreeFileNode.GetSelected() + echo "==========================================================\n" + echo "Complete the command to execute (add arguments etc):\n" + let cmd = treenode.path.str({'escape': 1}) + let cmd = input(':!', cmd . ' ') + + if cmd !=# '' + exec ':!' . cmd + else + echo 'Aborted' + endif +endfunction diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim new file mode 100644 index 00000000..05bee60d --- /dev/null +++ b/sources_non_forked/nerdtree/nerdtree_plugin/fs_menu.vim @@ -0,0 +1,484 @@ +" ============================================================================ +" File: fs_menu.vim +" Description: plugin for the NERD Tree that provides a file system menu +" Maintainer: Martin Grenfell +" 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. +" +" ============================================================================ +if exists('g:loaded_nerdtree_fs_menu') + finish +endif +let g:loaded_nerdtree_fs_menu = 1 + +"Automatically delete the buffer after deleting or renaming a file +if !exists('g:NERDTreeAutoDeleteBuffer') + let g:NERDTreeAutoDeleteBuffer = 0 +endif + +call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) +call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) +call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) + +if has('gui_mac') || has('gui_macvim') || has('mac') + call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'}) + call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'}) +endif + +if executable('xdg-open') + call NERDTreeAddMenuItem({'text': '(r)eveal the current node in file manager', 'shortcut': 'r', 'callback': 'NERDTreeRevealFileLinux'}) + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileLinux'}) +endif + +if nerdtree#runningWindows() + call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFileWindows'}) +endif + +if g:NERDTreePath.CopyingSupported() + call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) +endif +call NERDTreeAddMenuItem({'text': (has('clipboard')?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'}) + +if has('unix') || has('osx') + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'}) +else + call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNodeWin32'}) +endif + +if exists('*system') + call NERDTreeAddMenuItem({'text': 'Run (s)ystem command in this directory', 'shortcut':'s', 'callback': 'NERDTreeSystemCommand'}) +endif + +"FUNCTION: s:inputPrompt(action){{{1 +"returns the string that should be prompted to the user for the given action +" +"Args: +"action: the action that is being performed, e.g. 'delete' +function! s:inputPrompt(action) + if a:action ==# 'add' + let title = 'Add a childnode' + let info = "Enter the dir/file name to be created. Dirs end with a '/'" + let minimal = 'Add node:' + + elseif a:action ==# 'copy' + let title = 'Copy the current node' + let info = 'Enter the new path to copy the node to:' + let minimal = 'Copy to:' + + elseif a:action ==# 'delete' + let title = 'Delete the current node' + let info = 'Are you sure you wish to delete the node:' + let minimal = 'Delete?' + + elseif a:action ==# 'deleteNonEmpty' + let title = 'Delete the current node' + let info = "STOP! Directory is not empty! To delete, type 'yes'" + let minimal = 'Delete directory?' + + elseif a:action ==# 'move' + let title = 'Rename the current node' + let info = 'Enter the new path for the node:' + let minimal = 'Move to:' + endif + + if g:NERDTreeMenuController.isMinimal() + redraw! " Clear the menu + return minimal . ' ' + else + let divider = '==========================================================' + return title . "\n" . divider . "\n" . info . "\n" + end +endfunction + +"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 +"prints out the given msg and, if the user responds by pushing 'y' then the +"buffer with the given bufnum is deleted +" +"Args: +"bufnum: the buffer that may be deleted +"msg: a message that will be echoed to the user asking them if they wish to +" del the buffer +function! s:promptToDelBuffer(bufnum, msg) + echo a:msg + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + " 1. ensure that all windows which display the just deleted filename + " now display an empty buffer (so a layout is preserved). + " Is not it better to close single tabs with this file only ? + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + " Go to the next buffer in buffer list if at least one extra buffer is listed + " Otherwise open a new empty buffer + if v:version >= 800 + let l:listedBufferCount = len(getbufinfo({'buflisted':1})) + elseif v:version >= 702 + let l:listedBufferCount = len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) + else + " Ignore buffer count in this case to make sure we keep the old + " behavior + let l:listedBufferCount = 0 + endif + if l:listedBufferCount > 1 + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':bnext! ' | endif", 1) + else + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufnum . " | exec ':enew! ' | endif", 1) + endif + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) + " 3. We don't need a previous buffer anymore + call nerdtree#exec('bwipeout! ' . a:bufnum, 0) + endif +endfunction + +"FUNCTION: s:renameBuffer(bufNum, newNodeName, isDirectory){{{1 +"The buffer with the given bufNum is replaced with a new one +" +"Args: +"bufNum: the buffer that may be deleted +"newNodeName: the name given to the renamed node +"isDirectory: determines how to do the create the new filenames +function! s:renameBuffer(bufNum, newNodeName, isDirectory) + if a:isDirectory + let quotedFileName = fnameescape(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')) + let editStr = g:NERDTreePath.New(a:newNodeName . '/' . fnamemodify(bufname(a:bufNum),':t')).str({'format': 'Edit'}) + else + let quotedFileName = fnameescape(a:newNodeName) + let editStr = g:NERDTreePath.New(a:newNodeName).str({'format': 'Edit'}) + endif + " 1. ensure that a new buffer is loaded + call nerdtree#exec('badd ' . quotedFileName, 0) + " 2. ensure that all windows which display the just deleted filename + " display a buffer for a new filename. + let s:originalTabNumber = tabpagenr() + let s:originalWindowNumber = winnr() + call nerdtree#exec('tabdo windo if winbufnr(0) ==# ' . a:bufNum . " | exec ':e! " . editStr . "' | endif", 0) + call nerdtree#exec('tabnext ' . s:originalTabNumber, 1) + call nerdtree#exec(s:originalWindowNumber . 'wincmd w', 1) + " 3. We don't need a previous buffer anymore + try + call nerdtree#exec('confirm bwipeout ' . a:bufNum, 0) + catch + " This happens when answering Cancel if confirmation is needed. Do nothing. + endtry +endfunction + +"FUNCTION: NERDTreeAddNode(){{{1 +function! NERDTreeAddNode() + let curDirNode = g:NERDTreeDirNode.GetSelected() + let prompt = s:inputPrompt('add') + let newNodeName = substitute(input(prompt, curDirNode.path.str() . nerdtree#slash(), 'file'), '\(^\s*\|\s*$\)', '', 'g') + + if newNodeName ==# '' + call nerdtree#echo('Node Creation Aborted.') + return + endif + + try + let newPath = g:NERDTreePath.Create(newNodeName) + let parentNode = b:NERDTree.root.findNode(newPath.getParent()) + + let newTreeNode = g:NERDTreeFileNode.New(newPath, b:NERDTree) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] + if empty(parentNode) + call b:NERDTree.root.refresh() + call b:NERDTree.render() + elseif parentNode.isOpen || !empty(parentNode.children) + call parentNode.addChild(newTreeNode, 1) + call NERDTreeRender() + call newTreeNode.putCursorHere(1, 0) + endif + + redraw! + catch /^NERDTree/ + call nerdtree#echoWarning('Node Not Created.') + endtry +endfunction + +"FUNCTION: NERDTreeMoveNode(){{{1 +function! NERDTreeMoveNode() + let curNode = g:NERDTreeFileNode.GetSelected() + let prompt = s:inputPrompt('move') + let newNodePath = input(prompt, curNode.path.str(), 'file') + while filereadable(newNodePath) + call nerdtree#echoWarning('This destination already exists. Try again.') + let newNodePath = substitute(input(prompt, curNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') + endwhile + + + if newNodePath ==# '' + call nerdtree#echo('Node Renaming Aborted.') + return + endif + + try + if curNode.path.isDirectory + let l:curPath = escape(curNode.path.str(),'\') . (nerdtree#runningWindows()?'\\':'/') . '.*' + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") =~# "'.escape(l:curPath,'\').'"') + else + let l:openBuffers = filter(range(1,bufnr('$')),'bufexists(v:val) && fnamemodify(bufname(v:val),":p") ==# curNode.path.str()') + endif + + call curNode.rename(newNodePath) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] + call b:NERDTree.root.refresh() + call NERDTreeRender() + + " If the file node is open, or files under the directory node are + " open, ask the user if they want to replace the file(s) with the + " renamed files. + if !empty(l:openBuffers) + if curNode.path.isDirectory + echo "\nDirectory renamed.\n\nFiles with the old directory name are open in buffers " . join(l:openBuffers, ', ') . '. Replace these buffers with the new files? (yN)' + else + echo "\nFile renamed.\n\nThe old file is open in buffer " . l:openBuffers[0] . '. Replace this buffer with the new file? (yN)' + endif + if g:NERDTreeAutoDeleteBuffer || nr2char(getchar()) ==# 'y' + for bufNum in l:openBuffers + call s:renameBuffer(bufNum, newNodePath, curNode.path.isDirectory) + endfor + endif + endif + + call curNode.putCursorHere(1, 0) + + redraw! + catch /^NERDTree/ + call nerdtree#echoWarning('Node Not Renamed.') + endtry +endfunction + +" FUNCTION: NERDTreeDeleteNode() {{{1 +function! NERDTreeDeleteNode() + let currentNode = g:NERDTreeFileNode.GetSelected() + let confirmed = 0 + + if currentNode.path.isDirectory && ((currentNode.isOpen && currentNode.getChildCount() > 0) || + \ (len(currentNode._glob('*', 1)) > 0)) + let prompt = s:inputPrompt('deleteNonEmpty') . currentNode.path.str() . ': ' + let choice = input(prompt) + let confirmed = choice ==# 'yes' + else + let prompt = s:inputPrompt('delete') . currentNode.path.str() . ' (yN): ' + echo prompt + let choice = nr2char(getchar()) + let confirmed = choice ==# 'y' + endif + + if confirmed + try + call currentNode.delete() + call NERDTreeRender() + + "if the node is open in a buffer, ask the user if they want to + "close that buffer + let bufnum = bufnr('^'.currentNode.path.str().'$') + if buflisted(bufnum) + let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? ' (hidden)' : '') .'. Delete this buffer? (yN)' + call s:promptToDelBuffer(bufnum, prompt) + endif + + redraw! + catch /^NERDTree/ + call nerdtree#echoWarning('Could not remove node') + endtry + else + call nerdtree#echo('delete aborted') + endif +endfunction + +" FUNCTION: NERDTreeListNode() {{{1 +function! NERDTreeListNode() + let treenode = g:NERDTreeFileNode.GetSelected() + if !empty(treenode) + let s:uname = system('uname') + let stat_cmd = 'stat -c "%s" ' + + if s:uname =~? 'Darwin' + let stat_cmd = 'stat -f "%z" ' + endif + + let cmd = 'size=$(' . stat_cmd . shellescape(treenode.path.str()) . ') && ' . + \ 'size_with_commas=$(echo $size | sed -e :a -e "s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta") && ' . + \ 'ls -ld ' . shellescape(treenode.path.str()) . ' | sed -e "s/ $size / $size_with_commas /"' + + let metadata = split(system(cmd),'\n') + call nerdtree#echo(metadata[0]) + else + call nerdtree#echo('No information available') + endif +endfunction + +" FUNCTION: NERDTreeListNodeWin32() {{{1 +function! NERDTreeListNodeWin32() + let l:node = g:NERDTreeFileNode.GetSelected() + + if !empty(l:node) + let l:path = l:node.path.str() + call nerdtree#echo(printf('%s:%s MOD:%s BYTES:%d PERMISSIONS:%s', + \ toupper(getftype(l:path)), + \ fnamemodify(l:path, ':t'), + \ strftime('%c', getftime(l:path)), + \ getfsize(l:path), + \ getfperm(l:path))) + return + endif + + call nerdtree#echo('node not recognized') +endfunction + +" FUNCTION: NERDTreeCopyNode() {{{1 +function! NERDTreeCopyNode() + let currentNode = g:NERDTreeFileNode.GetSelected() + let prompt = s:inputPrompt('copy') + let newNodePath = substitute(input(prompt, currentNode.path.str(), 'file'), '\(^\s*\|\s*$\)', '', 'g') + + if newNodePath !=# '' + "strip trailing slash + let newNodePath = substitute(newNodePath, '\/$', '', '') + + let confirmed = 1 + if currentNode.path.copyingWillOverwrite(newNodePath) + call nerdtree#echo('Warning: copying may overwrite files! Continue? (yN)') + let choice = nr2char(getchar()) + let confirmed = choice ==# 'y' + endif + + if confirmed + try + let newNode = currentNode.copy(newNodePath) + " Emptying g:NERDTreeOldSortOrder forces the sort to + " recalculate the cached sortKey so nodes sort correctly. + let g:NERDTreeOldSortOrder = [] + if empty(newNode) + call b:NERDTree.root.refresh() + call b:NERDTree.render() + else + call NERDTreeRender() + call newNode.putCursorHere(0, 0) + endif + catch /^NERDTree/ + call nerdtree#echoWarning('Could not copy node') + endtry + endif + else + call nerdtree#echo('Copy aborted.') + endif + redraw! +endfunction + +" FUNCTION: NERDTreeCopyPath() {{{1 +function! NERDTreeCopyPath() + let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str() + if has('clipboard') + if &clipboard ==# 'unnamedplus' + let @+ = l:nodePath + else + let @* = l:nodePath + endif + call nerdtree#echo('The path [' . l:nodePath . '] was copied to your clipboard.') + else + call nerdtree#echo('The full path is: ' . l:nodePath) + endif +endfunction + +" FUNCTION: NERDTreeQuickLook() {{{1 +function! NERDTreeQuickLook() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('qlmanage -p 2>/dev/null ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeRevealInFinder() {{{1 +function! NERDTreeRevealInFinder() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('open -R ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeExecuteFile() {{{1 +function! NERDTreeExecuteFile() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('open ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeRevealFileLinux() {{{1 +function! NERDTreeRevealFileLinux() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + " Handle the edge case of "/", which has no parent. + if l:node.path.str() ==# '/' + call system('xdg-open /') + return + endif + + if empty(l:node.parent) + return + endif + + call system('xdg-open ' . shellescape(l:node.parent.path.str())) +endfunction + +" FUNCTION: NERDTreeExecuteFileLinux() {{{1 +function! NERDTreeExecuteFileLinux() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('xdg-open ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeExecuteFileWindows() {{{1 +function! NERDTreeExecuteFileWindows() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + call system('cmd.exe /c start "" ' . shellescape(l:node.path.str())) +endfunction + +" FUNCTION: NERDTreeSystemCommand() {{{1 +function! NERDTreeSystemCommand() + let l:node = g:NERDTreeFileNode.GetSelected() + + if empty(l:node) + return + endif + + let l:cwd = getcwd() + let l:directory = l:node.path.isDirectory ? l:node.path.str() : l:node.parent.path.str() + execute 'cd '.l:directory + + let l:nl = nr2char(10) + echo l:nl . system(input(l:directory . (nerdtree#runningWindows() ? '> ' : ' $ '))) + execute 'cd '.l:cwd +endfunction + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim new file mode 100644 index 00000000..d20e35e5 --- /dev/null +++ b/sources_non_forked/nerdtree/nerdtree_plugin/vcs.vim @@ -0,0 +1,47 @@ +" ============================================================================ +" File: vcs.vim +" Description: NERDTree plugin that provides a command to open on the root of +" a version control system repository. +" Maintainer: Phil Runninger +" 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. +" +" ============================================================================ +command! -n=? -complete=dir -bar NERDTreeVCS :call CreateTabTreeVCS('') +command! -n=? -complete=dir -bar NERDTreeToggleVCS :call ToggleTabTreeVCS('') + +" FUNCTION: s:CreateTabTreeVCS(a:name) {{{1 +function! s:CreateTabTreeVCS(name) + let l:path = g:NERDTreeCreator._pathForString(a:name) + let l:path = s:FindParentVCSRoot(l:path) + call g:NERDTreeCreator.createTabTree(empty(l:path) ? '' : l:path._str()) +endfunction + +" FUNCTION: s:ToggleTabTreeVCS(a:name) {{{1 +" Behaves the same as ToggleTabTree except roots directory at VCS root +function! s:ToggleTabTreeVCS(name) + let l:path = g:NERDTreeCreator._pathForString(a:name) + let l:path = s:FindParentVCSRoot(l:path) + call g:NERDTreeCreator.toggleTabTree(empty(l:path) ? '' : l:path._str()) +endfunction + +" FUNCTION: s:FindParentVCSRoot(a:path) {{{1 +" Finds the root version control system folder of the given path. If a:path is +" not part of a repository, return the original path. +function! s:FindParentVCSRoot(path) + let l:path = a:path + while !empty(l:path) && + \ l:path._str() !~# '^\(\a:[\\\/]\|\/\)$' && + \ !isdirectory(l:path._str() . '/.git') && + \ !isdirectory(l:path._str() . '/.svn') && + \ !isdirectory(l:path._str() . '/.hg') && + \ !isdirectory(l:path._str() . '/.bzr') && + \ !isdirectory(l:path._str() . '/_darcs') + let l:path = l:path.getParent() + endwhile + return (empty(l:path) || l:path._str() =~# '^\(\a:[\\\/]\|\/\)$') ? a:path : l:path +endfunction + diff --git a/sources_non_forked/nerdtree/plugin/NERD_tree.vim b/sources_non_forked/nerdtree/plugin/NERD_tree.vim new file mode 100644 index 00000000..ef60cca1 --- /dev/null +++ b/sources_non_forked/nerdtree/plugin/NERD_tree.vim @@ -0,0 +1,234 @@ +" ============================================================================ +" File: NERD_tree.vim +" Maintainer: Martin Grenfell +" 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. +" +" ============================================================================ +" +" SECTION: Script init stuff {{{1 +"============================================================ +scriptencoding utf-8 + +if exists('loaded_nerd_tree') + finish +endif +if v:version < 703 + echoerr "NERDTree: this plugin requires vim >= 7.3. DOWNLOAD IT! You'll thank me later!" + finish +endif +let loaded_nerd_tree = 1 + +"for line continuation - i.e dont want C in &cpoptions +let s:old_cpo = &cpoptions +set cpoptions&vim + +"SECTION: Initialize variable calls and other random constants {{{2 +let g:NERDTreeAutoCenter = get(g:, 'NERDTreeAutoCenter', 1) +let g:NERDTreeAutoCenterThreshold = get(g:, 'NERDTreeAutoCenterThreshold', 3) +let g:NERDTreeCaseSensitiveSort = get(g:, 'NERDTreeCaseSensitiveSort', 0) +let g:NERDTreeNaturalSort = get(g:, 'NERDTreeNaturalSort', 0) +let g:NERDTreeSortHiddenFirst = get(g:, 'NERDTreeSortHiddenFirst', 1) +let g:NERDTreeUseTCD = get(g:, 'NERDTreeUseTCD', 0) +let g:NERDTreeChDirMode = get(g:, 'NERDTreeChDirMode', 0) +let g:NERDTreeCreatePrefix = get(g:, 'NERDTreeCreatePrefix', 'silent') +let g:NERDTreeMinimalUI = get(g:, 'NERDTreeMinimalUI', 0) +let g:NERDTreeMinimalMenu = get(g:, 'NERDTreeMinimalMenu', 0) +let g:NERDTreeIgnore = get(g:, 'NERDTreeIgnore', ['\~$']) +let g:NERDTreeBookmarksFile = get(g:, 'NERDTreeBookmarksFile', expand('$HOME') . '/.NERDTreeBookmarks') +let g:NERDTreeBookmarksSort = get(g:, 'NERDTreeBookmarksSort', 1) +let g:NERDTreeHighlightCursorline = get(g:, 'NERDTreeHighlightCursorline', 1) +let g:NERDTreeHijackNetrw = get(g:, 'NERDTreeHijackNetrw', 1) +let g:NERDTreeMarkBookmarks = get(g:, 'NERDTreeMarkBookmarks', 1) +let g:NERDTreeMouseMode = get(g:, 'NERDTreeMouseMode', 1) +let g:NERDTreeNotificationThreshold = get(g:, 'NERDTreeNotificationThreshold', 100) +let g:NERDTreeQuitOnOpen = get(g:, 'NERDTreeQuitOnOpen', 0) +let g:NERDTreeRespectWildIgnore = get(g:, 'NERDTreeRespectWildIgnore', 0) +let g:NERDTreeShowBookmarks = get(g:, 'NERDTreeShowBookmarks', 0) +let g:NERDTreeShowFiles = get(g:, 'NERDTreeShowFiles', 1) +let g:NERDTreeShowHidden = get(g:, 'NERDTreeShowHidden', 0) +let g:NERDTreeShowLineNumbers = get(g:, 'NERDTreeShowLineNumbers', 0) +let g:NERDTreeSortDirs = get(g:, 'NERDTreeSortDirs', 1) + +if !nerdtree#runningWindows() && !nerdtree#runningCygwin() + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '▸') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '▾') +else + let g:NERDTreeDirArrowExpandable = get(g:, 'NERDTreeDirArrowExpandable', '+') + let g:NERDTreeDirArrowCollapsible = get(g:, 'NERDTreeDirArrowCollapsible', '~') +endif + +let g:NERDTreeCascadeOpenSingleChildDir = get(g:, 'NERDTreeCascadeOpenSingleChildDir', 1) +let g:NERDTreeCascadeSingleChildDir = get(g:, 'NERDTreeCascadeSingleChildDir', 1) + +let g:NERDTreeSortOrder = get(g:, 'NERDTreeSortOrder', ['\/$', '*', '\.swp$', '\.bak$', '\~$']) +let g:NERDTreeOldSortOrder = [] + +let g:NERDTreeGlyphReadOnly = get(g:, 'NERDTreeGlyphReadOnly', 'RO') + +if has('conceal') + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\x07") +elseif (g:NERDTreeDirArrowExpandable ==# "\u00a0" || g:NERDTreeDirArrowCollapsible ==# "\u00a0") + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00b7") +else + let g:NERDTreeNodeDelimiter = get(g:, 'NERDTreeNodeDelimiter', "\u00a0") +endif + +"the exists() crap here is a hack to stop vim spazzing out when +"loading a session that was created with an open nerd tree. It spazzes +"because it doesnt store b:NERDTree(its a b: var, and its a hash) +let g:NERDTreeStatusline = get(g:, 'NERDTreeStatusline', "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}") + +let g:NERDTreeWinPos = get(g:, 'NERDTreeWinPos', 'left') +let g:NERDTreeWinSize = get(g:, 'NERDTreeWinSize', 31) + +"init the shell commands that will be used to copy nodes, and remove dir trees +"Note: the space after the command is important +if nerdtree#runningWindows() + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rmdir /s /q ') + let g:NERDTreeCopyDirCmd = get(g:, 'NERDTreeCopyDirCmd', 'xcopy /s /e /i /y /q ') + let g:NERDTreeCopyFileCmd = get(g:, 'NERDTreeCopyFileCmd', 'copy /y ') +else + let g:NERDTreeRemoveDirCmd = get(g:, 'NERDTreeRemoveDirCmd', 'rm -rf ') + let g:NERDTreeCopyCmd = get(g:, 'NERDTreeCopyCmd', 'cp -r ') +endif + +"SECTION: Init variable calls for key mappings {{{2 +let g:NERDTreeMapCustomOpen = get(g:, 'NERDTreeMapCustomOpen', '') +let g:NERDTreeMapActivateNode = get(g:, 'NERDTreeMapActivateNode', 'o') +let g:NERDTreeMapChangeRoot = get(g:, 'NERDTreeMapChangeRoot', 'C') +let g:NERDTreeMapChdir = get(g:, 'NERDTreeMapChdir', 'cd') +let g:NERDTreeMapCloseChildren = get(g:, 'NERDTreeMapCloseChildren', 'X') +let g:NERDTreeMapCloseDir = get(g:, 'NERDTreeMapCloseDir', 'x') +let g:NERDTreeMapDeleteBookmark = get(g:, 'NERDTreeMapDeleteBookmark', 'D') +let g:NERDTreeMapMenu = get(g:, 'NERDTreeMapMenu', 'm') +let g:NERDTreeMapHelp = get(g:, 'NERDTreeMapHelp', '?') +let g:NERDTreeMapJumpFirstChild = get(g:, 'NERDTreeMapJumpFirstChild', 'K') +let g:NERDTreeMapJumpLastChild = get(g:, 'NERDTreeMapJumpLastChild', 'J') +let g:NERDTreeMapJumpNextSibling = get(g:, 'NERDTreeMapJumpNextSibling', '') +let g:NERDTreeMapJumpParent = get(g:, 'NERDTreeMapJumpParent', 'p') +let g:NERDTreeMapJumpPrevSibling = get(g:, 'NERDTreeMapJumpPrevSibling', '') +let g:NERDTreeMapJumpRoot = get(g:, 'NERDTreeMapJumpRoot', 'P') +let g:NERDTreeMapOpenExpl = get(g:, 'NERDTreeMapOpenExpl', 'e') +let g:NERDTreeMapOpenInTab = get(g:, 'NERDTreeMapOpenInTab', 't') +let g:NERDTreeMapOpenInTabSilent = get(g:, 'NERDTreeMapOpenInTabSilent', 'T') +let g:NERDTreeMapOpenRecursively = get(g:, 'NERDTreeMapOpenRecursively', 'O') +let g:NERDTreeMapOpenSplit = get(g:, 'NERDTreeMapOpenSplit', 'i') +let g:NERDTreeMapOpenVSplit = get(g:, 'NERDTreeMapOpenVSplit', 's') +let g:NERDTreeMapPreview = get(g:, 'NERDTreeMapPreview', 'g'.NERDTreeMapActivateNode) +let g:NERDTreeMapPreviewSplit = get(g:, 'NERDTreeMapPreviewSplit', 'g'.NERDTreeMapOpenSplit) +let g:NERDTreeMapPreviewVSplit = get(g:, 'NERDTreeMapPreviewVSplit', 'g'.NERDTreeMapOpenVSplit) +let g:NERDTreeMapQuit = get(g:, 'NERDTreeMapQuit', 'q') +let g:NERDTreeMapRefresh = get(g:, 'NERDTreeMapRefresh', 'r') +let g:NERDTreeMapRefreshRoot = get(g:, 'NERDTreeMapRefreshRoot', 'R') +let g:NERDTreeMapToggleBookmarks = get(g:, 'NERDTreeMapToggleBookmarks', 'B') +let g:NERDTreeMapToggleFiles = get(g:, 'NERDTreeMapToggleFiles', 'F') +let g:NERDTreeMapToggleFilters = get(g:, 'NERDTreeMapToggleFilters', 'f') +let g:NERDTreeMapToggleHidden = get(g:, 'NERDTreeMapToggleHidden', 'I') +let g:NERDTreeMapToggleZoom = get(g:, 'NERDTreeMapToggleZoom', 'A') +let g:NERDTreeMapUpdir = get(g:, 'NERDTreeMapUpdir', 'u') +let g:NERDTreeMapUpdirKeepOpen = get(g:, 'NERDTreeMapUpdirKeepOpen', 'U') +let g:NERDTreeMapCWD = get(g:, 'NERDTreeMapCWD', 'CD') +let g:NERDTreeMenuDown = get(g:, 'NERDTreeMenuDown', 'j') +let g:NERDTreeMenuUp = get(g:, 'NERDTreeMenuUp', 'k') + +"SECTION: Load class files{{{2 +call nerdtree#loadClassFiles() + +" SECTION: Commands {{{1 +"============================================================ +call nerdtree#ui_glue#setupCommands() + +" SECTION: Auto commands {{{1 +"============================================================ +augroup NERDTree + "Save the cursor position whenever we close the nerd tree + exec 'autocmd BufLeave,WinLeave '. g:NERDTreeCreator.BufNamePrefix() .'* if g:NERDTree.IsOpen() | call b:NERDTree.ui.saveScreenState() | endif' + + "disallow insert mode in the NERDTree + exec 'autocmd BufEnter,WinEnter '. g:NERDTreeCreator.BufNamePrefix() .'* stopinsert' +augroup END + +if g:NERDTreeHijackNetrw + augroup NERDTreeHijackNetrw + autocmd VimEnter * silent! autocmd! FileExplorer + au BufEnter,VimEnter * call nerdtree#checkForBrowse(expand('')) + augroup END +endif + +if g:NERDTreeChDirMode ==# 3 + augroup NERDTreeChDirOnTabSwitch + autocmd TabEnter * if g:NERDTree.ExistsForTab()|call g:NERDTree.ForCurrentTab().getRoot().path.changeToDir()|endif + augroup END +endif + +" SECTION: Public API {{{1 +"============================================================ +function! NERDTreeAddMenuItem(options) + call g:NERDTreeMenuItem.Create(a:options) +endfunction + +function! NERDTreeAddMenuSeparator(...) + let opts = a:0 ? a:1 : {} + call g:NERDTreeMenuItem.CreateSeparator(opts) +endfunction + +function! NERDTreeAddSubmenu(options) + return g:NERDTreeMenuItem.Create(a:options) +endfunction + +function! NERDTreeAddKeyMap(options) + call g:NERDTreeKeyMap.Create(a:options) +endfunction + +function! NERDTreeRender() + call nerdtree#renderView() +endfunction + +function! NERDTreeFocus() + if g:NERDTree.IsOpen() + call g:NERDTree.CursorToTreeWin(0) + else + call g:NERDTreeCreator.ToggleTabTree('') + endif +endfunction + +function! NERDTreeCWD() + + if empty(getcwd()) + call nerdtree#echoWarning('current directory does not exist') + return + endif + + try + let l:cwdPath = g:NERDTreePath.New(getcwd()) + catch /^NERDTree.InvalidArgumentsError/ + call nerdtree#echoWarning('current directory does not exist') + return + endtry + + call NERDTreeFocus() + + if b:NERDTree.root.path.equals(l:cwdPath) + return + endif + + let l:newRoot = g:NERDTreeFileNode.New(l:cwdPath, b:NERDTree) + call b:NERDTree.changeRoot(l:newRoot) + normal! ^ +endfunction + +function! NERDTreeAddPathFilter(callback) + call g:NERDTree.AddPathFilter(a:callback) +endfunction + +" SECTION: Post Source Actions {{{1 +call nerdtree#postSourceActions() + +"reset &cpoptions back to users setting +let &cpoptions = s:old_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/sources_non_forked/nerdtree/screenshot.png b/sources_non_forked/nerdtree/screenshot.png new file mode 100644 index 00000000..c410c5db Binary files /dev/null and b/sources_non_forked/nerdtree/screenshot.png differ diff --git a/sources_non_forked/nerdtree/syntax/nerdtree.vim b/sources_non_forked/nerdtree/syntax/nerdtree.vim new file mode 100644 index 00000000..c4197eef --- /dev/null +++ b/sources_non_forked/nerdtree/syntax/nerdtree.vim @@ -0,0 +1,97 @@ +let s:tree_up_dir_line = '.. (up a dir)' +syn match NERDTreeIgnore #\~# +exec 'syn match NERDTreeIgnore #\['.g:NERDTreeGlyphReadOnly.'\]#' + +"highlighting for the .. (up dir) line at the top of the tree +execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line .'#' + +"quickhelp syntax elements +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#ms=s+2,me=e-1 +syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#ms=s+2,me=e-1 +syn match NERDTreeHelpTitle #" .*\~$#ms=s+2,me=e-1 +syn match NERDTreeToggleOn #(on)#ms=s+1,he=e-1 +syn match NERDTreeToggleOff #(off)#ms=e-3,me=e-1 +syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3 +syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeIgnore,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand + +"highlighting for sym links +syn match NERDTreeLinkTarget #->.*# containedin=NERDTreeDir,NERDTreeFile +syn match NERDTreeLinkFile #.* ->#me=e-3 containedin=NERDTreeFile +syn match NERDTreeLinkDir #.*/ ->#me=e-3 containedin=NERDTreeDir + +"highlighting to conceal the delimiter around the file/dir name +if has('conceal') + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# conceal containedin=ALL' + setlocal conceallevel=2 concealcursor=nvic +else + exec 'syn match NERDTreeNodeDelimiters #\%d' . char2nr(g:NERDTreeNodeDelimiter) . '# containedin=ALL' + hi! link NERDTreeNodeDelimiters Ignore +endif + +"highlighing for directory nodes and file nodes +syn match NERDTreeDirSlash #/# containedin=NERDTreeDir + +if g:NERDTreeDirArrowExpandable !=# '' + exec 'syn match NERDTreeClosable #' . escape(g:NERDTreeDirArrowCollapsible, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + exec 'syn match NERDTreeOpenable #' . escape(g:NERDTreeDirArrowExpandable, '~') . '\ze .*/# containedin=NERDTreeDir,NERDTreeFile' + let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-') + exec 'syn match NERDTreeDir #[^'.s:dirArrows.' ].*/#' + exec 'syn match NERDTreeExecFile #^.*'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^[^"\.'.s:dirArrows.'] *[^'.s:dirArrows.']*# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' +else + exec 'syn match NERDTreeDir #[^'.g:NERDTreeNodeDelimiter.']\{-}/\ze\($\|'.g:NERDTreeNodeDelimiter.'\)#' + exec 'syn match NERDTreeExecFile #[^'.g:NERDTreeNodeDelimiter.']\{-}'.g:NERDTreeNodeDelimiter.'\*\($\| \)# contains=NERDTreeRO,NERDTreeBookmarkName' + exec 'syn match NERDTreeFile #^.*'.g:NERDTreeNodeDelimiter.'.*[^\/]\($\|'.g:NERDTreeNodeDelimiter.'.*\)# contains=NERDTreeLink,NERDTreeRO,NERDTreeBookmarkName,NERDTreeExecFile' +endif + +"highlighting for readonly files +exec 'syn match NERDTreeRO #.*'.g:NERDTreeNodeDelimiter.'\zs.*\ze'.g:NERDTreeNodeDelimiter.'.*\['.g:NERDTreeGlyphReadOnly.'\]# contains=NERDTreeIgnore,NERDTreeBookmarkName,NERDTreeFile' + +exec 'syn match NERDTreeFlags #\[[^\]]*\]\ze'.g:NERDTreeNodeDelimiter.'# containedin=NERDTreeFile,NERDTreeExecFile,NERDTreeLinkFile,NERDTreeRO,NERDTreeDir' + +syn match NERDTreeCWD #^[# +syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader +syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader + +hi def link NERDTreePart Special +hi def link NERDTreePartFile Type +hi def link NERDTreeExecFile Title +hi def link NERDTreeDirSlash Identifier + +hi def link NERDTreeBookmarksHeader statement +hi def link NERDTreeBookmarksLeader ignore +hi def link NERDTreeBookmarkName Identifier +hi def link NERDTreeBookmark normal + +hi def link NERDTreeHelp String +hi def link NERDTreeHelpKey Identifier +hi def link NERDTreeHelpCommand Identifier +hi def link NERDTreeHelpTitle Macro +hi def link NERDTreeToggleOn Question +hi def link NERDTreeToggleOff WarningMsg + +hi def link NERDTreeLinkTarget Type +hi def link NERDTreeLinkFile Macro +hi def link NERDTreeLinkDir Macro + +hi def link NERDTreeDir Directory +hi def link NERDTreeUp Directory +hi def link NERDTreeFile Normal +hi def link NERDTreeCWD Statement +hi def link NERDTreeOpenable Directory +hi def link NERDTreeClosable Directory +hi def link NERDTreeIgnore ignore +hi def link NERDTreeRO WarningMsg +hi def link NERDTreeBookmark Statement +hi def link NERDTreeFlags Number + +hi def link NERDTreeCurrentNode Search + +hi NERDTreeFile ctermbg=NONE guibg=NONE diff --git a/sources_non_forked/nginx.vim/CHANGELOG.md b/sources_non_forked/nginx.vim/CHANGELOG.md new file mode 100644 index 00000000..0a8ec60a --- /dev/null +++ b/sources_non_forked/nginx.vim/CHANGELOG.md @@ -0,0 +1,19 @@ +nginx.vim CHANGELOG +===================== + +This file is used to list changes made in each version of the [nginx](https://github.com/chr4/nginx.vim) plugin for the [Vim](http://www.vim.org/) editor. + +1.1.0 +----- + +- Do not highlight `SHA` ciphers, as usage as HMAC is still considered secure + +1.0.1 +----- + +- Highlight `gzip on` as insecure (as it might be vulnerable to BREACH/ CRIME) + +1.0.0 +----- + +- Initial release diff --git a/sources_non_forked/nginx.vim/README.md b/sources_non_forked/nginx.vim/README.md new file mode 100644 index 00000000..11f865b9 --- /dev/null +++ b/sources_non_forked/nginx.vim/README.md @@ -0,0 +1,92 @@ +# nginx.vim + +## Description + +[Vim](http://www.vim.org/) plugin for [Nginx](http://www.nginx.org) + + +## Features + +The plugin is based on the recent vim-plugin distributed with `nginx-1.12.0` and additionally features the following syntax improvements: + +- Highlight IPv4 and IPv6 addresses +- Mark insecure `ssl_protocols` as errors +- Inline template syntax highlight for **ERB** and **Jinja** +- Inline syntax highlight for **LUA** +- Improve integer matching +- Syntax highlighting for `proxy_next_upstream` options +- Syntax highlighting for `sticky` options +- Syntax highlighting for `upstream` `server` options +- More to come! + +Furthermore: + +- Remove annoying delimiters, resulting in strange word-boundaries + +*Note: Also check out [sslsecure.vim](https://github.com/chr4/sslsecure.vim): it supports highlighting insecure SSL/TLS cipher suites and protocols in all your files!* + + +## Screenshots + +A `server` block with highlighting of insecure `ssl_protocol` options: +![nginx server block with SSL configuration](https://chr4.org/images/nginx_ssl.png) + +An `upstream` block with highlighted options: +![nginx upstream configuration](https://chr4.org/images/nginx_upstream.png) + +Embedded highlighting for ERB and Jinja templates: +![Embedded highlighting for ERB and Jinja templates](https://chr4.org/images/nginx_templating.png) + +Embedded LUA syntax highlighting: +![Embedded LUA syntax highlighting](https://chr4.org/images/nginx_lua.png) + + +## References + +- Based on the original `nginx-1.12.0/contrib/vim` +- IPv4 and IPv6 address highlighting, based on expressions found in [this forum post](http://vim.1045645.n5.nabble.com/IPv6-support-for-quot-dns-quot-zonefile-syntax-highlighting-td1197292.html) +- [Blog post](https://chr4.org/blog/2017/04/14/better-syntax-highlighting-and-snippets-for-nginx-in-vim/) introducing this plugin including some more examples + +For help with secure cipher selection, visit [Mozillas SSL Configuration Generator](https://ssl-config.mozilla.org/) + +## Installation + +If your Vim is at version 8 or later, the first method below is the quickest. Otherwise, install this plugin with any Vim plugin manager ([``vim-plug``](https://github.com/junegunn/vim-plug) is recommended). + +### Native plugin management (Vim 8+) + +Clone or submodule this repo into your Vim packages location. Example: + +``` +mkdir -p ~/.vim/pack/plugins/start +cd ~/.vim/pack/plugins/start +git clone https://github.com/chr4/nginx.vim.git +``` + +### Plug +``` +Plug 'chr4/nginx.vim' +``` + +### Dein.vim +``` +call dein#add('chr4/nginx.vim') +``` + +### Vundle +``` +Plugin 'chr4/nginx.vim' +``` + +### Pathogen +``` +git clone https://github.com/chr4/nginx.vim ~/.vim/bundle/nginx.vim +``` + +Optionally, if you like [Jinja](http://jinja.pocoo.org/) template syntax highlighting, install `lepture/vim-jinja`, too. + + +## License + +Copyright (c) Chris Aumann. Distributed under the same terms as Vim itself. +See `:help license`. diff --git a/sources_non_forked/nginx.vim/ftdetect/nginx.vim b/sources_non_forked/nginx.vim/ftdetect/nginx.vim new file mode 100644 index 00000000..0916ca89 --- /dev/null +++ b/sources_non_forked/nginx.vim/ftdetect/nginx.vim @@ -0,0 +1,6 @@ +au BufRead,BufNewFile *.nginx set ft=nginx +au BufRead,BufNewFile nginx*.conf set ft=nginx +au BufRead,BufNewFile *nginx.conf set ft=nginx +au BufRead,BufNewFile */etc/nginx/* set ft=nginx +au BufRead,BufNewFile */usr/local/nginx/conf/* set ft=nginx +au BufRead,BufNewFile */nginx/*.conf set ft=nginx diff --git a/sources_non_forked/nginx.vim/ftplugin/nginx.vim b/sources_non_forked/nginx.vim/ftplugin/nginx.vim new file mode 100644 index 00000000..cfedff87 --- /dev/null +++ b/sources_non_forked/nginx.vim/ftplugin/nginx.vim @@ -0,0 +1,5 @@ +setlocal comments=:# +setlocal commentstring=#\ %s +setlocal formatoptions+=croql formatoptions-=t + +let b:undo_ftplugin = "setl fo< cms< com<" diff --git a/sources_non_forked/nginx.vim/indent/nginx.vim b/sources_non_forked/nginx.vim/indent/nginx.vim new file mode 100644 index 00000000..7a0123cc --- /dev/null +++ b/sources_non_forked/nginx.vim/indent/nginx.vim @@ -0,0 +1,13 @@ +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr= + +" cindent actually works for nginx' simple file structure +setlocal cindent +" Just make sure that the comments are not reset as defs would be. +setlocal cinkeys-=0# + +let b:undo_indent = "setl cin< cink< inde<" diff --git a/sources_non_forked/nginx.vim/syntax/nginx.vim b/sources_non_forked/nginx.vim/syntax/nginx.vim new file mode 100644 index 00000000..18dd50cb --- /dev/null +++ b/sources_non_forked/nginx.vim/syntax/nginx.vim @@ -0,0 +1,2307 @@ +" Vim syntax file +" Language: nginx.conf +" Maintainer: Chris Aumann +" Last Change: Apr 15, 2017 + +if exists("b:current_syntax") + finish +end + +let b:current_syntax = "nginx" + +syn match ngxVariable '\$\(\w\+\|{\w\+}\)' +syn match ngxVariableBlock '\$\(\w\+\|{\w\+}\)' contained +syn match ngxVariableString '\$\(\w\+\|{\w\+}\)' contained +syn region ngxBlock start=+^+ end=+{+ skip=+\${\|{{\|{%+ contains=ngxComment,ngxInteger,ngxIPaddr,ngxDirectiveBlock,ngxVariableBlock,ngxString,ngxThirdPartyLuaBlock oneline +syn region ngxString start=+[^:a-zA-Z>!\\@]\z(["']\)+lc=1 end=+\z1+ skip=+\\\\\|\\\z1+ contains=ngxVariableString,ngxSSLCipherInsecure +syn match ngxComment ' *#.*$' + +" These regular expressions where taken (and adapted) from +" http://vim.1045645.n5.nabble.com/IPv6-support-for-quot-dns-quot-zonefile-syntax-highlighting-td1197292.html +syn match ngxInteger '\W\zs\(\d[0-9.]*\|[0-9.]*\d\)\w\?\ze\W' +syn match ngxIPaddr '\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{6}\(\x\{1,4}:\x\{1,4}\|\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[::\(\(\x\{1,4}:\)\{,6}\x\{1,4}\|\(\x\{1,4}:\)\{,5}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{1}:\(\(\x\{1,4}:\)\{,5}\x\{1,4}\|\(\x\{1,4}:\)\{,4}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{2}:\(\(\x\{1,4}:\)\{,4}\x\{1,4}\|\(\x\{1,4}:\)\{,3}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{3}:\(\(\x\{1,4}:\)\{,3}\x\{1,4}\|\(\x\{1,4}:\)\{,2}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{4}:\(\(\x\{1,4}:\)\{,2}\x\{1,4}\|\(\x\{1,4}:\)\{,1}\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{5}:\(\(\x\{1,4}:\)\{,1}\x\{1,4}\|\([0-2]\?\d\{1,2}\.\)\{3}[0-2]\?\d\{1,2}\)\]' +syn match ngxIPaddr '\[\(\x\{1,4}:\)\{6}:\x\{1,4}\]' + +" Highlight wildcard listening signs also as IPaddr +syn match ngxIPaddr '\s\zs\[::]' +syn match ngxIPaddr '\s\zs\*' + +syn keyword ngxBoolean on +syn keyword ngxBoolean off + +syn keyword ngxDirectiveBlock http contained +syn keyword ngxDirectiveBlock mail contained +syn keyword ngxDirectiveBlock events contained +syn keyword ngxDirectiveBlock server contained +syn keyword ngxDirectiveBlock match contained +syn keyword ngxDirectiveBlock types contained +syn keyword ngxDirectiveBlock location contained +syn keyword ngxDirectiveBlock upstream contained +syn keyword ngxDirectiveBlock charset_map contained +syn keyword ngxDirectiveBlock limit_except contained +syn keyword ngxDirectiveBlock if contained +syn keyword ngxDirectiveBlock geo contained +syn keyword ngxDirectiveBlock map contained +syn keyword ngxDirectiveBlock split_clients contained + +syn keyword ngxDirectiveImportant include +syn keyword ngxDirectiveImportant root +syn keyword ngxDirectiveImportant server contained +syn region ngxDirectiveImportantServer matchgroup=ngxDirectiveImportant start=+^\s*\zsserver\ze\s.*;+ skip=+\\\\\|\\\;+ end=+;+he=e-1 contains=ngxUpstreamServerOptions,ngxString,ngxIPaddr,ngxBoolean,ngxInteger,ngxTemplateVar +syn keyword ngxDirectiveImportant server_name +syn keyword ngxDirectiveImportant listen contained +syn region ngxDirectiveImportantListen matchgroup=ngxDirectiveImportant start=+listen+ skip=+\\\\\|\\\;+ end=+;+he=e-1 contains=ngxListenOptions,ngxString,ngxIPaddr,ngxBoolean,ngxInteger,ngxTemplateVar +syn keyword ngxDirectiveImportant internal +syn keyword ngxDirectiveImportant proxy_pass +syn keyword ngxDirectiveImportant memcached_pass +syn keyword ngxDirectiveImportant fastcgi_pass +syn keyword ngxDirectiveImportant scgi_pass +syn keyword ngxDirectiveImportant uwsgi_pass +syn keyword ngxDirectiveImportant try_files +syn keyword ngxDirectiveImportant error_page +syn keyword ngxDirectiveImportant post_action + +syn keyword ngxUpstreamServerOptions weight contained +syn keyword ngxUpstreamServerOptions max_conns contained +syn keyword ngxUpstreamServerOptions max_fails contained +syn keyword ngxUpstreamServerOptions fail_timeout contained +syn keyword ngxUpstreamServerOptions backup contained +syn keyword ngxUpstreamServerOptions down contained +syn keyword ngxUpstreamServerOptions resolve contained +syn keyword ngxUpstreamServerOptions route contained +syn keyword ngxUpstreamServerOptions service contained +syn keyword ngxUpstreamServerOptions default_server contained +syn keyword ngxUpstreamServerOptions slow_start contained + +syn keyword ngxListenOptions default_server contained +syn keyword ngxListenOptions ssl contained +syn keyword ngxListenOptions http2 contained +syn keyword ngxListenOptions spdy contained +syn keyword ngxListenOptions proxy_protocol contained +syn keyword ngxListenOptions setfib contained +syn keyword ngxListenOptions fastopen contained +syn keyword ngxListenOptions backlog contained +syn keyword ngxListenOptions rcvbuf contained +syn keyword ngxListenOptions sndbuf contained +syn keyword ngxListenOptions accept_filter contained +syn keyword ngxListenOptions deferred contained +syn keyword ngxListenOptions bind contained +syn keyword ngxListenOptions ipv6only contained +syn keyword ngxListenOptions reuseport contained +syn keyword ngxListenOptions so_keepalive contained +syn keyword ngxListenOptions keepidle contained + +syn keyword ngxDirectiveControl break +syn keyword ngxDirectiveControl return +syn keyword ngxDirectiveControl rewrite +syn keyword ngxDirectiveControl set + +syn keyword ngxDirectiveDeprecated connections +syn keyword ngxDirectiveDeprecated imap +syn keyword ngxDirectiveDeprecated limit_zone +syn keyword ngxDirectiveDeprecated mysql_test +syn keyword ngxDirectiveDeprecated open_file_cache_retest +syn keyword ngxDirectiveDeprecated optimize_server_names +syn keyword ngxDirectiveDeprecated satisfy_any +syn keyword ngxDirectiveDeprecated so_keepalive + +syn keyword ngxDirective absolute_redirect +syn keyword ngxDirective accept_mutex +syn keyword ngxDirective accept_mutex_delay +syn keyword ngxDirective acceptex_read +syn keyword ngxDirective access_log +syn keyword ngxDirective add_after_body +syn keyword ngxDirective add_before_body +syn keyword ngxDirective add_header +syn keyword ngxDirective addition_types +syn keyword ngxDirective aio +syn keyword ngxDirective aio_write +syn keyword ngxDirective alias +syn keyword ngxDirective allow +syn keyword ngxDirective ancient_browser +syn keyword ngxDirective ancient_browser_value +syn keyword ngxDirective auth_basic +syn keyword ngxDirective auth_basic_user_file +syn keyword ngxDirective auth_http +syn keyword ngxDirective auth_http_header +syn keyword ngxDirective auth_http_pass_client_cert +syn keyword ngxDirective auth_http_timeout +syn keyword ngxDirective auth_jwt +syn keyword ngxDirective auth_jwt_key_file +syn keyword ngxDirective auth_request +syn keyword ngxDirective auth_request_set +syn keyword ngxDirective autoindex +syn keyword ngxDirective autoindex_exact_size +syn keyword ngxDirective autoindex_format +syn keyword ngxDirective autoindex_localtime +syn keyword ngxDirective charset +syn keyword ngxDirective charset_map +syn keyword ngxDirective charset_types +syn keyword ngxDirective chunked_transfer_encoding +syn keyword ngxDirective client_body_buffer_size +syn keyword ngxDirective client_body_in_file_only +syn keyword ngxDirective client_body_in_single_buffer +syn keyword ngxDirective client_body_temp_path +syn keyword ngxDirective client_body_timeout +syn keyword ngxDirective client_header_buffer_size +syn keyword ngxDirective client_header_timeout +syn keyword ngxDirective client_max_body_size +syn keyword ngxDirective connection_pool_size +syn keyword ngxDirective create_full_put_path +syn keyword ngxDirective daemon +syn keyword ngxDirective dav_access +syn keyword ngxDirective dav_methods +syn keyword ngxDirective debug_connection +syn keyword ngxDirective debug_points +syn keyword ngxDirective default_type +syn keyword ngxDirective degradation +syn keyword ngxDirective degrade +syn keyword ngxDirective deny +syn keyword ngxDirective devpoll_changes +syn keyword ngxDirective devpoll_events +syn keyword ngxDirective directio +syn keyword ngxDirective directio_alignment +syn keyword ngxDirective disable_symlinks +syn keyword ngxDirective empty_gif +syn keyword ngxDirective env +syn keyword ngxDirective epoll_events +syn keyword ngxDirective error_log +syn keyword ngxDirective etag +syn keyword ngxDirective eventport_events +syn keyword ngxDirective expires +syn keyword ngxDirective f4f +syn keyword ngxDirective f4f_buffer_size +syn keyword ngxDirective fastcgi_bind +syn keyword ngxDirective fastcgi_buffer_size +syn keyword ngxDirective fastcgi_buffering +syn keyword ngxDirective fastcgi_buffers +syn keyword ngxDirective fastcgi_busy_buffers_size +syn keyword ngxDirective fastcgi_cache +syn keyword ngxDirective fastcgi_cache_bypass +syn keyword ngxDirective fastcgi_cache_key +syn keyword ngxDirective fastcgi_cache_lock +syn keyword ngxDirective fastcgi_cache_lock_age +syn keyword ngxDirective fastcgi_cache_lock_timeout +syn keyword ngxDirective fastcgi_cache_max_range_offset +syn keyword ngxDirective fastcgi_cache_methods +syn keyword ngxDirective fastcgi_cache_min_uses +syn keyword ngxDirective fastcgi_cache_path +syn keyword ngxDirective fastcgi_cache_purge +syn keyword ngxDirective fastcgi_cache_revalidate +syn keyword ngxDirective fastcgi_cache_use_stale +syn keyword ngxDirective fastcgi_cache_valid +syn keyword ngxDirective fastcgi_catch_stderr +syn keyword ngxDirective fastcgi_connect_timeout +syn keyword ngxDirective fastcgi_force_ranges +syn keyword ngxDirective fastcgi_hide_header +syn keyword ngxDirective fastcgi_ignore_client_abort +syn keyword ngxDirective fastcgi_ignore_headers +syn keyword ngxDirective fastcgi_index +syn keyword ngxDirective fastcgi_intercept_errors +syn keyword ngxDirective fastcgi_keep_conn +syn keyword ngxDirective fastcgi_limit_rate +syn keyword ngxDirective fastcgi_max_temp_file_size +syn keyword ngxDirective fastcgi_next_upstream +syn keyword ngxDirective fastcgi_next_upstream_timeout +syn keyword ngxDirective fastcgi_next_upstream_tries +syn keyword ngxDirective fastcgi_no_cache +syn keyword ngxDirective fastcgi_param +syn keyword ngxDirective fastcgi_pass_header +syn keyword ngxDirective fastcgi_pass_request_body +syn keyword ngxDirective fastcgi_pass_request_headers +syn keyword ngxDirective fastcgi_read_timeout +syn keyword ngxDirective fastcgi_request_buffering +syn keyword ngxDirective fastcgi_send_lowat +syn keyword ngxDirective fastcgi_send_timeout +syn keyword ngxDirective fastcgi_split_path_info +syn keyword ngxDirective fastcgi_store +syn keyword ngxDirective fastcgi_store_access +syn keyword ngxDirective fastcgi_temp_file_write_size +syn keyword ngxDirective fastcgi_temp_path +syn keyword ngxDirective flv +syn keyword ngxDirective geoip_city +syn keyword ngxDirective geoip_country +syn keyword ngxDirective geoip_org +syn keyword ngxDirective geoip_proxy +syn keyword ngxDirective geoip_proxy_recursive +syn keyword ngxDirective google_perftools_profiles +syn keyword ngxDirective gunzip +syn keyword ngxDirective gunzip_buffers +syn keyword ngxDirective gzip nextgroup=ngxGzipOn,ngxGzipOff skipwhite +syn keyword ngxGzipOn on contained +syn keyword ngxGzipOff off contained +syn keyword ngxDirective gzip_buffers +syn keyword ngxDirective gzip_comp_level +syn keyword ngxDirective gzip_disable +syn keyword ngxDirective gzip_hash +syn keyword ngxDirective gzip_http_version +syn keyword ngxDirective gzip_min_length +syn keyword ngxDirective gzip_no_buffer +syn keyword ngxDirective gzip_proxied +syn keyword ngxDirective gzip_static +syn keyword ngxDirective gzip_types +syn keyword ngxDirective gzip_vary +syn keyword ngxDirective gzip_window +syn keyword ngxDirective hash +syn keyword ngxDirective health_check +syn keyword ngxDirective health_check_timeout +syn keyword ngxDirective hls +syn keyword ngxDirective hls_buffers +syn keyword ngxDirective hls_forward_args +syn keyword ngxDirective hls_fragment +syn keyword ngxDirective hls_mp4_buffer_size +syn keyword ngxDirective hls_mp4_max_buffer_size +syn keyword ngxDirective http2_chunk_size +syn keyword ngxDirective http2_body_preread_size +syn keyword ngxDirective http2_idle_timeout +syn keyword ngxDirective http2_max_concurrent_streams +syn keyword ngxDirective http2_max_field_size +syn keyword ngxDirective http2_max_header_size +syn keyword ngxDirective http2_max_requests +syn keyword ngxDirective http2_recv_buffer_size +syn keyword ngxDirective http2_recv_timeout +syn keyword ngxDirective if_modified_since +syn keyword ngxDirective ignore_invalid_headers +syn keyword ngxDirective image_filter +syn keyword ngxDirective image_filter_buffer +syn keyword ngxDirective image_filter_interlace +syn keyword ngxDirective image_filter_jpeg_quality +syn keyword ngxDirective image_filter_sharpen +syn keyword ngxDirective image_filter_transparency +syn keyword ngxDirective image_filter_webp_quality +syn keyword ngxDirective imap_auth +syn keyword ngxDirective imap_capabilities +syn keyword ngxDirective imap_client_buffer +syn keyword ngxDirective index +syn keyword ngxDirective iocp_threads +syn keyword ngxDirective ip_hash +syn keyword ngxDirective js_access +syn keyword ngxDirective js_content +syn keyword ngxDirective js_filter +syn keyword ngxDirective js_include +syn keyword ngxDirective js_preread +syn keyword ngxDirective js_set +syn keyword ngxDirective keepalive +syn keyword ngxDirective keepalive_disable +syn keyword ngxDirective keepalive_requests +syn keyword ngxDirective keepalive_timeout +syn keyword ngxDirective kqueue_changes +syn keyword ngxDirective kqueue_events +syn keyword ngxDirective large_client_header_buffers +syn keyword ngxDirective least_conn +syn keyword ngxDirective least_time +syn keyword ngxDirective limit_conn +syn keyword ngxDirective limit_conn_dry_run +syn keyword ngxDirective limit_conn_log_level +syn keyword ngxDirective limit_conn_status +syn keyword ngxDirective limit_conn_zone +syn keyword ngxDirective limit_except +syn keyword ngxDirective limit_rate +syn keyword ngxDirective limit_rate_after +syn keyword ngxDirective limit_req +syn keyword ngxDirective limit_req_dry_run +syn keyword ngxDirective limit_req_log_level +syn keyword ngxDirective limit_req_status +syn keyword ngxDirective limit_req_zone +syn keyword ngxDirective lingering_close +syn keyword ngxDirective lingering_time +syn keyword ngxDirective lingering_timeout +syn keyword ngxDirective load_module +syn keyword ngxDirective lock_file +syn keyword ngxDirective log_format +syn keyword ngxDirective log_not_found +syn keyword ngxDirective log_subrequest +syn keyword ngxDirective map_hash_bucket_size +syn keyword ngxDirective map_hash_max_size +syn keyword ngxDirective master_process +syn keyword ngxDirective max_ranges +syn keyword ngxDirective memcached_bind +syn keyword ngxDirective memcached_buffer_size +syn keyword ngxDirective memcached_connect_timeout +syn keyword ngxDirective memcached_force_ranges +syn keyword ngxDirective memcached_gzip_flag +syn keyword ngxDirective memcached_next_upstream +syn keyword ngxDirective memcached_next_upstream_timeout +syn keyword ngxDirective memcached_next_upstream_tries +syn keyword ngxDirective memcached_read_timeout +syn keyword ngxDirective memcached_send_timeout +syn keyword ngxDirective merge_slashes +syn keyword ngxDirective min_delete_depth +syn keyword ngxDirective modern_browser +syn keyword ngxDirective modern_browser_value +syn keyword ngxDirective mp4 +syn keyword ngxDirective mp4_buffer_size +syn keyword ngxDirective mp4_max_buffer_size +syn keyword ngxDirective mp4_limit_rate +syn keyword ngxDirective mp4_limit_rate_after +syn keyword ngxDirective msie_padding +syn keyword ngxDirective msie_refresh +syn keyword ngxDirective multi_accept +syn keyword ngxDirective ntlm +syn keyword ngxDirective open_file_cache +syn keyword ngxDirective open_file_cache_errors +syn keyword ngxDirective open_file_cache_events +syn keyword ngxDirective open_file_cache_min_uses +syn keyword ngxDirective open_file_cache_valid +syn keyword ngxDirective open_log_file_cache +syn keyword ngxDirective output_buffers +syn keyword ngxDirective override_charset +syn keyword ngxDirective pcre_jit +syn keyword ngxDirective perl +syn keyword ngxDirective perl_modules +syn keyword ngxDirective perl_require +syn keyword ngxDirective perl_set +syn keyword ngxDirective pid +syn keyword ngxDirective pop3_auth +syn keyword ngxDirective pop3_capabilities +syn keyword ngxDirective port_in_redirect +syn keyword ngxDirective post_acceptex +syn keyword ngxDirective postpone_gzipping +syn keyword ngxDirective postpone_output +syn keyword ngxDirective preread_buffer_size +syn keyword ngxDirective preread_timeout +syn keyword ngxDirective protocol nextgroup=ngxMailProtocol skipwhite +syn keyword ngxMailProtocol imap pop3 smtp contained +syn keyword ngxDirective proxy +syn keyword ngxDirective proxy_bind +syn keyword ngxDirective proxy_buffer +syn keyword ngxDirective proxy_buffer_size +syn keyword ngxDirective proxy_buffering +syn keyword ngxDirective proxy_buffers +syn keyword ngxDirective proxy_busy_buffers_size +syn keyword ngxDirective proxy_cache +syn keyword ngxDirective proxy_cache_bypass +syn keyword ngxDirective proxy_cache_convert_head +syn keyword ngxDirective proxy_cache_key +syn keyword ngxDirective proxy_cache_lock +syn keyword ngxDirective proxy_cache_lock_age +syn keyword ngxDirective proxy_cache_lock_timeout +syn keyword ngxDirective proxy_cache_max_range_offset +syn keyword ngxDirective proxy_cache_methods +syn keyword ngxDirective proxy_cache_min_uses +syn keyword ngxDirective proxy_cache_path +syn keyword ngxDirective proxy_cache_purge +syn keyword ngxDirective proxy_cache_revalidate +syn keyword ngxDirective proxy_cache_use_stale +syn keyword ngxDirective proxy_cache_valid +syn keyword ngxDirective proxy_connect_timeout +syn keyword ngxDirective proxy_cookie_domain +syn keyword ngxDirective proxy_cookie_path +syn keyword ngxDirective proxy_download_rate +syn keyword ngxDirective proxy_force_ranges +syn keyword ngxDirective proxy_headers_hash_bucket_size +syn keyword ngxDirective proxy_headers_hash_max_size +syn keyword ngxDirective proxy_hide_header +syn keyword ngxDirective proxy_http_version +syn keyword ngxDirective proxy_ignore_client_abort +syn keyword ngxDirective proxy_ignore_headers +syn keyword ngxDirective proxy_intercept_errors +syn keyword ngxDirective proxy_limit_rate +syn keyword ngxDirective proxy_max_temp_file_size +syn keyword ngxDirective proxy_method +syn keyword ngxDirective proxy_next_upstream contained +syn region ngxDirectiveProxyNextUpstream matchgroup=ngxDirective start=+^\s*\zsproxy_next_upstream\ze\s.*;+ skip=+\\\\\|\\\;+ end=+;+he=e-1 contains=ngxProxyNextUpstreamOptions,ngxString,ngxTemplateVar +syn keyword ngxDirective proxy_next_upstream_timeout +syn keyword ngxDirective proxy_next_upstream_tries +syn keyword ngxDirective proxy_no_cache +syn keyword ngxDirective proxy_pass_error_message +syn keyword ngxDirective proxy_pass_header +syn keyword ngxDirective proxy_pass_request_body +syn keyword ngxDirective proxy_pass_request_headers +syn keyword ngxDirective proxy_protocol +syn keyword ngxDirective proxy_protocol_timeout +syn keyword ngxDirective proxy_read_timeout +syn keyword ngxDirective proxy_redirect +syn keyword ngxDirective proxy_request_buffering +syn keyword ngxDirective proxy_responses +syn keyword ngxDirective proxy_send_lowat +syn keyword ngxDirective proxy_send_timeout +syn keyword ngxDirective proxy_set_body +syn keyword ngxDirective proxy_set_header +syn keyword ngxDirective proxy_ssl_certificate +syn keyword ngxDirective proxy_ssl_certificate_key +syn keyword ngxDirective proxy_ssl_ciphers +syn keyword ngxDirective proxy_ssl_crl +syn keyword ngxDirective proxy_ssl_name +syn keyword ngxDirective proxy_ssl_password_file +syn keyword ngxDirective proxy_ssl_protocols nextgroup=ngxSSLProtocol skipwhite +syn keyword ngxDirective proxy_ssl_server_name +syn keyword ngxDirective proxy_ssl_session_reuse +syn keyword ngxDirective proxy_ssl_trusted_certificate +syn keyword ngxDirective proxy_ssl_verify +syn keyword ngxDirective proxy_ssl_verify_depth +syn keyword ngxDirective proxy_store +syn keyword ngxDirective proxy_store_access +syn keyword ngxDirective proxy_temp_file_write_size +syn keyword ngxDirective proxy_temp_path +syn keyword ngxDirective proxy_timeout +syn keyword ngxDirective proxy_upload_rate +syn keyword ngxDirective queue +syn keyword ngxDirective random_index +syn keyword ngxDirective read_ahead +syn keyword ngxDirective real_ip_header +syn keyword ngxDirective real_ip_recursive +syn keyword ngxDirective recursive_error_pages +syn keyword ngxDirective referer_hash_bucket_size +syn keyword ngxDirective referer_hash_max_size +syn keyword ngxDirective request_pool_size +syn keyword ngxDirective reset_timedout_connection +syn keyword ngxDirective resolver +syn keyword ngxDirective resolver_timeout +syn keyword ngxDirective rewrite_log +syn keyword ngxDirective rtsig_overflow_events +syn keyword ngxDirective rtsig_overflow_test +syn keyword ngxDirective rtsig_overflow_threshold +syn keyword ngxDirective rtsig_signo +syn keyword ngxDirective satisfy +syn keyword ngxDirective scgi_bind +syn keyword ngxDirective scgi_buffer_size +syn keyword ngxDirective scgi_buffering +syn keyword ngxDirective scgi_buffers +syn keyword ngxDirective scgi_busy_buffers_size +syn keyword ngxDirective scgi_cache +syn keyword ngxDirective scgi_cache_bypass +syn keyword ngxDirective scgi_cache_key +syn keyword ngxDirective scgi_cache_lock +syn keyword ngxDirective scgi_cache_lock_age +syn keyword ngxDirective scgi_cache_lock_timeout +syn keyword ngxDirective scgi_cache_max_range_offset +syn keyword ngxDirective scgi_cache_methods +syn keyword ngxDirective scgi_cache_min_uses +syn keyword ngxDirective scgi_cache_path +syn keyword ngxDirective scgi_cache_purge +syn keyword ngxDirective scgi_cache_revalidate +syn keyword ngxDirective scgi_cache_use_stale +syn keyword ngxDirective scgi_cache_valid +syn keyword ngxDirective scgi_connect_timeout +syn keyword ngxDirective scgi_force_ranges +syn keyword ngxDirective scgi_hide_header +syn keyword ngxDirective scgi_ignore_client_abort +syn keyword ngxDirective scgi_ignore_headers +syn keyword ngxDirective scgi_intercept_errors +syn keyword ngxDirective scgi_limit_rate +syn keyword ngxDirective scgi_max_temp_file_size +syn keyword ngxDirective scgi_next_upstream +syn keyword ngxDirective scgi_next_upstream_timeout +syn keyword ngxDirective scgi_next_upstream_tries +syn keyword ngxDirective scgi_no_cache +syn keyword ngxDirective scgi_param +syn keyword ngxDirective scgi_pass_header +syn keyword ngxDirective scgi_pass_request_body +syn keyword ngxDirective scgi_pass_request_headers +syn keyword ngxDirective scgi_read_timeout +syn keyword ngxDirective scgi_request_buffering +syn keyword ngxDirective scgi_send_timeout +syn keyword ngxDirective scgi_store +syn keyword ngxDirective scgi_store_access +syn keyword ngxDirective scgi_temp_file_write_size +syn keyword ngxDirective scgi_temp_path +syn keyword ngxDirective secure_link +syn keyword ngxDirective secure_link_md5 +syn keyword ngxDirective secure_link_secret +syn keyword ngxDirective send_lowat +syn keyword ngxDirective send_timeout +syn keyword ngxDirective sendfile +syn keyword ngxDirective sendfile_max_chunk +syn keyword ngxDirective server_name_in_redirect +syn keyword ngxDirective server_names_hash_bucket_size +syn keyword ngxDirective server_names_hash_max_size +syn keyword ngxDirective server_tokens +syn keyword ngxDirective session_log +syn keyword ngxDirective session_log_format +syn keyword ngxDirective session_log_zone +syn keyword ngxDirective set_real_ip_from +syn keyword ngxDirective slice +syn keyword ngxDirective smtp_auth +syn keyword ngxDirective smtp_capabilities +syn keyword ngxDirective smtp_client_buffer +syn keyword ngxDirective smtp_greeting_delay +syn keyword ngxDirective source_charset +syn keyword ngxDirective spdy_chunk_size +syn keyword ngxDirective spdy_headers_comp +syn keyword ngxDirective spdy_keepalive_timeout +syn keyword ngxDirective spdy_max_concurrent_streams +syn keyword ngxDirective spdy_pool_size +syn keyword ngxDirective spdy_recv_buffer_size +syn keyword ngxDirective spdy_recv_timeout +syn keyword ngxDirective spdy_streams_index_size +syn keyword ngxDirective ssi +syn keyword ngxDirective ssi_ignore_recycled_buffers +syn keyword ngxDirective ssi_last_modified +syn keyword ngxDirective ssi_min_file_chunk +syn keyword ngxDirective ssi_silent_errors +syn keyword ngxDirective ssi_types +syn keyword ngxDirective ssi_value_length +syn keyword ngxDirective ssl +syn keyword ngxDirective ssl_buffer_size +syn keyword ngxDirective ssl_certificate +syn keyword ngxDirective ssl_certificate_key +syn keyword ngxDirective ssl_ciphers +syn keyword ngxDirective ssl_client_certificate +syn keyword ngxDirective ssl_crl +syn keyword ngxDirective ssl_dhparam +syn keyword ngxDirective ssl_ecdh_curve +syn keyword ngxDirective ssl_engine +syn keyword ngxDirective ssl_handshake_timeout +syn keyword ngxDirective ssl_password_file +syn keyword ngxDirective ssl_prefer_server_ciphers nextgroup=ngxSSLPreferServerCiphersOff,ngxSSLPreferServerCiphersOn skipwhite +syn keyword ngxSSLPreferServerCiphersOn on contained +syn keyword ngxSSLPreferServerCiphersOff off contained +syn keyword ngxDirective ssl_preread +syn keyword ngxDirective ssl_protocols nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +syn match ngxSSLProtocol 'TLSv1' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +syn match ngxSSLProtocol 'TLSv1\.1' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +syn match ngxSSLProtocol 'TLSv1\.2' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +syn match ngxSSLProtocol 'TLSv1\.3' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite + +" Do not enable highlighting of insecure protocols if sslecure is loaded +if !exists('g:loaded_sslsecure') + syn keyword ngxSSLProtocolDeprecated SSLv2 SSLv3 contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +else + syn match ngxSSLProtocol 'SSLv2' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite + syn match ngxSSLProtocol 'SSLv3' contained nextgroup=ngxSSLProtocol,ngxSSLProtocolDeprecated skipwhite +endif + +syn keyword ngxDirective ssl_session_cache +syn keyword ngxDirective ssl_session_ticket_key +syn keyword ngxDirective ssl_session_tickets nextgroup=ngxSSLSessionTicketsOn,ngxSSLSessionTicketsOff skipwhite +syn keyword ngxSSLSessionTicketsOn on contained +syn keyword ngxSSLSessionTicketsOff off contained +syn keyword ngxDirective ssl_session_timeout +syn keyword ngxDirective ssl_stapling +syn keyword ngxDirective ssl_stapling_file +syn keyword ngxDirective ssl_stapling_responder +syn keyword ngxDirective ssl_stapling_verify +syn keyword ngxDirective ssl_trusted_certificate +syn keyword ngxDirective ssl_verify_client +syn keyword ngxDirective ssl_verify_depth +syn keyword ngxDirective starttls +syn keyword ngxDirective state +syn keyword ngxDirective status +syn keyword ngxDirective status_format +syn keyword ngxDirective status_zone +syn keyword ngxDirective sticky contained +syn keyword ngxDirective sticky_cookie_insert contained +syn region ngxDirectiveSticky matchgroup=ngxDirective start=+^\s*\zssticky\ze\s.*;+ skip=+\\\\\|\\\;+ end=+;+he=e-1 contains=ngxCookieOptions,ngxString,ngxBoolean,ngxInteger,ngxTemplateVar +syn keyword ngxDirective stub_status +syn keyword ngxDirective sub_filter +syn keyword ngxDirective sub_filter_last_modified +syn keyword ngxDirective sub_filter_once +syn keyword ngxDirective sub_filter_types +syn keyword ngxDirective tcp_nodelay +syn keyword ngxDirective tcp_nopush +syn keyword ngxDirective thread_pool +syn keyword ngxDirective thread_stack_size +syn keyword ngxDirective timeout +syn keyword ngxDirective timer_resolution +syn keyword ngxDirective types_hash_bucket_size +syn keyword ngxDirective types_hash_max_size +syn keyword ngxDirective underscores_in_headers +syn keyword ngxDirective uninitialized_variable_warn +syn keyword ngxDirective upstream_conf +syn keyword ngxDirective use +syn keyword ngxDirective user +syn keyword ngxDirective userid +syn keyword ngxDirective userid_domain +syn keyword ngxDirective userid_expires +syn keyword ngxDirective userid_mark +syn keyword ngxDirective userid_name +syn keyword ngxDirective userid_p3p +syn keyword ngxDirective userid_path +syn keyword ngxDirective userid_service +syn keyword ngxDirective uwsgi_bind +syn keyword ngxDirective uwsgi_buffer_size +syn keyword ngxDirective uwsgi_buffering +syn keyword ngxDirective uwsgi_buffers +syn keyword ngxDirective uwsgi_busy_buffers_size +syn keyword ngxDirective uwsgi_cache +syn keyword ngxDirective uwsgi_cache_bypass +syn keyword ngxDirective uwsgi_cache_key +syn keyword ngxDirective uwsgi_cache_lock +syn keyword ngxDirective uwsgi_cache_lock_age +syn keyword ngxDirective uwsgi_cache_lock_timeout +syn keyword ngxDirective uwsgi_cache_methods +syn keyword ngxDirective uwsgi_cache_min_uses +syn keyword ngxDirective uwsgi_cache_path +syn keyword ngxDirective uwsgi_cache_purge +syn keyword ngxDirective uwsgi_cache_revalidate +syn keyword ngxDirective uwsgi_cache_use_stale +syn keyword ngxDirective uwsgi_cache_valid +syn keyword ngxDirective uwsgi_connect_timeout +syn keyword ngxDirective uwsgi_force_ranges +syn keyword ngxDirective uwsgi_hide_header +syn keyword ngxDirective uwsgi_ignore_client_abort +syn keyword ngxDirective uwsgi_ignore_headers +syn keyword ngxDirective uwsgi_intercept_errors +syn keyword ngxDirective uwsgi_limit_rate +syn keyword ngxDirective uwsgi_max_temp_file_size +syn keyword ngxDirective uwsgi_modifier1 +syn keyword ngxDirective uwsgi_modifier2 +syn keyword ngxDirective uwsgi_next_upstream +syn keyword ngxDirective uwsgi_next_upstream_timeout +syn keyword ngxDirective uwsgi_next_upstream_tries +syn keyword ngxDirective uwsgi_no_cache +syn keyword ngxDirective uwsgi_param +syn keyword ngxDirective uwsgi_pass +syn keyword ngxDirective uwsgi_pass_header +syn keyword ngxDirective uwsgi_pass_request_body +syn keyword ngxDirective uwsgi_pass_request_headers +syn keyword ngxDirective uwsgi_read_timeout +syn keyword ngxDirective uwsgi_request_buffering +syn keyword ngxDirective uwsgi_send_timeout +syn keyword ngxDirective uwsgi_ssl_certificate +syn keyword ngxDirective uwsgi_ssl_certificate_key +syn keyword ngxDirective uwsgi_ssl_ciphers +syn keyword ngxDirective uwsgi_ssl_crl +syn keyword ngxDirective uwsgi_ssl_name +syn keyword ngxDirective uwsgi_ssl_password_file +syn keyword ngxDirective uwsgi_ssl_protocols nextgroup=ngxSSLProtocol skipwhite +syn keyword ngxDirective uwsgi_ssl_server_name +syn keyword ngxDirective uwsgi_ssl_session_reuse +syn keyword ngxDirective uwsgi_ssl_trusted_certificate +syn keyword ngxDirective uwsgi_ssl_verify +syn keyword ngxDirective uwsgi_ssl_verify_depth +syn keyword ngxDirective uwsgi_store +syn keyword ngxDirective uwsgi_store_access +syn keyword ngxDirective uwsgi_string +syn keyword ngxDirective uwsgi_temp_file_write_size +syn keyword ngxDirective uwsgi_temp_path +syn keyword ngxDirective valid_referers +syn keyword ngxDirective variables_hash_bucket_size +syn keyword ngxDirective variables_hash_max_size +syn keyword ngxDirective worker_aio_requests +syn keyword ngxDirective worker_connections +syn keyword ngxDirective worker_cpu_affinity +syn keyword ngxDirective worker_priority +syn keyword ngxDirective worker_processes +syn keyword ngxDirective worker_rlimit_core +syn keyword ngxDirective worker_rlimit_nofile +syn keyword ngxDirective worker_rlimit_sigpending +syn keyword ngxDirective worker_threads +syn keyword ngxDirective working_directory +syn keyword ngxDirective xclient +syn keyword ngxDirective xml_entities +syn keyword ngxDirective xslt_last_modified +syn keyword ngxDirective xslt_param +syn keyword ngxDirective xslt_string_param +syn keyword ngxDirective xslt_stylesheet +syn keyword ngxDirective xslt_types +syn keyword ngxDirective zone + +" Do not enable highlighting of insecure ciphers if sslecure is loaded +if !exists('g:loaded_sslsecure') + " Mark insecure SSL Ciphers (Note: List might not not complete) + " Reference: https://www.openssl.org/docs/man1.0.2/apps/ciphers.html + syn match ngxSSLCipherInsecure '[^!]\zsSSLv3' + syn match ngxSSLCipherInsecure '[^!]\zsSSLv2' + syn match ngxSSLCipherInsecure '[^!]\zsHIGH' + syn match ngxSSLCipherInsecure '[^!]\zsMEDIUM' + syn match ngxSSLCipherInsecure '[^!]\zsLOW' + syn match ngxSSLCipherInsecure '[^!]\zsDEFAULT' + syn match ngxSSLCipherInsecure '[^!]\zsCOMPLEMENTOFDEFAULT' + syn match ngxSSLCipherInsecure '[^!]\zsALL' + syn match ngxSSLCipherInsecure '[^!]\zsCOMPLEMENTOFALL' + + " SHA ciphers are only used in HMAC with all known OpenSSL/ LibreSSL cipher suites and MAC + " usage is still considered safe + " syn match ngxSSLCipherInsecure '[^!]\zsSHA\ze\D' " Match SHA1 without matching SHA256+ + " syn match ngxSSLCipherInsecure '[^!]\zsSHA1' + syn match ngxSSLCipherInsecure '[^!]\zsMD5' + syn match ngxSSLCipherInsecure '[^!]\zsRC2' + syn match ngxSSLCipherInsecure '[^!]\zsRC4' + syn match ngxSSLCipherInsecure '[^!]\zs3DES' + syn match ngxSSLCipherInsecure '[^!3]\zsDES' + syn match ngxSSLCipherInsecure '[^!]\zsaDSS' + syn match ngxSSLCipherInsecure '[^!a]\zsDSS' + syn match ngxSSLCipherInsecure '[^!]\zsPSK' + syn match ngxSSLCipherInsecure '[^!]\zsIDEA' + syn match ngxSSLCipherInsecure '[^!]\zsSEED' + syn match ngxSSLCipherInsecure '[^!]\zsEXP\w*' " Match all EXPORT ciphers + syn match ngxSSLCipherInsecure '[^!]\zsaGOST\w*' " Match all GOST ciphers + syn match ngxSSLCipherInsecure '[^!]\zskGOST\w*' + syn match ngxSSLCipherInsecure '[^!ak]\zsGOST\w*' + syn match ngxSSLCipherInsecure '[^!]\zs[kae]\?FZA' " Not implemented + syn match ngxSSLCipherInsecure '[^!]\zsECB' + syn match ngxSSLCipherInsecure '[^!]\zs[aes]NULL' + + " Anonymous cipher suites should never be used + syn match ngxSSLCipherInsecure '[^!ECa]\zsDH\ze[^E]' " Try to match DH without DHE, EDH, EECDH, etc. + syn match ngxSSLCipherInsecure '[^!EA]\zsECDH\ze[^E]' " Do not match EECDH, ECDHE + syn match ngxSSLCipherInsecure '[^!]\zsADH' + syn match ngxSSLCipherInsecure '[^!]\zskDHE' + syn match ngxSSLCipherInsecure '[^!]\zskEDH' + syn match ngxSSLCipherInsecure '[^!]\zskECDHE' + syn match ngxSSLCipherInsecure '[^!]\zskEECDH' + syn match ngxSSLCipherInsecure '[^!E]\zsAECDH' +endif + +syn keyword ngxProxyNextUpstreamOptions error contained +syn keyword ngxProxyNextUpstreamOptions timeout contained +syn keyword ngxProxyNextUpstreamOptions invalid_header contained +syn keyword ngxProxyNextUpstreamOptions http_500 contained +syn keyword ngxProxyNextUpstreamOptions http_502 contained +syn keyword ngxProxyNextUpstreamOptions http_503 contained +syn keyword ngxProxyNextUpstreamOptions http_504 contained +syn keyword ngxProxyNextUpstreamOptions http_403 contained +syn keyword ngxProxyNextUpstreamOptions http_404 contained +syn keyword ngxProxyNextUpstreamOptions http_429 contained +syn keyword ngxProxyNextUpstreamOptions non_idempotent contained +syn keyword ngxProxyNextUpstreamOptions off contained + +syn keyword ngxStickyOptions cookie contained +syn region ngxStickyOptionsCookie matchgroup=ngxStickyOptions start=+^\s*\zssticky\s\s*cookie\ze\s.*;+ skip=+\\\\\|\\\;+ end=+;+he=e-1 contains=ngxCookieOptions,ngxString,ngxBoolean,ngxInteger,ngxTemplateVar +syn keyword ngxStickyOptions route contained +syn keyword ngxStickyOptions learn contained + +syn keyword ngxCookieOptions expires contained +syn keyword ngxCookieOptions domain contained +syn keyword ngxCookieOptions httponly contained +syn keyword ngxCookieOptions secure contained +syn keyword ngxCookieOptions path contained + +" 3rd party module list: +" https://www.nginx.com/resources/wiki/modules/ + +" Accept Language Module +" Parses the Accept-Language header and gives the most suitable locale from a list of supported locales. +syn keyword ngxDirectiveThirdParty set_from_accept_language + +" Access Key Module (DEPRECATED) +" Denies access unless the request URL contains an access key. +syn keyword ngxDirectiveDeprecated accesskey +syn keyword ngxDirectiveDeprecated accesskey_arg +syn keyword ngxDirectiveDeprecated accesskey_hashmethod +syn keyword ngxDirectiveDeprecated accesskey_signature + +" Asynchronous FastCGI Module +" Primarily a modified version of the Nginx FastCGI module which implements multiplexing of connections, allowing a single FastCGI server to handle many concurrent requests. +" syn keyword ngxDirectiveThirdParty fastcgi_bind +" syn keyword ngxDirectiveThirdParty fastcgi_buffer_size +" syn keyword ngxDirectiveThirdParty fastcgi_buffers +" syn keyword ngxDirectiveThirdParty fastcgi_busy_buffers_size +" syn keyword ngxDirectiveThirdParty fastcgi_cache +" syn keyword ngxDirectiveThirdParty fastcgi_cache_key +" syn keyword ngxDirectiveThirdParty fastcgi_cache_methods +" syn keyword ngxDirectiveThirdParty fastcgi_cache_min_uses +" syn keyword ngxDirectiveThirdParty fastcgi_cache_path +" syn keyword ngxDirectiveThirdParty fastcgi_cache_use_stale +" syn keyword ngxDirectiveThirdParty fastcgi_cache_valid +" syn keyword ngxDirectiveThirdParty fastcgi_catch_stderr +" syn keyword ngxDirectiveThirdParty fastcgi_connect_timeout +" syn keyword ngxDirectiveThirdParty fastcgi_hide_header +" syn keyword ngxDirectiveThirdParty fastcgi_ignore_client_abort +" syn keyword ngxDirectiveThirdParty fastcgi_ignore_headers +" syn keyword ngxDirectiveThirdParty fastcgi_index +" syn keyword ngxDirectiveThirdParty fastcgi_intercept_errors +" syn keyword ngxDirectiveThirdParty fastcgi_max_temp_file_size +" syn keyword ngxDirectiveThirdParty fastcgi_next_upstream +" syn keyword ngxDirectiveThirdParty fastcgi_param +" syn keyword ngxDirectiveThirdParty fastcgi_pass +" syn keyword ngxDirectiveThirdParty fastcgi_pass_header +" syn keyword ngxDirectiveThirdParty fastcgi_pass_request_body +" syn keyword ngxDirectiveThirdParty fastcgi_pass_request_headers +" syn keyword ngxDirectiveThirdParty fastcgi_read_timeout +" syn keyword ngxDirectiveThirdParty fastcgi_send_lowat +" syn keyword ngxDirectiveThirdParty fastcgi_send_timeout +" syn keyword ngxDirectiveThirdParty fastcgi_split_path_info +" syn keyword ngxDirectiveThirdParty fastcgi_store +" syn keyword ngxDirectiveThirdParty fastcgi_store_access +" syn keyword ngxDirectiveThirdParty fastcgi_temp_file_write_size +" syn keyword ngxDirectiveThirdParty fastcgi_temp_path +syn keyword ngxDirectiveDeprecated fastcgi_upstream_fail_timeout +syn keyword ngxDirectiveDeprecated fastcgi_upstream_max_fails + +" Akamai G2O Module +" Nginx Module for Authenticating Akamai G2O requests +syn keyword ngxDirectiveThirdParty g2o +syn keyword ngxDirectiveThirdParty g2o_nonce +syn keyword ngxDirectiveThirdParty g2o_key + +" Lua Module +" You can be very simple to execute lua code for nginx +syn keyword ngxDirectiveThirdParty lua_file + +" Array Variable Module +" Add support for array-typed variables to nginx config files +syn keyword ngxDirectiveThirdParty array_split +syn keyword ngxDirectiveThirdParty array_join +syn keyword ngxDirectiveThirdParty array_map +syn keyword ngxDirectiveThirdParty array_map_op + +" Nginx Audio Track for HTTP Live Streaming +" This nginx module generates audio track for hls streams on the fly. +syn keyword ngxDirectiveThirdParty ngx_hls_audio_track +syn keyword ngxDirectiveThirdParty ngx_hls_audio_track_rootpath +syn keyword ngxDirectiveThirdParty ngx_hls_audio_track_output_format +syn keyword ngxDirectiveThirdParty ngx_hls_audio_track_output_header + +" AWS Proxy Module +" Nginx module to proxy to authenticated AWS services +syn keyword ngxDirectiveThirdParty aws_access_key +syn keyword ngxDirectiveThirdParty aws_key_scope +syn keyword ngxDirectiveThirdParty aws_signing_key +syn keyword ngxDirectiveThirdParty aws_endpoint +syn keyword ngxDirectiveThirdParty aws_s3_bucket +syn keyword ngxDirectiveThirdParty aws_sign + +" Backtrace module +" A Nginx module to dump backtrace when a worker process exits abnormally +syn keyword ngxDirectiveThirdParty backtrace_log +syn keyword ngxDirectiveThirdParty backtrace_max_stack_size + +" Brotli Module +" Nginx module for Brotli compression +syn keyword ngxDirectiveThirdParty brotli_static +syn keyword ngxDirectiveThirdParty brotli +syn keyword ngxDirectiveThirdParty brotli_types +syn keyword ngxDirectiveThirdParty brotli_buffers +syn keyword ngxDirectiveThirdParty brotli_comp_level +syn keyword ngxDirectiveThirdParty brotli_window +syn keyword ngxDirectiveThirdParty brotli_min_length + +" Cache Purge Module +" Adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches. +syn keyword ngxDirectiveThirdParty fastcgi_cache_purge +syn keyword ngxDirectiveThirdParty proxy_cache_purge +" syn keyword ngxDirectiveThirdParty scgi_cache_purge +" syn keyword ngxDirectiveThirdParty uwsgi_cache_purge + +" Chunkin Module (DEPRECATED) +" HTTP 1.1 chunked-encoding request body support for Nginx. +syn keyword ngxDirectiveDeprecated chunkin +syn keyword ngxDirectiveDeprecated chunkin_keepalive +syn keyword ngxDirectiveDeprecated chunkin_max_chunks_per_buf +syn keyword ngxDirectiveDeprecated chunkin_resume + +" Circle GIF Module +" Generates simple circle images with the colors and size specified in the URL. +syn keyword ngxDirectiveThirdParty circle_gif +syn keyword ngxDirectiveThirdParty circle_gif_max_radius +syn keyword ngxDirectiveThirdParty circle_gif_min_radius +syn keyword ngxDirectiveThirdParty circle_gif_step_radius + +" Nginx-Clojure Module +" Parses the Accept-Language header and gives the most suitable locale from a list of supported locales. +syn keyword ngxDirectiveThirdParty jvm_path +syn keyword ngxDirectiveThirdParty jvm_var +syn keyword ngxDirectiveThirdParty jvm_classpath +syn keyword ngxDirectiveThirdParty jvm_classpath_check +syn keyword ngxDirectiveThirdParty jvm_workers +syn keyword ngxDirectiveThirdParty jvm_options +syn keyword ngxDirectiveThirdParty jvm_handler_type +syn keyword ngxDirectiveThirdParty jvm_init_handler_name +syn keyword ngxDirectiveThirdParty jvm_init_handler_code +syn keyword ngxDirectiveThirdParty jvm_exit_handler_name +syn keyword ngxDirectiveThirdParty jvm_exit_handler_code +syn keyword ngxDirectiveThirdParty handlers_lazy_init +syn keyword ngxDirectiveThirdParty auto_upgrade_ws +syn keyword ngxDirectiveThirdParty content_handler_type +syn keyword ngxDirectiveThirdParty content_handler_name +syn keyword ngxDirectiveThirdParty content_handler_code +syn keyword ngxDirectiveThirdParty rewrite_handler_type +syn keyword ngxDirectiveThirdParty rewrite_handler_name +syn keyword ngxDirectiveThirdParty rewrite_handler_code +syn keyword ngxDirectiveThirdParty access_handler_type +syn keyword ngxDirectiveThirdParty access_handler_name +syn keyword ngxDirectiveThirdParty access_handler_code +syn keyword ngxDirectiveThirdParty header_filter_type +syn keyword ngxDirectiveThirdParty header_filter_name +syn keyword ngxDirectiveThirdParty header_filter_code +syn keyword ngxDirectiveThirdParty content_handler_property +syn keyword ngxDirectiveThirdParty rewrite_handler_property +syn keyword ngxDirectiveThirdParty access_handler_property +syn keyword ngxDirectiveThirdParty header_filter_property +syn keyword ngxDirectiveThirdParty always_read_body +syn keyword ngxDirectiveThirdParty shared_map +syn keyword ngxDirectiveThirdParty write_page_size + +" Upstream Consistent Hash +" A load balancer that uses an internal consistent hash ring to select the right backend node. +syn keyword ngxDirectiveThirdParty consistent_hash + +" Nginx Development Kit +" The NDK is an Nginx module that is designed to extend the core functionality of the excellent Nginx webserver in a way that can be used as a basis of other Nginx modules. +" NDK_UPSTREAM_LIST +" This submodule provides a directive that creates a list of upstreams, with optional weighting. This list can then be used by other modules to hash over the upstreams however they choose. +syn keyword ngxDirectiveThirdParty upstream_list + +" Drizzle Module +" Upstream module for talking to MySQL and Drizzle directly +syn keyword ngxDirectiveThirdParty drizzle_server +syn keyword ngxDirectiveThirdParty drizzle_keepalive +syn keyword ngxDirectiveThirdParty drizzle_query +syn keyword ngxDirectiveThirdParty drizzle_pass +syn keyword ngxDirectiveThirdParty drizzle_connect_timeout +syn keyword ngxDirectiveThirdParty drizzle_send_query_timeout +syn keyword ngxDirectiveThirdParty drizzle_recv_cols_timeout +syn keyword ngxDirectiveThirdParty drizzle_recv_rows_timeout +syn keyword ngxDirectiveThirdParty drizzle_buffer_size +syn keyword ngxDirectiveThirdParty drizzle_module_header +syn keyword ngxDirectiveThirdParty drizzle_status + +" Dynamic ETags Module +" Attempt at handling ETag / If-None-Match on proxied content. +syn keyword ngxDirectiveThirdParty dynamic_etags + +" Echo Module +" Bringing the power of "echo", "sleep", "time" and more to Nginx's config file +syn keyword ngxDirectiveThirdParty echo +syn keyword ngxDirectiveThirdParty echo_duplicate +syn keyword ngxDirectiveThirdParty echo_flush +syn keyword ngxDirectiveThirdParty echo_sleep +syn keyword ngxDirectiveThirdParty echo_blocking_sleep +syn keyword ngxDirectiveThirdParty echo_reset_timer +syn keyword ngxDirectiveThirdParty echo_read_request_body +syn keyword ngxDirectiveThirdParty echo_location_async +syn keyword ngxDirectiveThirdParty echo_location +syn keyword ngxDirectiveThirdParty echo_subrequest_async +syn keyword ngxDirectiveThirdParty echo_subrequest +syn keyword ngxDirectiveThirdParty echo_foreach_split +syn keyword ngxDirectiveThirdParty echo_end +syn keyword ngxDirectiveThirdParty echo_request_body +syn keyword ngxDirectiveThirdParty echo_exec +syn keyword ngxDirectiveThirdParty echo_status +syn keyword ngxDirectiveThirdParty echo_before_body +syn keyword ngxDirectiveThirdParty echo_after_body + +" Encrypted Session Module +" Encrypt and decrypt nginx variable values +syn keyword ngxDirectiveThirdParty encrypted_session_key +syn keyword ngxDirectiveThirdParty encrypted_session_iv +syn keyword ngxDirectiveThirdParty encrypted_session_expires +syn keyword ngxDirectiveThirdParty set_encrypt_session +syn keyword ngxDirectiveThirdParty set_decrypt_session + +" Enhanced Memcached Module +" This module is based on the standard Nginx Memcached module, with some additonal features +syn keyword ngxDirectiveThirdParty enhanced_memcached_pass +syn keyword ngxDirectiveThirdParty enhanced_memcached_hash_keys_with_md5 +syn keyword ngxDirectiveThirdParty enhanced_memcached_allow_put +syn keyword ngxDirectiveThirdParty enhanced_memcached_allow_delete +syn keyword ngxDirectiveThirdParty enhanced_memcached_stats +syn keyword ngxDirectiveThirdParty enhanced_memcached_flush +syn keyword ngxDirectiveThirdParty enhanced_memcached_flush_namespace +syn keyword ngxDirectiveThirdParty enhanced_memcached_bind +syn keyword ngxDirectiveThirdParty enhanced_memcached_connect_timeout +syn keyword ngxDirectiveThirdParty enhanced_memcached_send_timeout +syn keyword ngxDirectiveThirdParty enhanced_memcached_buffer_size +syn keyword ngxDirectiveThirdParty enhanced_memcached_read_timeout + +" Events Module (DEPRECATED) +" Provides options for start/stop events. +syn keyword ngxDirectiveDeprecated on_start +syn keyword ngxDirectiveDeprecated on_stop + +" EY Balancer Module +" Adds a request queue to Nginx that allows the limiting of concurrent requests passed to the upstream. +syn keyword ngxDirectiveThirdParty max_connections +syn keyword ngxDirectiveThirdParty max_connections_max_queue_length +syn keyword ngxDirectiveThirdParty max_connections_queue_timeout + +" Upstream Fair Balancer +" Sends an incoming request to the least-busy backend server, rather than distributing requests round-robin. +syn keyword ngxDirectiveThirdParty fair +syn keyword ngxDirectiveThirdParty upstream_fair_shm_size + +" Fancy Indexes Module +" Like the built-in autoindex module, but fancier. +syn keyword ngxDirectiveThirdParty fancyindex +syn keyword ngxDirectiveThirdParty fancyindex_default_sort +syn keyword ngxDirectiveThirdParty fancyindex_directories_first +syn keyword ngxDirectiveThirdParty fancyindex_css_href +syn keyword ngxDirectiveThirdParty fancyindex_exact_size +syn keyword ngxDirectiveThirdParty fancyindex_name_length +syn keyword ngxDirectiveThirdParty fancyindex_footer +syn keyword ngxDirectiveThirdParty fancyindex_header +syn keyword ngxDirectiveThirdParty fancyindex_show_path +syn keyword ngxDirectiveThirdParty fancyindex_ignore +syn keyword ngxDirectiveThirdParty fancyindex_hide_symlinks +syn keyword ngxDirectiveThirdParty fancyindex_localtime +syn keyword ngxDirectiveThirdParty fancyindex_time_format + +" Form Auth Module +" Provides authentication and authorization with credentials submitted via POST request +syn keyword ngxDirectiveThirdParty form_auth +syn keyword ngxDirectiveThirdParty form_auth_pam_service +syn keyword ngxDirectiveThirdParty form_auth_login +syn keyword ngxDirectiveThirdParty form_auth_password +syn keyword ngxDirectiveThirdParty form_auth_remote_user + +" Form Input Module +" Reads HTTP POST and PUT request body encoded in "application/x-www-form-urlencoded" and parses the arguments into nginx variables. +syn keyword ngxDirectiveThirdParty set_form_input +syn keyword ngxDirectiveThirdParty set_form_input_multi + +" GeoIP Module (DEPRECATED) +" Country code lookups via the MaxMind GeoIP API. +syn keyword ngxDirectiveDeprecated geoip_country_file + +" GeoIP 2 Module +" Creates variables with values from the maxmind geoip2 databases based on the client IP +syn keyword ngxDirectiveThirdParty geoip2 + +" GridFS Module +" Nginx module for serving files from MongoDB's GridFS +syn keyword ngxDirectiveThirdParty gridfs + +" Headers More Module +" Set and clear input and output headers...more than "add"! +syn keyword ngxDirectiveThirdParty more_clear_headers +syn keyword ngxDirectiveThirdParty more_clear_input_headers +syn keyword ngxDirectiveThirdParty more_set_headers +syn keyword ngxDirectiveThirdParty more_set_input_headers + +" Health Checks Upstreams Module +" Polls backends and if they respond with HTTP 200 + an optional request body, they are marked good. Otherwise, they are marked bad. +syn keyword ngxDirectiveThirdParty healthcheck_enabled +syn keyword ngxDirectiveThirdParty healthcheck_delay +syn keyword ngxDirectiveThirdParty healthcheck_timeout +syn keyword ngxDirectiveThirdParty healthcheck_failcount +syn keyword ngxDirectiveThirdParty healthcheck_send +syn keyword ngxDirectiveThirdParty healthcheck_expected +syn keyword ngxDirectiveThirdParty healthcheck_buffer +syn keyword ngxDirectiveThirdParty healthcheck_status + +" HTTP Accounting Module +" Add traffic stat function to nginx. Useful for http accounting based on nginx configuration logic +syn keyword ngxDirectiveThirdParty http_accounting +syn keyword ngxDirectiveThirdParty http_accounting_log +syn keyword ngxDirectiveThirdParty http_accounting_id +syn keyword ngxDirectiveThirdParty http_accounting_interval +syn keyword ngxDirectiveThirdParty http_accounting_perturb + +" Nginx Digest Authentication module +" Digest Authentication for Nginx +syn keyword ngxDirectiveThirdParty auth_digest +syn keyword ngxDirectiveThirdParty auth_digest_user_file +syn keyword ngxDirectiveThirdParty auth_digest_timeout +syn keyword ngxDirectiveThirdParty auth_digest_expires +syn keyword ngxDirectiveThirdParty auth_digest_replays +syn keyword ngxDirectiveThirdParty auth_digest_shm_size + +" Auth PAM Module +" HTTP Basic Authentication using PAM. +syn keyword ngxDirectiveThirdParty auth_pam +syn keyword ngxDirectiveThirdParty auth_pam_service_name + +" HTTP Auth Request Module +" Implements client authorization based on the result of a subrequest +" syn keyword ngxDirectiveThirdParty auth_request +" syn keyword ngxDirectiveThirdParty auth_request_set + +" HTTP Concatenation module for Nginx +" A Nginx module for concatenating files in a given context: CSS and JS files usually +syn keyword ngxDirectiveThirdParty concat +syn keyword ngxDirectiveThirdParty concat_types +syn keyword ngxDirectiveThirdParty concat_unique +syn keyword ngxDirectiveThirdParty concat_max_files +syn keyword ngxDirectiveThirdParty concat_delimiter +syn keyword ngxDirectiveThirdParty concat_ignore_file_error + +" HTTP Dynamic Upstream Module +" Update upstreams' config by restful interface +syn keyword ngxDirectiveThirdParty dyups_interface +syn keyword ngxDirectiveThirdParty dyups_read_msg_timeout +syn keyword ngxDirectiveThirdParty dyups_shm_zone_size +syn keyword ngxDirectiveThirdParty dyups_upstream_conf +syn keyword ngxDirectiveThirdParty dyups_trylock + +" HTTP Footer If Filter Module +" The ngx_http_footer_if_filter_module is used to add given content to the end of the response according to the condition specified. +syn keyword ngxDirectiveThirdParty footer_if + +" HTTP Footer Filter Module +" This module implements a body filter that adds a given string to the page footer. +syn keyword ngxDirectiveThirdParty footer +syn keyword ngxDirectiveThirdParty footer_types + +" HTTP Internal Redirect Module +" Make an internal redirect to the uri specified according to the condition specified. +syn keyword ngxDirectiveThirdParty internal_redirect_if +syn keyword ngxDirectiveThirdParty internal_redirect_if_no_postponed + +" HTTP JavaScript Module +" Embedding SpiderMonkey. Nearly full port on Perl module. +syn keyword ngxDirectiveThirdParty js +syn keyword ngxDirectiveThirdParty js_filter +syn keyword ngxDirectiveThirdParty js_filter_types +syn keyword ngxDirectiveThirdParty js_load +syn keyword ngxDirectiveThirdParty js_maxmem +syn keyword ngxDirectiveThirdParty js_require +syn keyword ngxDirectiveThirdParty js_set +syn keyword ngxDirectiveThirdParty js_utf8 + +" HTTP Push Module (DEPRECATED) +" Turn Nginx into an adept long-polling HTTP Push (Comet) server. +syn keyword ngxDirectiveDeprecated push_buffer_size +syn keyword ngxDirectiveDeprecated push_listener +syn keyword ngxDirectiveDeprecated push_message_timeout +syn keyword ngxDirectiveDeprecated push_queue_messages +syn keyword ngxDirectiveDeprecated push_sender + +" HTTP Redis Module +" Redis support. +syn keyword ngxDirectiveThirdParty redis_bind +syn keyword ngxDirectiveThirdParty redis_buffer_size +syn keyword ngxDirectiveThirdParty redis_connect_timeout +syn keyword ngxDirectiveThirdParty redis_next_upstream +syn keyword ngxDirectiveThirdParty redis_pass +syn keyword ngxDirectiveThirdParty redis_read_timeout +syn keyword ngxDirectiveThirdParty redis_send_timeout + +" Iconv Module +" A character conversion nginx module using libiconv +syn keyword ngxDirectiveThirdParty set_iconv +syn keyword ngxDirectiveThirdParty iconv_buffer_size +syn keyword ngxDirectiveThirdParty iconv_filter + +" IP Blocker Module +" An efficient shared memory IP blocking system for nginx. +syn keyword ngxDirectiveThirdParty ip_blocker + +" IP2Location Module +" Allows user to lookup for geolocation information using IP2Location database +syn keyword ngxDirectiveThirdParty ip2location_database + +" JS Module +" Reflect the nginx functionality in JS +syn keyword ngxDirectiveThirdParty js +syn keyword ngxDirectiveThirdParty js_access +syn keyword ngxDirectiveThirdParty js_load +syn keyword ngxDirectiveThirdParty js_set + +" Limit Upload Rate Module +" Limit client-upload rate when they are sending request bodies to you +syn keyword ngxDirectiveThirdParty limit_upload_rate +syn keyword ngxDirectiveThirdParty limit_upload_rate_after + +" Limit Upstream Module +" Limit the number of connections to upstream for NGINX +syn keyword ngxDirectiveThirdParty limit_upstream_zone +syn keyword ngxDirectiveThirdParty limit_upstream_conn +syn keyword ngxDirectiveThirdParty limit_upstream_log_level + +" Log If Module +" Conditional accesslog for nginx +syn keyword ngxDirectiveThirdParty access_log_bypass_if + +" Log Request Speed (DEPRECATED) +" Log the time it took to process each request. +syn keyword ngxDirectiveDeprecated log_request_speed_filter +syn keyword ngxDirectiveDeprecated log_request_speed_filter_timeout + +" Log ZeroMQ Module +" ZeroMQ logger module for nginx +syn keyword ngxDirectiveThirdParty log_zmq_server +syn keyword ngxDirectiveThirdParty log_zmq_endpoint +syn keyword ngxDirectiveThirdParty log_zmq_format +syn keyword ngxDirectiveThirdParty log_zmq_off + +" Lower/UpperCase Module +" This module simply uppercases or lowercases a string and saves it into a new variable. +syn keyword ngxDirectiveThirdParty lower +syn keyword ngxDirectiveThirdParty upper + +" Lua Upstream Module +" Nginx C module to expose Lua API to ngx_lua for Nginx upstreams + +" Lua Module +" Embed the Power of Lua into NGINX HTTP servers +syn keyword ngxDirectiveThirdParty lua_use_default_type +syn keyword ngxDirectiveThirdParty lua_malloc_trim +syn keyword ngxDirectiveThirdParty lua_code_cache +syn keyword ngxDirectiveThirdParty lua_regex_cache_max_entries +syn keyword ngxDirectiveThirdParty lua_regex_match_limit +syn keyword ngxDirectiveThirdParty lua_package_path +syn keyword ngxDirectiveThirdParty lua_package_cpath +syn keyword ngxDirectiveThirdParty init_by_lua +syn keyword ngxDirectiveThirdParty init_by_lua_file +syn keyword ngxDirectiveThirdParty init_worker_by_lua +syn keyword ngxDirectiveThirdParty init_worker_by_lua_file +syn keyword ngxDirectiveThirdParty set_by_lua +syn keyword ngxDirectiveThirdParty set_by_lua_file +syn keyword ngxDirectiveThirdParty content_by_lua +syn keyword ngxDirectiveThirdParty content_by_lua_file +syn keyword ngxDirectiveThirdParty rewrite_by_lua +syn keyword ngxDirectiveThirdParty rewrite_by_lua_file +syn keyword ngxDirectiveThirdParty access_by_lua +syn keyword ngxDirectiveThirdParty access_by_lua_file +syn keyword ngxDirectiveThirdParty header_filter_by_lua +syn keyword ngxDirectiveThirdParty header_filter_by_lua_file +syn keyword ngxDirectiveThirdParty body_filter_by_lua +syn keyword ngxDirectiveThirdParty body_filter_by_lua_file +syn keyword ngxDirectiveThirdParty log_by_lua +syn keyword ngxDirectiveThirdParty log_by_lua_file +syn keyword ngxDirectiveThirdParty balancer_by_lua_file +syn keyword ngxDirectiveThirdParty lua_need_request_body +syn keyword ngxDirectiveThirdParty ssl_certificate_by_lua_file +syn keyword ngxDirectiveThirdParty ssl_session_fetch_by_lua_file +syn keyword ngxDirectiveThirdParty ssl_session_store_by_lua_file +syn keyword ngxDirectiveThirdParty lua_shared_dict +syn keyword ngxDirectiveThirdParty lua_socket_connect_timeout +syn keyword ngxDirectiveThirdParty lua_socket_send_timeout +syn keyword ngxDirectiveThirdParty lua_socket_send_lowat +syn keyword ngxDirectiveThirdParty lua_socket_read_timeout +syn keyword ngxDirectiveThirdParty lua_socket_buffer_size +syn keyword ngxDirectiveThirdParty lua_socket_pool_size +syn keyword ngxDirectiveThirdParty lua_socket_keepalive_timeout +syn keyword ngxDirectiveThirdParty lua_socket_log_errors +syn keyword ngxDirectiveThirdParty lua_ssl_ciphers +syn keyword ngxDirectiveThirdParty lua_ssl_crl +syn keyword ngxDirectiveThirdParty lua_ssl_protocols +syn keyword ngxDirectiveThirdParty lua_ssl_trusted_certificate +syn keyword ngxDirectiveThirdParty lua_ssl_verify_depth +syn keyword ngxDirectiveThirdParty lua_http10_buffering +syn keyword ngxDirectiveThirdParty rewrite_by_lua_no_postpone +syn keyword ngxDirectiveThirdParty access_by_lua_no_postpone +syn keyword ngxDirectiveThirdParty lua_transform_underscores_in_response_headers +syn keyword ngxDirectiveThirdParty lua_check_client_abort +syn keyword ngxDirectiveThirdParty lua_max_pending_timers +syn keyword ngxDirectiveThirdParty lua_max_running_timers + +" MD5 Filter Module +" A content filter for nginx, which returns the md5 hash of the content otherwise returned. +syn keyword ngxDirectiveThirdParty md5_filter + +" Memc Module +" An extended version of the standard memcached module that supports set, add, delete, and many more memcached commands. +syn keyword ngxDirectiveThirdParty memc_buffer_size +syn keyword ngxDirectiveThirdParty memc_cmds_allowed +syn keyword ngxDirectiveThirdParty memc_connect_timeout +syn keyword ngxDirectiveThirdParty memc_flags_to_last_modified +syn keyword ngxDirectiveThirdParty memc_next_upstream +syn keyword ngxDirectiveThirdParty memc_pass +syn keyword ngxDirectiveThirdParty memc_read_timeout +syn keyword ngxDirectiveThirdParty memc_send_timeout +syn keyword ngxDirectiveThirdParty memc_upstream_fail_timeout +syn keyword ngxDirectiveThirdParty memc_upstream_max_fails + +" Mod Security Module +" ModSecurity is an open source, cross platform web application firewall (WAF) engine +syn keyword ngxDirectiveThirdParty ModSecurityConfig +syn keyword ngxDirectiveThirdParty ModSecurityEnabled +syn keyword ngxDirectiveThirdParty pool_context +syn keyword ngxDirectiveThirdParty pool_context_hash_size + +" Mogilefs Module +" MogileFS client for nginx web server. +syn keyword ngxDirectiveThirdParty mogilefs_pass +syn keyword ngxDirectiveThirdParty mogilefs_methods +syn keyword ngxDirectiveThirdParty mogilefs_domain +syn keyword ngxDirectiveThirdParty mogilefs_class +syn keyword ngxDirectiveThirdParty mogilefs_tracker +syn keyword ngxDirectiveThirdParty mogilefs_noverify +syn keyword ngxDirectiveThirdParty mogilefs_connect_timeout +syn keyword ngxDirectiveThirdParty mogilefs_send_timeout +syn keyword ngxDirectiveThirdParty mogilefs_read_timeout + +" Mongo Module +" Upstream module that allows nginx to communicate directly with MongoDB database. +syn keyword ngxDirectiveThirdParty mongo_auth +syn keyword ngxDirectiveThirdParty mongo_pass +syn keyword ngxDirectiveThirdParty mongo_query +syn keyword ngxDirectiveThirdParty mongo_json +syn keyword ngxDirectiveThirdParty mongo_bind +syn keyword ngxDirectiveThirdParty mongo_connect_timeout +syn keyword ngxDirectiveThirdParty mongo_send_timeout +syn keyword ngxDirectiveThirdParty mongo_read_timeout +syn keyword ngxDirectiveThirdParty mongo_buffering +syn keyword ngxDirectiveThirdParty mongo_buffer_size +syn keyword ngxDirectiveThirdParty mongo_buffers +syn keyword ngxDirectiveThirdParty mongo_busy_buffers_size +syn keyword ngxDirectiveThirdParty mongo_next_upstream + +" MP4 Streaming Lite Module +" Will seek to a certain time within H.264/MP4 files when provided with a 'start' parameter in the URL. +" syn keyword ngxDirectiveThirdParty mp4 + +" NAXSI Module +" NAXSI is an open-source, high performance, low rules maintenance WAF for NGINX +syn keyword ngxDirectiveThirdParty DeniedUrl denied_url +syn keyword ngxDirectiveThirdParty LearningMode learning_mode +syn keyword ngxDirectiveThirdParty SecRulesEnabled rules_enabled +syn keyword ngxDirectiveThirdParty SecRulesDisabled rules_disabled +syn keyword ngxDirectiveThirdParty CheckRule check_rule +syn keyword ngxDirectiveThirdParty BasicRule basic_rule +syn keyword ngxDirectiveThirdParty MainRule main_rule +syn keyword ngxDirectiveThirdParty LibInjectionSql libinjection_sql +syn keyword ngxDirectiveThirdParty LibInjectionXss libinjection_xss + +" Nchan Module +" Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE) +syn keyword ngxDirectiveThirdParty nchan_channel_id +syn keyword ngxDirectiveThirdParty nchan_channel_id_split_delimiter +syn keyword ngxDirectiveThirdParty nchan_eventsource_event +syn keyword ngxDirectiveThirdParty nchan_longpoll_multipart_response +syn keyword ngxDirectiveThirdParty nchan_publisher +syn keyword ngxDirectiveThirdParty nchan_publisher_channel_id +syn keyword ngxDirectiveThirdParty nchan_publisher_upstream_request +syn keyword ngxDirectiveThirdParty nchan_pubsub +syn keyword ngxDirectiveThirdParty nchan_subscribe_request +syn keyword ngxDirectiveThirdParty nchan_subscriber +syn keyword ngxDirectiveThirdParty nchan_subscriber_channel_id +syn keyword ngxDirectiveThirdParty nchan_subscriber_compound_etag_message_id +syn keyword ngxDirectiveThirdParty nchan_subscriber_first_message +syn keyword ngxDirectiveThirdParty nchan_subscriber_http_raw_stream_separator +syn keyword ngxDirectiveThirdParty nchan_subscriber_last_message_id +syn keyword ngxDirectiveThirdParty nchan_subscriber_message_id_custom_etag_header +syn keyword ngxDirectiveThirdParty nchan_subscriber_timeout +syn keyword ngxDirectiveThirdParty nchan_unsubscribe_request +syn keyword ngxDirectiveThirdParty nchan_websocket_ping_interval +syn keyword ngxDirectiveThirdParty nchan_authorize_request +syn keyword ngxDirectiveThirdParty nchan_max_reserved_memory +syn keyword ngxDirectiveThirdParty nchan_message_buffer_length +syn keyword ngxDirectiveThirdParty nchan_message_timeout +syn keyword ngxDirectiveThirdParty nchan_redis_idle_channel_cache_timeout +syn keyword ngxDirectiveThirdParty nchan_redis_namespace +syn keyword ngxDirectiveThirdParty nchan_redis_pass +syn keyword ngxDirectiveThirdParty nchan_redis_ping_interval +syn keyword ngxDirectiveThirdParty nchan_redis_server +syn keyword ngxDirectiveThirdParty nchan_redis_storage_mode +syn keyword ngxDirectiveThirdParty nchan_redis_url +syn keyword ngxDirectiveThirdParty nchan_store_messages +syn keyword ngxDirectiveThirdParty nchan_use_redis +syn keyword ngxDirectiveThirdParty nchan_access_control_allow_origin +syn keyword ngxDirectiveThirdParty nchan_channel_group +syn keyword ngxDirectiveThirdParty nchan_channel_group_accounting +syn keyword ngxDirectiveThirdParty nchan_group_location +syn keyword ngxDirectiveThirdParty nchan_group_max_channels +syn keyword ngxDirectiveThirdParty nchan_group_max_messages +syn keyword ngxDirectiveThirdParty nchan_group_max_messages_disk +syn keyword ngxDirectiveThirdParty nchan_group_max_messages_memory +syn keyword ngxDirectiveThirdParty nchan_group_max_subscribers +syn keyword ngxDirectiveThirdParty nchan_subscribe_existing_channels_only +syn keyword ngxDirectiveThirdParty nchan_channel_event_string +syn keyword ngxDirectiveThirdParty nchan_channel_events_channel_id +syn keyword ngxDirectiveThirdParty nchan_stub_status +syn keyword ngxDirectiveThirdParty nchan_max_channel_id_length +syn keyword ngxDirectiveThirdParty nchan_max_channel_subscribers +syn keyword ngxDirectiveThirdParty nchan_channel_timeout +syn keyword ngxDirectiveThirdParty nchan_storage_engine + +" Nginx Notice Module +" Serve static file to POST requests. +syn keyword ngxDirectiveThirdParty notice +syn keyword ngxDirectiveThirdParty notice_type + +" OCSP Proxy Module +" Nginx OCSP processing module designed for response caching +syn keyword ngxDirectiveThirdParty ocsp_proxy +syn keyword ngxDirectiveThirdParty ocsp_cache_timeout + +" Eval Module +" Module for nginx web server evaluates response of proxy or memcached module into variables. +syn keyword ngxDirectiveThirdParty eval +syn keyword ngxDirectiveThirdParty eval_escalate +syn keyword ngxDirectiveThirdParty eval_buffer_size +syn keyword ngxDirectiveThirdParty eval_override_content_type +syn keyword ngxDirectiveThirdParty eval_subrequest_in_memory + +" OpenSSL Version Module +" Nginx OpenSSL version check at startup +syn keyword ngxDirectiveThirdParty openssl_version_minimum +syn keyword ngxDirectiveThirdParty openssl_builddate_minimum + +" Owner Match Module +" Control access for specific owners and groups of files +syn keyword ngxDirectiveThirdParty omallow +syn keyword ngxDirectiveThirdParty omdeny + +" Accept Language Module +" Parses the Accept-Language header and gives the most suitable locale from a list of supported locales. +syn keyword ngxDirectiveThirdParty pagespeed + +" PHP Memcache Standard Balancer Module +" Loadbalancer that is compatible to the standard loadbalancer in the php-memcache module +syn keyword ngxDirectiveThirdParty hash_key + +" PHP Session Module +" Nginx module to parse php sessions +syn keyword ngxDirectiveThirdParty php_session_parse +syn keyword ngxDirectiveThirdParty php_session_strip_formatting + +" Phusion Passenger Module +" Passenger is an open source web application server. +syn keyword ngxDirectiveThirdParty passenger_root +syn keyword ngxDirectiveThirdParty passenger_enabled +syn keyword ngxDirectiveThirdParty passenger_base_uri +syn keyword ngxDirectiveThirdParty passenger_document_root +syn keyword ngxDirectiveThirdParty passenger_ruby +syn keyword ngxDirectiveThirdParty passenger_python +syn keyword ngxDirectiveThirdParty passenger_nodejs +syn keyword ngxDirectiveThirdParty passenger_meteor_app_settings +syn keyword ngxDirectiveThirdParty passenger_app_env +syn keyword ngxDirectiveThirdParty passenger_app_root +syn keyword ngxDirectiveThirdParty passenger_app_group_name +syn keyword ngxDirectiveThirdParty passenger_app_type +syn keyword ngxDirectiveThirdParty passenger_startup_file +syn keyword ngxDirectiveThirdParty passenger_restart_dir +syn keyword ngxDirectiveThirdParty passenger_spawn_method +syn keyword ngxDirectiveThirdParty passenger_env_var +syn keyword ngxDirectiveThirdParty passenger_load_shell_envvars +syn keyword ngxDirectiveThirdParty passenger_rolling_restarts +syn keyword ngxDirectiveThirdParty passenger_resist_deployment_errors +syn keyword ngxDirectiveThirdParty passenger_user_switching +syn keyword ngxDirectiveThirdParty passenger_user +syn keyword ngxDirectiveThirdParty passenger_group +syn keyword ngxDirectiveThirdParty passenger_default_user +syn keyword ngxDirectiveThirdParty passenger_default_group +syn keyword ngxDirectiveThirdParty passenger_show_version_in_header +syn keyword ngxDirectiveThirdParty passenger_friendly_error_pages +syn keyword ngxDirectiveThirdParty passenger_disable_security_update_check +syn keyword ngxDirectiveThirdParty passenger_security_update_check_proxy +syn keyword ngxDirectiveThirdParty passenger_max_pool_size +syn keyword ngxDirectiveThirdParty passenger_min_instances +syn keyword ngxDirectiveThirdParty passenger_max_instances +syn keyword ngxDirectiveThirdParty passenger_max_instances_per_app +syn keyword ngxDirectiveThirdParty passenger_pool_idle_time +syn keyword ngxDirectiveThirdParty passenger_max_preloader_idle_time +syn keyword ngxDirectiveThirdParty passenger_force_max_concurrent_requests_per_process +syn keyword ngxDirectiveThirdParty passenger_start_timeout +syn keyword ngxDirectiveThirdParty passenger_concurrency_model +syn keyword ngxDirectiveThirdParty passenger_thread_count +syn keyword ngxDirectiveThirdParty passenger_max_requests +syn keyword ngxDirectiveThirdParty passenger_max_request_time +syn keyword ngxDirectiveThirdParty passenger_memory_limit +syn keyword ngxDirectiveThirdParty passenger_stat_throttle_rate +syn keyword ngxDirectiveThirdParty passenger_core_file_descriptor_ulimit +syn keyword ngxDirectiveThirdParty passenger_app_file_descriptor_ulimit +syn keyword ngxDirectiveThirdParty passenger_pre_start +syn keyword ngxDirectiveThirdParty passenger_set_header +syn keyword ngxDirectiveThirdParty passenger_max_request_queue_size +syn keyword ngxDirectiveThirdParty passenger_request_queue_overflow_status_code +syn keyword ngxDirectiveThirdParty passenger_sticky_sessions +syn keyword ngxDirectiveThirdParty passenger_sticky_sessions_cookie_name +syn keyword ngxDirectiveThirdParty passenger_abort_websockets_on_process_shutdown +syn keyword ngxDirectiveThirdParty passenger_ignore_client_abort +syn keyword ngxDirectiveThirdParty passenger_intercept_errors +syn keyword ngxDirectiveThirdParty passenger_pass_header +syn keyword ngxDirectiveThirdParty passenger_ignore_headers +syn keyword ngxDirectiveThirdParty passenger_headers_hash_bucket_size +syn keyword ngxDirectiveThirdParty passenger_headers_hash_max_size +syn keyword ngxDirectiveThirdParty passenger_buffer_response +syn keyword ngxDirectiveThirdParty passenger_response_buffer_high_watermark +syn keyword ngxDirectiveThirdParty passenger_buffer_size, passenger_buffers, passenger_busy_buffers_size +syn keyword ngxDirectiveThirdParty passenger_socket_backlog +syn keyword ngxDirectiveThirdParty passenger_log_level +syn keyword ngxDirectiveThirdParty passenger_log_file +syn keyword ngxDirectiveThirdParty passenger_file_descriptor_log_file +syn keyword ngxDirectiveThirdParty passenger_debugger +syn keyword ngxDirectiveThirdParty passenger_instance_registry_dir +syn keyword ngxDirectiveThirdParty passenger_data_buffer_dir +syn keyword ngxDirectiveThirdParty passenger_fly_with +syn keyword ngxDirectiveThirdParty union_station_support +syn keyword ngxDirectiveThirdParty union_station_key +syn keyword ngxDirectiveThirdParty union_station_proxy_address +syn keyword ngxDirectiveThirdParty union_station_filter +syn keyword ngxDirectiveThirdParty union_station_gateway_address +syn keyword ngxDirectiveThirdParty union_station_gateway_port +syn keyword ngxDirectiveThirdParty union_station_gateway_cert +syn keyword ngxDirectiveDeprecated rails_spawn_method +syn keyword ngxDirectiveDeprecated passenger_debug_log_file + +" Postgres Module +" Upstream module that allows nginx to communicate directly with PostgreSQL database. +syn keyword ngxDirectiveThirdParty postgres_server +syn keyword ngxDirectiveThirdParty postgres_keepalive +syn keyword ngxDirectiveThirdParty postgres_pass +syn keyword ngxDirectiveThirdParty postgres_query +syn keyword ngxDirectiveThirdParty postgres_rewrite +syn keyword ngxDirectiveThirdParty postgres_output +syn keyword ngxDirectiveThirdParty postgres_set +syn keyword ngxDirectiveThirdParty postgres_escape +syn keyword ngxDirectiveThirdParty postgres_connect_timeout +syn keyword ngxDirectiveThirdParty postgres_result_timeout + +" Pubcookie Module +" Authorizes users using encrypted cookies +syn keyword ngxDirectiveThirdParty pubcookie_inactive_expire +syn keyword ngxDirectiveThirdParty pubcookie_hard_expire +syn keyword ngxDirectiveThirdParty pubcookie_app_id +syn keyword ngxDirectiveThirdParty pubcookie_dir_depth +syn keyword ngxDirectiveThirdParty pubcookie_catenate_app_ids +syn keyword ngxDirectiveThirdParty pubcookie_app_srv_id +syn keyword ngxDirectiveThirdParty pubcookie_login +syn keyword ngxDirectiveThirdParty pubcookie_login_method +syn keyword ngxDirectiveThirdParty pubcookie_post +syn keyword ngxDirectiveThirdParty pubcookie_domain +syn keyword ngxDirectiveThirdParty pubcookie_granting_cert_file +syn keyword ngxDirectiveThirdParty pubcookie_session_key_file +syn keyword ngxDirectiveThirdParty pubcookie_session_cert_file +syn keyword ngxDirectiveThirdParty pubcookie_crypt_key_file +syn keyword ngxDirectiveThirdParty pubcookie_end_session +syn keyword ngxDirectiveThirdParty pubcookie_encryption +syn keyword ngxDirectiveThirdParty pubcookie_session_reauth +syn keyword ngxDirectiveThirdParty pubcookie_auth_type_names +syn keyword ngxDirectiveThirdParty pubcookie_no_prompt +syn keyword ngxDirectiveThirdParty pubcookie_on_demand +syn keyword ngxDirectiveThirdParty pubcookie_addl_request +syn keyword ngxDirectiveThirdParty pubcookie_no_obscure_cookies +syn keyword ngxDirectiveThirdParty pubcookie_no_clean_creds +syn keyword ngxDirectiveThirdParty pubcookie_egd_device +syn keyword ngxDirectiveThirdParty pubcookie_no_blank +syn keyword ngxDirectiveThirdParty pubcookie_super_debug +syn keyword ngxDirectiveThirdParty pubcookie_set_remote_user + +" Push Stream Module +" A pure stream http push technology for your Nginx setup +syn keyword ngxDirectiveThirdParty push_stream_channels_statistics +syn keyword ngxDirectiveThirdParty push_stream_publisher +syn keyword ngxDirectiveThirdParty push_stream_subscriber +syn keyword ngxDirectiveThirdParty push_stream_shared_memory_size +syn keyword ngxDirectiveThirdParty push_stream_channel_deleted_message_text +syn keyword ngxDirectiveThirdParty push_stream_channel_inactivity_time +syn keyword ngxDirectiveThirdParty push_stream_ping_message_text +syn keyword ngxDirectiveThirdParty push_stream_timeout_with_body +syn keyword ngxDirectiveThirdParty push_stream_message_ttl +syn keyword ngxDirectiveThirdParty push_stream_max_subscribers_per_channel +syn keyword ngxDirectiveThirdParty push_stream_max_messages_stored_per_channel +syn keyword ngxDirectiveThirdParty push_stream_max_channel_id_length +syn keyword ngxDirectiveThirdParty push_stream_max_number_of_channels +syn keyword ngxDirectiveThirdParty push_stream_max_number_of_wildcard_channels +syn keyword ngxDirectiveThirdParty push_stream_wildcard_channel_prefix +syn keyword ngxDirectiveThirdParty push_stream_events_channel_id +syn keyword ngxDirectiveThirdParty push_stream_channels_path +syn keyword ngxDirectiveThirdParty push_stream_store_messages +syn keyword ngxDirectiveThirdParty push_stream_channel_info_on_publish +syn keyword ngxDirectiveThirdParty push_stream_authorized_channels_only +syn keyword ngxDirectiveThirdParty push_stream_header_template_file +syn keyword ngxDirectiveThirdParty push_stream_header_template +syn keyword ngxDirectiveThirdParty push_stream_message_template +syn keyword ngxDirectiveThirdParty push_stream_footer_template +syn keyword ngxDirectiveThirdParty push_stream_wildcard_channel_max_qtd +syn keyword ngxDirectiveThirdParty push_stream_ping_message_interval +syn keyword ngxDirectiveThirdParty push_stream_subscriber_connection_ttl +syn keyword ngxDirectiveThirdParty push_stream_longpolling_connection_ttl +syn keyword ngxDirectiveThirdParty push_stream_websocket_allow_publish +syn keyword ngxDirectiveThirdParty push_stream_last_received_message_time +syn keyword ngxDirectiveThirdParty push_stream_last_received_message_tag +syn keyword ngxDirectiveThirdParty push_stream_last_event_id +syn keyword ngxDirectiveThirdParty push_stream_user_agent +syn keyword ngxDirectiveThirdParty push_stream_padding_by_user_agent +syn keyword ngxDirectiveThirdParty push_stream_allowed_origins +syn keyword ngxDirectiveThirdParty push_stream_allow_connections_to_events_channel + +" rDNS Module +" Make a reverse DNS (rDNS) lookup for incoming connection and provides simple access control of incoming hostname by allow/deny rules +syn keyword ngxDirectiveThirdParty rdns +syn keyword ngxDirectiveThirdParty rdns_allow +syn keyword ngxDirectiveThirdParty rdns_deny + +" RDS CSV Module +" Nginx output filter module to convert Resty-DBD-Streams (RDS) to Comma-Separated Values (CSV) +syn keyword ngxDirectiveThirdParty rds_csv +syn keyword ngxDirectiveThirdParty rds_csv_row_terminator +syn keyword ngxDirectiveThirdParty rds_csv_field_separator +syn keyword ngxDirectiveThirdParty rds_csv_field_name_header +syn keyword ngxDirectiveThirdParty rds_csv_content_type +syn keyword ngxDirectiveThirdParty rds_csv_buffer_size + +" RDS JSON Module +" An output filter that formats Resty DBD Streams generated by ngx_drizzle and others to JSON +syn keyword ngxDirectiveThirdParty rds_json +syn keyword ngxDirectiveThirdParty rds_json_buffer_size +syn keyword ngxDirectiveThirdParty rds_json_format +syn keyword ngxDirectiveThirdParty rds_json_root +syn keyword ngxDirectiveThirdParty rds_json_success_property +syn keyword ngxDirectiveThirdParty rds_json_user_property +syn keyword ngxDirectiveThirdParty rds_json_errcode_key +syn keyword ngxDirectiveThirdParty rds_json_errstr_key +syn keyword ngxDirectiveThirdParty rds_json_ret +syn keyword ngxDirectiveThirdParty rds_json_content_type + +" Redis Module +" Use this module to perform simple caching +syn keyword ngxDirectiveThirdParty redis_pass +syn keyword ngxDirectiveThirdParty redis_bind +syn keyword ngxDirectiveThirdParty redis_connect_timeout +syn keyword ngxDirectiveThirdParty redis_read_timeout +syn keyword ngxDirectiveThirdParty redis_send_timeout +syn keyword ngxDirectiveThirdParty redis_buffer_size +syn keyword ngxDirectiveThirdParty redis_next_upstream +syn keyword ngxDirectiveThirdParty redis_gzip_flag + +" Redis 2 Module +" Nginx upstream module for the Redis 2.0 protocol +syn keyword ngxDirectiveThirdParty redis2_query +syn keyword ngxDirectiveThirdParty redis2_raw_query +syn keyword ngxDirectiveThirdParty redis2_raw_queries +syn keyword ngxDirectiveThirdParty redis2_literal_raw_query +syn keyword ngxDirectiveThirdParty redis2_pass +syn keyword ngxDirectiveThirdParty redis2_connect_timeout +syn keyword ngxDirectiveThirdParty redis2_send_timeout +syn keyword ngxDirectiveThirdParty redis2_read_timeout +syn keyword ngxDirectiveThirdParty redis2_buffer_size +syn keyword ngxDirectiveThirdParty redis2_next_upstream + +" Replace Filter Module +" Streaming regular expression replacement in response bodies +syn keyword ngxDirectiveThirdParty replace_filter +syn keyword ngxDirectiveThirdParty replace_filter_types +syn keyword ngxDirectiveThirdParty replace_filter_max_buffered_size +syn keyword ngxDirectiveThirdParty replace_filter_last_modified +syn keyword ngxDirectiveThirdParty replace_filter_skip + +" Roboo Module +" HTTP Robot Mitigator + +" RRD Graph Module +" This module provides an HTTP interface to RRDtool's graphing facilities. +syn keyword ngxDirectiveThirdParty rrd_graph +syn keyword ngxDirectiveThirdParty rrd_graph_root + +" RTMP Module +" NGINX-based Media Streaming Server +syn keyword ngxDirectiveThirdParty rtmp +" syn keyword ngxDirectiveThirdParty server +" syn keyword ngxDirectiveThirdParty listen +syn keyword ngxDirectiveThirdParty application +" syn keyword ngxDirectiveThirdParty timeout +syn keyword ngxDirectiveThirdParty ping +syn keyword ngxDirectiveThirdParty ping_timeout +syn keyword ngxDirectiveThirdParty max_streams +syn keyword ngxDirectiveThirdParty ack_window +syn keyword ngxDirectiveThirdParty chunk_size +syn keyword ngxDirectiveThirdParty max_queue +syn keyword ngxDirectiveThirdParty max_message +syn keyword ngxDirectiveThirdParty out_queue +syn keyword ngxDirectiveThirdParty out_cork +" syn keyword ngxDirectiveThirdParty allow +" syn keyword ngxDirectiveThirdParty deny +syn keyword ngxDirectiveThirdParty exec_push +syn keyword ngxDirectiveThirdParty exec_pull +syn keyword ngxDirectiveThirdParty exec +syn keyword ngxDirectiveThirdParty exec_options +syn keyword ngxDirectiveThirdParty exec_static +syn keyword ngxDirectiveThirdParty exec_kill_signal +syn keyword ngxDirectiveThirdParty respawn +syn keyword ngxDirectiveThirdParty respawn_timeout +syn keyword ngxDirectiveThirdParty exec_publish +syn keyword ngxDirectiveThirdParty exec_play +syn keyword ngxDirectiveThirdParty exec_play_done +syn keyword ngxDirectiveThirdParty exec_publish_done +syn keyword ngxDirectiveThirdParty exec_record_done +syn keyword ngxDirectiveThirdParty live +syn keyword ngxDirectiveThirdParty meta +syn keyword ngxDirectiveThirdParty interleave +syn keyword ngxDirectiveThirdParty wait_key +syn keyword ngxDirectiveThirdParty wait_video +syn keyword ngxDirectiveThirdParty publish_notify +syn keyword ngxDirectiveThirdParty drop_idle_publisher +syn keyword ngxDirectiveThirdParty sync +syn keyword ngxDirectiveThirdParty play_restart +syn keyword ngxDirectiveThirdParty idle_streams +syn keyword ngxDirectiveThirdParty record +syn keyword ngxDirectiveThirdParty record_path +syn keyword ngxDirectiveThirdParty record_suffix +syn keyword ngxDirectiveThirdParty record_unique +syn keyword ngxDirectiveThirdParty record_append +syn keyword ngxDirectiveThirdParty record_lock +syn keyword ngxDirectiveThirdParty record_max_size +syn keyword ngxDirectiveThirdParty record_max_frames +syn keyword ngxDirectiveThirdParty record_interval +syn keyword ngxDirectiveThirdParty recorder +syn keyword ngxDirectiveThirdParty record_notify +syn keyword ngxDirectiveThirdParty play +syn keyword ngxDirectiveThirdParty play_temp_path +syn keyword ngxDirectiveThirdParty play_local_path +syn keyword ngxDirectiveThirdParty pull +syn keyword ngxDirectiveThirdParty push +syn keyword ngxDirectiveThirdParty push_reconnect +syn keyword ngxDirectiveThirdParty session_relay +syn keyword ngxDirectiveThirdParty on_connect +syn keyword ngxDirectiveThirdParty on_play +syn keyword ngxDirectiveThirdParty on_publish +syn keyword ngxDirectiveThirdParty on_done +syn keyword ngxDirectiveThirdParty on_play_done +syn keyword ngxDirectiveThirdParty on_publish_done +syn keyword ngxDirectiveThirdParty on_record_done +syn keyword ngxDirectiveThirdParty on_update +syn keyword ngxDirectiveThirdParty notify_update_timeout +syn keyword ngxDirectiveThirdParty notify_update_strict +syn keyword ngxDirectiveThirdParty notify_relay_redirect +syn keyword ngxDirectiveThirdParty notify_method +syn keyword ngxDirectiveThirdParty hls +syn keyword ngxDirectiveThirdParty hls_path +syn keyword ngxDirectiveThirdParty hls_fragment +syn keyword ngxDirectiveThirdParty hls_playlist_length +syn keyword ngxDirectiveThirdParty hls_sync +syn keyword ngxDirectiveThirdParty hls_continuous +syn keyword ngxDirectiveThirdParty hls_nested +syn keyword ngxDirectiveThirdParty hls_base_url +syn keyword ngxDirectiveThirdParty hls_cleanup +syn keyword ngxDirectiveThirdParty hls_fragment_naming +syn keyword ngxDirectiveThirdParty hls_fragment_slicing +syn keyword ngxDirectiveThirdParty hls_variant +syn keyword ngxDirectiveThirdParty hls_type +syn keyword ngxDirectiveThirdParty hls_keys +syn keyword ngxDirectiveThirdParty hls_key_path +syn keyword ngxDirectiveThirdParty hls_key_url +syn keyword ngxDirectiveThirdParty hls_fragments_per_key +syn keyword ngxDirectiveThirdParty dash +syn keyword ngxDirectiveThirdParty dash_path +syn keyword ngxDirectiveThirdParty dash_fragment +syn keyword ngxDirectiveThirdParty dash_playlist_length +syn keyword ngxDirectiveThirdParty dash_nested +syn keyword ngxDirectiveThirdParty dash_cleanup +" syn keyword ngxDirectiveThirdParty access_log +" syn keyword ngxDirectiveThirdParty log_format +syn keyword ngxDirectiveThirdParty max_connections +syn keyword ngxDirectiveThirdParty rtmp_stat +syn keyword ngxDirectiveThirdParty rtmp_stat_stylesheet +syn keyword ngxDirectiveThirdParty rtmp_auto_push +syn keyword ngxDirectiveThirdParty rtmp_auto_push_reconnect +syn keyword ngxDirectiveThirdParty rtmp_socket_dir +syn keyword ngxDirectiveThirdParty rtmp_control + +" RTMPT Module +" Module for nginx to proxy rtmp using http protocol +syn keyword ngxDirectiveThirdParty rtmpt_proxy_target +syn keyword ngxDirectiveThirdParty rtmpt_proxy_rtmp_timeout +syn keyword ngxDirectiveThirdParty rtmpt_proxy_http_timeout +syn keyword ngxDirectiveThirdParty rtmpt_proxy +syn keyword ngxDirectiveThirdParty rtmpt_proxy_stat +syn keyword ngxDirectiveThirdParty rtmpt_proxy_stylesheet + +" Syntactically Awesome Module +" Providing on-the-fly compiling of Sass files as an NGINX module. +syn keyword ngxDirectiveThirdParty sass_compile +syn keyword ngxDirectiveThirdParty sass_error_log +syn keyword ngxDirectiveThirdParty sass_include_path +syn keyword ngxDirectiveThirdParty sass_indent +syn keyword ngxDirectiveThirdParty sass_is_indented_syntax +syn keyword ngxDirectiveThirdParty sass_linefeed +syn keyword ngxDirectiveThirdParty sass_precision +syn keyword ngxDirectiveThirdParty sass_output_style +syn keyword ngxDirectiveThirdParty sass_source_comments +syn keyword ngxDirectiveThirdParty sass_source_map_embed + +" Secure Download Module +" Enables you to create links which are only valid until a certain datetime is reached +syn keyword ngxDirectiveThirdParty secure_download +syn keyword ngxDirectiveThirdParty secure_download_secret +syn keyword ngxDirectiveThirdParty secure_download_path_mode + +" Selective Cache Purge Module +" A module to purge cache by GLOB patterns. The supported patterns are the same as supported by Redis. +syn keyword ngxDirectiveThirdParty selective_cache_purge_redis_unix_socket +syn keyword ngxDirectiveThirdParty selective_cache_purge_redis_host +syn keyword ngxDirectiveThirdParty selective_cache_purge_redis_port +syn keyword ngxDirectiveThirdParty selective_cache_purge_redis_database +syn keyword ngxDirectiveThirdParty selective_cache_purge_query + +" Set cconv Module +" Cconv rewrite set commands +syn keyword ngxDirectiveThirdParty set_cconv_to_simp +syn keyword ngxDirectiveThirdParty set_cconv_to_trad +syn keyword ngxDirectiveThirdParty set_pinyin_to_normal + +" Set Hash Module +" Nginx module that allows the setting of variables to the value of a variety of hashes +syn keyword ngxDirectiveThirdParty set_md5 +syn keyword ngxDirectiveThirdParty set_md5_upper +syn keyword ngxDirectiveThirdParty set_murmur2 +syn keyword ngxDirectiveThirdParty set_murmur2_upper +syn keyword ngxDirectiveThirdParty set_sha1 +syn keyword ngxDirectiveThirdParty set_sha1_upper + +" Set Lang Module +" Provides a variety of ways for setting a variable denoting the langauge that content should be returned in. +syn keyword ngxDirectiveThirdParty set_lang +syn keyword ngxDirectiveThirdParty set_lang_method +syn keyword ngxDirectiveThirdParty lang_cookie +syn keyword ngxDirectiveThirdParty lang_get_var +syn keyword ngxDirectiveThirdParty lang_list +syn keyword ngxDirectiveThirdParty lang_post_var +syn keyword ngxDirectiveThirdParty lang_host +syn keyword ngxDirectiveThirdParty lang_referer + +" Set Misc Module +" Various set_xxx directives added to nginx's rewrite module +syn keyword ngxDirectiveThirdParty set_if_empty +syn keyword ngxDirectiveThirdParty set_quote_sql_str +syn keyword ngxDirectiveThirdParty set_quote_pgsql_str +syn keyword ngxDirectiveThirdParty set_quote_json_str +syn keyword ngxDirectiveThirdParty set_unescape_uri +syn keyword ngxDirectiveThirdParty set_escape_uri +syn keyword ngxDirectiveThirdParty set_hashed_upstream +syn keyword ngxDirectiveThirdParty set_encode_base32 +syn keyword ngxDirectiveThirdParty set_base32_padding +syn keyword ngxDirectiveThirdParty set_misc_base32_padding +syn keyword ngxDirectiveThirdParty set_base32_alphabet +syn keyword ngxDirectiveThirdParty set_decode_base32 +syn keyword ngxDirectiveThirdParty set_encode_base64 +syn keyword ngxDirectiveThirdParty set_decode_base64 +syn keyword ngxDirectiveThirdParty set_encode_hex +syn keyword ngxDirectiveThirdParty set_decode_hex +syn keyword ngxDirectiveThirdParty set_sha1 +syn keyword ngxDirectiveThirdParty set_md5 +syn keyword ngxDirectiveThirdParty set_hmac_sha1 +syn keyword ngxDirectiveThirdParty set_random +syn keyword ngxDirectiveThirdParty set_secure_random_alphanum +syn keyword ngxDirectiveThirdParty set_secure_random_lcalpha +syn keyword ngxDirectiveThirdParty set_rotate +syn keyword ngxDirectiveThirdParty set_local_today +syn keyword ngxDirectiveThirdParty set_formatted_gmt_time +syn keyword ngxDirectiveThirdParty set_formatted_local_time + +" SFlow Module +" A binary, random-sampling nginx module designed for: lightweight, centralized, continuous, real-time monitoring of very large and very busy web farms. +syn keyword ngxDirectiveThirdParty sflow + +" Shibboleth Module +" Shibboleth auth request module for nginx +syn keyword ngxDirectiveThirdParty shib_request +syn keyword ngxDirectiveThirdParty shib_request_set +syn keyword ngxDirectiveThirdParty shib_request_use_headers + +" Slice Module +" Nginx module for serving a file in slices (reverse byte-range) +" syn keyword ngxDirectiveThirdParty slice +syn keyword ngxDirectiveThirdParty slice_arg_begin +syn keyword ngxDirectiveThirdParty slice_arg_end +syn keyword ngxDirectiveThirdParty slice_header +syn keyword ngxDirectiveThirdParty slice_footer +syn keyword ngxDirectiveThirdParty slice_header_first +syn keyword ngxDirectiveThirdParty slice_footer_last + +" SlowFS Cache Module +" Module adding ability to cache static files. +syn keyword ngxDirectiveThirdParty slowfs_big_file_size +syn keyword ngxDirectiveThirdParty slowfs_cache +syn keyword ngxDirectiveThirdParty slowfs_cache_key +syn keyword ngxDirectiveThirdParty slowfs_cache_min_uses +syn keyword ngxDirectiveThirdParty slowfs_cache_path +syn keyword ngxDirectiveThirdParty slowfs_cache_purge +syn keyword ngxDirectiveThirdParty slowfs_cache_valid +syn keyword ngxDirectiveThirdParty slowfs_temp_path + +" Small Light Module +" Dynamic Image Transformation Module For nginx. +syn keyword ngxDirectiveThirdParty small_light +syn keyword ngxDirectiveThirdParty small_light_getparam_mode +syn keyword ngxDirectiveThirdParty small_light_material_dir +syn keyword ngxDirectiveThirdParty small_light_pattern_define +syn keyword ngxDirectiveThirdParty small_light_radius_max +syn keyword ngxDirectiveThirdParty small_light_sigma_max +syn keyword ngxDirectiveThirdParty small_light_imlib2_temp_dir +syn keyword ngxDirectiveThirdParty small_light_buffer + +" Sorted Querystring Filter Module +" Nginx module to expose querystring parameters sorted in a variable to be used on cache_key as example +syn keyword ngxDirectiveThirdParty sorted_querystring_filter_parameter + +" Sphinx2 Module +" Nginx upstream module for Sphinx 2.x +syn keyword ngxDirectiveThirdParty sphinx2_pass +syn keyword ngxDirectiveThirdParty sphinx2_bind +syn keyword ngxDirectiveThirdParty sphinx2_connect_timeout +syn keyword ngxDirectiveThirdParty sphinx2_send_timeout +syn keyword ngxDirectiveThirdParty sphinx2_buffer_size +syn keyword ngxDirectiveThirdParty sphinx2_read_timeout +syn keyword ngxDirectiveThirdParty sphinx2_next_upstream + +" HTTP SPNEGO auth Module +" This module implements adds SPNEGO support to nginx(http://nginx.org). It currently supports only Kerberos authentication via GSSAPI +syn keyword ngxDirectiveThirdParty auth_gss +syn keyword ngxDirectiveThirdParty auth_gss_keytab +syn keyword ngxDirectiveThirdParty auth_gss_realm +syn keyword ngxDirectiveThirdParty auth_gss_service_name +syn keyword ngxDirectiveThirdParty auth_gss_authorized_principal +syn keyword ngxDirectiveThirdParty auth_gss_allow_basic_fallback + +" SR Cache Module +" Transparent subrequest-based caching layout for arbitrary nginx locations +syn keyword ngxDirectiveThirdParty srcache_fetch +syn keyword ngxDirectiveThirdParty srcache_fetch_skip +syn keyword ngxDirectiveThirdParty srcache_store +syn keyword ngxDirectiveThirdParty srcache_store_max_size +syn keyword ngxDirectiveThirdParty srcache_store_skip +syn keyword ngxDirectiveThirdParty srcache_store_statuses +syn keyword ngxDirectiveThirdParty srcache_store_ranges +syn keyword ngxDirectiveThirdParty srcache_header_buffer_size +syn keyword ngxDirectiveThirdParty srcache_store_hide_header +syn keyword ngxDirectiveThirdParty srcache_store_pass_header +syn keyword ngxDirectiveThirdParty srcache_methods +syn keyword ngxDirectiveThirdParty srcache_ignore_content_encoding +syn keyword ngxDirectiveThirdParty srcache_request_cache_control +syn keyword ngxDirectiveThirdParty srcache_response_cache_control +syn keyword ngxDirectiveThirdParty srcache_store_no_store +syn keyword ngxDirectiveThirdParty srcache_store_no_cache +syn keyword ngxDirectiveThirdParty srcache_store_private +syn keyword ngxDirectiveThirdParty srcache_default_expire +syn keyword ngxDirectiveThirdParty srcache_max_expire + +" SSSD Info Module +" Retrives additional attributes from SSSD for current authentizated user +syn keyword ngxDirectiveThirdParty sssd_info +syn keyword ngxDirectiveThirdParty sssd_info_output_to +syn keyword ngxDirectiveThirdParty sssd_info_groups +syn keyword ngxDirectiveThirdParty sssd_info_group +syn keyword ngxDirectiveThirdParty sssd_info_group_separator +syn keyword ngxDirectiveThirdParty sssd_info_attributes +syn keyword ngxDirectiveThirdParty sssd_info_attribute +syn keyword ngxDirectiveThirdParty sssd_info_attribute_separator + +" Static Etags Module +" Generate etags for static content +syn keyword ngxDirectiveThirdParty FileETag + +" Statsd Module +" An nginx module for sending statistics to statsd +syn keyword ngxDirectiveThirdParty statsd_server +syn keyword ngxDirectiveThirdParty statsd_sample_rate +syn keyword ngxDirectiveThirdParty statsd_count +syn keyword ngxDirectiveThirdParty statsd_timing + +" Sticky Module +" Add a sticky cookie to be always forwarded to the same upstream server +" syn keyword ngxDirectiveThirdParty sticky + +" Stream Echo Module +" TCP/stream echo module for NGINX (a port of ngx_http_echo_module) +syn keyword ngxDirectiveThirdParty echo +syn keyword ngxDirectiveThirdParty echo_duplicate +syn keyword ngxDirectiveThirdParty echo_flush_wait +syn keyword ngxDirectiveThirdParty echo_sleep +syn keyword ngxDirectiveThirdParty echo_send_timeout +syn keyword ngxDirectiveThirdParty echo_read_bytes +syn keyword ngxDirectiveThirdParty echo_read_line +syn keyword ngxDirectiveThirdParty echo_request_data +syn keyword ngxDirectiveThirdParty echo_discard_request +syn keyword ngxDirectiveThirdParty echo_read_buffer_size +syn keyword ngxDirectiveThirdParty echo_read_timeout +syn keyword ngxDirectiveThirdParty echo_client_error_log_level +syn keyword ngxDirectiveThirdParty echo_lingering_close +syn keyword ngxDirectiveThirdParty echo_lingering_time +syn keyword ngxDirectiveThirdParty echo_lingering_timeout + +" Stream Lua Module +" Embed the power of Lua into Nginx stream/TCP Servers. +syn keyword ngxDirectiveThirdParty lua_resolver +syn keyword ngxDirectiveThirdParty lua_resolver_timeout +syn keyword ngxDirectiveThirdParty lua_lingering_close +syn keyword ngxDirectiveThirdParty lua_lingering_time +syn keyword ngxDirectiveThirdParty lua_lingering_timeout + +" Stream Upsync Module +" Sync upstreams from consul or others, dynamiclly modify backend-servers attribute(weight, max_fails,...), needn't reload nginx. +syn keyword ngxDirectiveThirdParty upsync +syn keyword ngxDirectiveThirdParty upsync_dump_path +syn keyword ngxDirectiveThirdParty upsync_lb +syn keyword ngxDirectiveThirdParty upsync_show + +" Strip Module +" Whitespace remover. +syn keyword ngxDirectiveThirdParty strip + +" Subrange Module +" Split one big HTTP/Range request to multiple subrange requesets +syn keyword ngxDirectiveThirdParty subrange + +" Substitutions Module +" A filter module which can do both regular expression and fixed string substitutions on response bodies. +syn keyword ngxDirectiveThirdParty subs_filter +syn keyword ngxDirectiveThirdParty subs_filter_types + +" Summarizer Module +" Upstream nginx module to get summaries of documents using the summarizer daemon service +syn keyword ngxDirectiveThirdParty smrzr_filename +syn keyword ngxDirectiveThirdParty smrzr_ratio + +" Supervisord Module +" Module providing nginx with API to communicate with supervisord and manage (start/stop) backends on-demand. +syn keyword ngxDirectiveThirdParty supervisord +syn keyword ngxDirectiveThirdParty supervisord_inherit_backend_status +syn keyword ngxDirectiveThirdParty supervisord_name +syn keyword ngxDirectiveThirdParty supervisord_start +syn keyword ngxDirectiveThirdParty supervisord_stop + +" Tarantool Upstream Module +" Tarantool NginX upstream module (REST, JSON API, websockets, load balancing) +syn keyword ngxDirectiveThirdParty tnt_pass +syn keyword ngxDirectiveThirdParty tnt_http_methods +syn keyword ngxDirectiveThirdParty tnt_http_rest_methods +syn keyword ngxDirectiveThirdParty tnt_pass_http_request +syn keyword ngxDirectiveThirdParty tnt_pass_http_request_buffer_size +syn keyword ngxDirectiveThirdParty tnt_method +syn keyword ngxDirectiveThirdParty tnt_http_allowed_methods - experemental +syn keyword ngxDirectiveThirdParty tnt_send_timeout +syn keyword ngxDirectiveThirdParty tnt_read_timeout +syn keyword ngxDirectiveThirdParty tnt_buffer_size +syn keyword ngxDirectiveThirdParty tnt_next_upstream +syn keyword ngxDirectiveThirdParty tnt_connect_timeout +syn keyword ngxDirectiveThirdParty tnt_next_upstream +syn keyword ngxDirectiveThirdParty tnt_next_upstream_tries +syn keyword ngxDirectiveThirdParty tnt_next_upstream_timeout + +" TCP Proxy Module +" Add the feature of tcp proxy with nginx, with health check and status monitor +syn keyword ngxDirectiveBlock tcp +" syn keyword ngxDirectiveThirdParty server +" syn keyword ngxDirectiveThirdParty listen +" syn keyword ngxDirectiveThirdParty allow +" syn keyword ngxDirectiveThirdParty deny +" syn keyword ngxDirectiveThirdParty so_keepalive +" syn keyword ngxDirectiveThirdParty tcp_nodelay +" syn keyword ngxDirectiveThirdParty timeout +" syn keyword ngxDirectiveThirdParty server_name +" syn keyword ngxDirectiveThirdParty resolver +" syn keyword ngxDirectiveThirdParty resolver_timeout +" syn keyword ngxDirectiveThirdParty upstream +syn keyword ngxDirectiveThirdParty check +syn keyword ngxDirectiveThirdParty check_http_send +syn keyword ngxDirectiveThirdParty check_http_expect_alive +syn keyword ngxDirectiveThirdParty check_smtp_send +syn keyword ngxDirectiveThirdParty check_smtp_expect_alive +syn keyword ngxDirectiveThirdParty check_shm_size +syn keyword ngxDirectiveThirdParty check_status +" syn keyword ngxDirectiveThirdParty ip_hash +" syn keyword ngxDirectiveThirdParty proxy_pass +" syn keyword ngxDirectiveThirdParty proxy_buffer +" syn keyword ngxDirectiveThirdParty proxy_connect_timeout +" syn keyword ngxDirectiveThirdParty proxy_read_timeout +syn keyword ngxDirectiveThirdParty proxy_write_timeout + +" Testcookie Module +" NGINX module for L7 DDoS attack mitigation +syn keyword ngxDirectiveThirdParty testcookie +syn keyword ngxDirectiveThirdParty testcookie_name +syn keyword ngxDirectiveThirdParty testcookie_domain +syn keyword ngxDirectiveThirdParty testcookie_expires +syn keyword ngxDirectiveThirdParty testcookie_path +syn keyword ngxDirectiveThirdParty testcookie_secret +syn keyword ngxDirectiveThirdParty testcookie_session +syn keyword ngxDirectiveThirdParty testcookie_arg +syn keyword ngxDirectiveThirdParty testcookie_max_attempts +syn keyword ngxDirectiveThirdParty testcookie_p3p +syn keyword ngxDirectiveThirdParty testcookie_fallback +syn keyword ngxDirectiveThirdParty testcookie_whitelist +syn keyword ngxDirectiveThirdParty testcookie_pass +syn keyword ngxDirectiveThirdParty testcookie_redirect_via_refresh +syn keyword ngxDirectiveThirdParty testcookie_refresh_template +syn keyword ngxDirectiveThirdParty testcookie_refresh_status +syn keyword ngxDirectiveThirdParty testcookie_deny_keepalive +syn keyword ngxDirectiveThirdParty testcookie_get_only +syn keyword ngxDirectiveThirdParty testcookie_https_location +syn keyword ngxDirectiveThirdParty testcookie_refresh_encrypt_cookie +syn keyword ngxDirectiveThirdParty testcookie_refresh_encrypt_cookie_key +syn keyword ngxDirectiveThirdParty testcookie_refresh_encrypt_iv +syn keyword ngxDirectiveThirdParty testcookie_internal +syn keyword ngxDirectiveThirdParty testcookie_httponly_flag +syn keyword ngxDirectiveThirdParty testcookie_secure_flag + +" Types Filter Module +" Change the `Content-Type` output header depending on an extension variable according to a condition specified in the 'if' clause. +syn keyword ngxDirectiveThirdParty types_filter +syn keyword ngxDirectiveThirdParty types_filter_use_default + +" Unzip Module +" Enabling fetching of files that are stored in zipped archives. +syn keyword ngxDirectiveThirdParty file_in_unzip_archivefile +syn keyword ngxDirectiveThirdParty file_in_unzip_extract +syn keyword ngxDirectiveThirdParty file_in_unzip + +" Upload Progress Module +" An upload progress system, that monitors RFC1867 POST upload as they are transmitted to upstream servers +syn keyword ngxDirectiveThirdParty upload_progress +syn keyword ngxDirectiveThirdParty track_uploads +syn keyword ngxDirectiveThirdParty report_uploads +syn keyword ngxDirectiveThirdParty upload_progress_content_type +syn keyword ngxDirectiveThirdParty upload_progress_header +syn keyword ngxDirectiveThirdParty upload_progress_jsonp_parameter +syn keyword ngxDirectiveThirdParty upload_progress_json_output +syn keyword ngxDirectiveThirdParty upload_progress_jsonp_output +syn keyword ngxDirectiveThirdParty upload_progress_template + +" Upload Module +" Parses request body storing all files being uploaded to a directory specified by upload_store directive +syn keyword ngxDirectiveThirdParty upload_pass +syn keyword ngxDirectiveThirdParty upload_resumable +syn keyword ngxDirectiveThirdParty upload_store +syn keyword ngxDirectiveThirdParty upload_state_store +syn keyword ngxDirectiveThirdParty upload_store_access +syn keyword ngxDirectiveThirdParty upload_set_form_field +syn keyword ngxDirectiveThirdParty upload_aggregate_form_field +syn keyword ngxDirectiveThirdParty upload_pass_form_field +syn keyword ngxDirectiveThirdParty upload_cleanup +syn keyword ngxDirectiveThirdParty upload_buffer_size +syn keyword ngxDirectiveThirdParty upload_max_part_header_len +syn keyword ngxDirectiveThirdParty upload_max_file_size +syn keyword ngxDirectiveThirdParty upload_limit_rate +syn keyword ngxDirectiveThirdParty upload_max_output_body_len +syn keyword ngxDirectiveThirdParty upload_tame_arrays +syn keyword ngxDirectiveThirdParty upload_pass_args + +" Upstream Fair Module +" The fair load balancer module for nginx http://nginx.localdomain.pl +syn keyword ngxDirectiveThirdParty fair +syn keyword ngxDirectiveThirdParty upstream_fair_shm_size + +" Upstream Hash Module (DEPRECATED) +" Provides simple upstream load distribution by hashing a configurable variable. +" syn keyword ngxDirectiveDeprecated hash +syn keyword ngxDirectiveDeprecated hash_again + +" Upstream Domain Resolve Module +" A load-balancer that resolves an upstream domain name asynchronously. +syn keyword ngxDirectiveThirdParty jdomain + +" Upsync Module +" Sync upstreams from consul or others, dynamiclly modify backend-servers attribute(weight, max_fails,...), needn't reload nginx +syn keyword ngxDirectiveThirdParty upsync +syn keyword ngxDirectiveThirdParty upsync_dump_path +syn keyword ngxDirectiveThirdParty upsync_lb +syn keyword ngxDirectiveThirdParty upstream_show + +" URL Module +" Nginx url encoding converting module +syn keyword ngxDirectiveThirdParty url_encoding_convert +syn keyword ngxDirectiveThirdParty url_encoding_convert_from +syn keyword ngxDirectiveThirdParty url_encoding_convert_to + +" User Agent Module +" Match browsers and crawlers +syn keyword ngxDirectiveThirdParty user_agent + +" Upstrema Ketama Chash Module +" Nginx load-balancer module implementing ketama consistent hashing. +syn keyword ngxDirectiveThirdParty ketama_chash + +" Video Thumbextractor Module +" Extract thumbs from a video file +syn keyword ngxDirectiveThirdParty video_thumbextractor +syn keyword ngxDirectiveThirdParty video_thumbextractor_video_filename +syn keyword ngxDirectiveThirdParty video_thumbextractor_video_second +syn keyword ngxDirectiveThirdParty video_thumbextractor_image_width +syn keyword ngxDirectiveThirdParty video_thumbextractor_image_height +syn keyword ngxDirectiveThirdParty video_thumbextractor_only_keyframe +syn keyword ngxDirectiveThirdParty video_thumbextractor_next_time +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_rows +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_cols +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_max_rows +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_max_cols +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_sample_interval +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_color +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_margin +syn keyword ngxDirectiveThirdParty video_thumbextractor_tile_padding +syn keyword ngxDirectiveThirdParty video_thumbextractor_threads +syn keyword ngxDirectiveThirdParty video_thumbextractor_processes_per_worker + +" Eval Module +" Module for nginx web server evaluates response of proxy or memcached module into variables. +syn keyword ngxDirectiveThirdParty eval +syn keyword ngxDirectiveThirdParty eval_escalate +syn keyword ngxDirectiveThirdParty eval_override_content_type + +" VTS Module +" Nginx virtual host traffic status module +syn keyword ngxDirectiveThirdParty vhost_traffic_status +syn keyword ngxDirectiveThirdParty vhost_traffic_status_zone +syn keyword ngxDirectiveThirdParty vhost_traffic_status_display +syn keyword ngxDirectiveThirdParty vhost_traffic_status_display_format +syn keyword ngxDirectiveThirdParty vhost_traffic_status_display_jsonp +syn keyword ngxDirectiveThirdParty vhost_traffic_status_filter +syn keyword ngxDirectiveThirdParty vhost_traffic_status_filter_by_host +syn keyword ngxDirectiveThirdParty vhost_traffic_status_filter_by_set_key +syn keyword ngxDirectiveThirdParty vhost_traffic_status_filter_check_duplicate +syn keyword ngxDirectiveThirdParty vhost_traffic_status_limit +syn keyword ngxDirectiveThirdParty vhost_traffic_status_limit_traffic +syn keyword ngxDirectiveThirdParty vhost_traffic_status_limit_traffic_by_set_key +syn keyword ngxDirectiveThirdParty vhost_traffic_status_limit_check_duplicate + +" XSS Module +" Native support for cross-site scripting (XSS) in an nginx. +syn keyword ngxDirectiveThirdParty xss_get +syn keyword ngxDirectiveThirdParty xss_callback_arg +syn keyword ngxDirectiveThirdParty xss_override_status +syn keyword ngxDirectiveThirdParty xss_check_status +syn keyword ngxDirectiveThirdParty xss_input_types + +" ZIP Module +" ZIP archiver for nginx + +" Contained LUA blocks for embedded syntax highlighting +syn keyword ngxThirdPartyLuaBlock balancer_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock init_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock init_worker_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock set_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock content_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock rewrite_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock access_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock header_filter_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock body_filter_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock log_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock ssl_certificate_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock ssl_session_fetch_by_lua_block contained +syn keyword ngxThirdPartyLuaBlock ssl_session_store_by_lua_block contained + + +" Nested syntax in ERB templating statements +" Subtype needs to be set to '', otherwise recursive errors occur when opening *.nginx files +let b:eruby_subtype = '' +unlet b:current_syntax +syn include @ERB syntax/eruby.vim +syn region ngxTemplate start=+<%[^\=]+ end=+%>+ oneline contains=@ERB +syn region ngxTemplateVar start=+<%=+ end=+%>+ oneline +let b:current_syntax = "nginx" + +" Nested syntax in Jinja templating statements +" This dependend on https://github.com/lepture/vim-jinja +unlet b:current_syntax +try + syn include @JINJA syntax/jinja.vim + syn region ngxTemplate start=+{%+ end=+%}+ oneline contains=@JINJA + syn region ngxTemplateVar start=+{{+ end=+}}+ oneline +catch +endtry +let b:current_syntax = "nginx" + +" Enable nested LUA syntax highlighting +unlet b:current_syntax +syn include @LUA syntax/lua.vim +syn region ngxLua start=+^\s*\w\+_by_lua_block\s*{+ end=+}+me=s-1 contains=ngxBlock,@LUA +let b:current_syntax = "nginx" + + +" Highlight +hi link ngxComment Comment +hi link ngxVariable Identifier +hi link ngxVariableBlock Identifier +hi link ngxVariableString PreProc +hi link ngxString String +hi link ngxIPaddr Delimiter +hi link ngxBoolean Boolean +hi link ngxInteger Number +hi link ngxDirectiveBlock Statement +hi link ngxDirectiveImportant Type +hi link ngxDirectiveControl Keyword +hi link ngxDirectiveDeprecated Error +hi link ngxDirective Function +hi link ngxDirectiveThirdParty Function +hi link ngxListenOptions PreProc +hi link ngxUpstreamServerOptions PreProc +hi link ngxProxyNextUpstreamOptions PreProc +hi link ngxMailProtocol Keyword +hi link ngxSSLProtocol PreProc +hi link ngxSSLProtocolDeprecated Error +hi link ngxStickyOptions ngxDirective +hi link ngxCookieOptions PreProc +hi link ngxTemplateVar Identifier + +hi link ngxSSLSessionTicketsOff ngxBoolean +hi link ngxSSLSessionTicketsOn Error +hi link ngxSSLPreferServerCiphersOn ngxBoolean +hi link ngxSSLPreferServerCiphersOff Error +hi link ngxGzipOff ngxBoolean +hi link ngxGzipOn Error +hi link ngxSSLCipherInsecure Error + +hi link ngxThirdPartyLuaBlock Function diff --git a/sources_non_forked/open_file_under_cursor.vim/plugin/open_file_under_cursor.vim b/sources_non_forked/open_file_under_cursor.vim/plugin/open_file_under_cursor.vim new file mode 100644 index 00000000..107babc4 --- /dev/null +++ b/sources_non_forked/open_file_under_cursor.vim/plugin/open_file_under_cursor.vim @@ -0,0 +1,41 @@ +" ----- Emulate 'gf' but recognize :line format ----- +function! GotoFile(w) + let curword = expand("") + if (strlen(curword) == 0) + return + endif + let matchstart = match(curword, ':\d\+$') + if matchstart > 0 + let pos = '+' . strpart(curword, matchstart+1) + let fname = strpart(curword, 0, matchstart) + else + let pos = "" + let fname = curword + endif + + " check exists file. + if filereadable(fname) + let fullname = fname + else + " try find file with prefix by working directory + let fullname = getcwd() . '/' . fname + if ! filereadable(fullname) + " the last try, using current directory based on file opened. + let fullname = expand('%:h') . '/' . fname + endif + endif + + " Open new window if requested + if a:w == "new" + new + endif + " Use 'find' so path is searched like 'gf' would + execute 'find ' . pos . ' ' . fname +endfunction + +set isfname+=: " include colon in filenames + +" Override vim commands 'gf', '^Wf', '^W^F' +nnoremap gf :call GotoFile("") +nnoremap f :call GotoFile("new") +nnoremap :call GotoFile("new") diff --git a/sources_non_forked/rust.vim/.github/workflows/ci.yml b/sources_non_forked/rust.vim/.github/workflows/ci.yml new file mode 100644 index 00000000..bd6e2265 --- /dev/null +++ b/sources_non_forked/rust.vim/.github/workflows/ci.yml @@ -0,0 +1,9 @@ +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run tests + run: cd test && ./run-tests + shell: bash diff --git a/sources_non_forked/rust.vim/.gitignore b/sources_non_forked/rust.vim/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/rust.vim/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/rust.vim/.vintrc.yml b/sources_non_forked/rust.vim/.vintrc.yml new file mode 100644 index 00000000..0914f1b5 --- /dev/null +++ b/sources_non_forked/rust.vim/.vintrc.yml @@ -0,0 +1,10 @@ +cmdargs: + # Checking more strictly + severity: style_problem + +policies: + # Disable a violation + ProhibitUnnecessaryDoubleQuote: + enabled: false + ProhibitImplicitScopeVariable: + enabled: false diff --git a/sources_non_forked/rust.vim/ISSUE_TEMPLATE.md b/sources_non_forked/rust.vim/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..cf8c71bb --- /dev/null +++ b/sources_non_forked/rust.vim/ISSUE_TEMPLATE.md @@ -0,0 +1,28 @@ + + +* rust.vim version: + +Steps to reproduce: + + +_?_ + +Expected vs. actual behavior: + +_?_ + +Paste debugging info from the Rust Vim plugin via _one_ of the following +commands: `:RustInfo`, `:RustInfoToClipboard`, or `:RustInfoToFile `. + + +_?_ diff --git a/sources_non_forked/rust.vim/LICENSE-APACHE b/sources_non_forked/rust.vim/LICENSE-APACHE new file mode 100644 index 00000000..16fe87b0 --- /dev/null +++ b/sources_non_forked/rust.vim/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/sources_non_forked/rust.vim/LICENSE-MIT b/sources_non_forked/rust.vim/LICENSE-MIT new file mode 100644 index 00000000..e69282e3 --- /dev/null +++ b/sources_non_forked/rust.vim/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2015 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/sources_non_forked/rust.vim/README.md b/sources_non_forked/rust.vim/README.md new file mode 100644 index 00000000..c1d428b8 --- /dev/null +++ b/sources_non_forked/rust.vim/README.md @@ -0,0 +1,135 @@ +# rust.vim + +## Description + +This is a Vim plugin that provides [Rust][r] file detection, syntax highlighting, formatting, +[Syntastic][syn] integration, and more. It requires Vim 8 or higher for full functionality. +Some things may not work on earlier versions. + +## Installation + +For activating the full functionality, this plugin requires either the plugin +manager or the `.vimrc` to have the following: + +```vim +syntax enable +filetype plugin indent on +``` + +Most plugin managers don't do this automatically, so these statements are +usually added by users in their `vimrc` _right after_ the plugin manager load +section. + +### [Vim8 packages][vim8pack] + +```sh +git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim +``` + +### [Vundle][v] + +```vim +Plugin 'rust-lang/rust.vim' +``` + +### [Pathogen][p] + +```sh +git clone --depth=1 https://github.com/rust-lang/rust.vim.git ~/.vim/bundle/rust.vim +``` + +### [vim-plug][vp] + +```vim +Plug 'rust-lang/rust.vim' +``` + +### [dein.vim][d] + +```vim +call dein#add('rust-lang/rust.vim') +``` + +### [NeoBundle][nb] + +```vim +NeoBundle 'rust-lang/rust.vim' +``` + +## Features + +### Error checking with [Syntastic][syn] + +`rust.vim` automatically registers `cargo` as a syntax checker with +[Syntastic][syn], if nothing else is specified. See `:help rust-syntastic` +for more details. + +### Source browsing with [Tagbar][tgbr] + +The installation of Tagbar along with [Universal Ctags][uctags] is recommended +for a good Tagbar experience. For other kinds of setups, `rust.vim` tries to +configure Tagbar to some degree. + +### Formatting with [rustfmt][rfmt] + +The `:RustFmt` command will format your code with +[rustfmt][rfmt] if installed. `rustfmt` can be installed +via `rustup component add rustfmt`. + +Placing `let g:rustfmt_autosave = 1` in your `~/.vimrc` will +enable automatic running of `:RustFmt` when you save a buffer. + +Do `:help :RustFmt` for further formatting help and customization +options. + +### [Playpen][pp] integration + +*Note:* This feature requires [webapi-vim][wav] to be installed. + +The `:RustPlay` command will send the current selection, or if +nothing is selected the current buffer, to the [Rust playpen][pp]. + +If you set g:rust_clip_command RustPlay will copy the url to the clipboard. + +- Mac: + + let g:rust_clip_command = 'pbcopy' + +- Linux: + + let g:rust_clip_command = 'xclip -selection clipboard' + +### Running a test under cursor + +In a Cargo project, the `:RustTest` command will run the test that is under the cursor. +This is useful when your project is big and running all of the tests takes a long time. + +## Help + +Further help can be found in the documentation with `:Helptags` then `:help rust`. + +Detailed help can be found in the documentation with `:help rust`. +Helptags (`:help helptags`) need to be generated for this plugin +in order to navigate the help. Most plugin managers will do this +automatically, but check their documentation if that is not the case. + +## License + +Like Rust, rust.vim is primarily distributed under the terms of both the MIT +license and the Apache License (Version 2.0). See LICENSE-APACHE and +LICENSE-MIT for details. + +[r]: https://www.rust-lang.org +[v]: https://github.com/gmarik/vundle +[vqs]: https://github.com/gmarik/vundle#quick-start +[p]: https://github.com/tpope/vim-pathogen +[nb]: https://github.com/Shougo/neobundle.vim +[vp]: https://github.com/junegunn/vim-plug +[d]: https://github.com/Shougo/dein.vim +[rfmt]: https://github.com/rust-lang-nursery/rustfmt +[syn]: https://github.com/scrooloose/syntastic +[tgbr]: https://github.com/majutsushi/tagbar +[uctags]: https://ctags.io +[wav]: https://github.com/mattn/webapi-vim +[pp]: https://play.rust-lang.org/ +[vim8pack]: http://vimhelp.appspot.com/repeat.txt.html#packages diff --git a/sources_non_forked/rust.vim/after/syntax/rust.vim b/sources_non_forked/rust.vim/after/syntax/rust.vim new file mode 100644 index 00000000..62bfc652 --- /dev/null +++ b/sources_non_forked/rust.vim/after/syntax/rust.vim @@ -0,0 +1,41 @@ +scriptencoding utf-8 + +if !get(g:, 'rust_conceal', 0) || !has('conceal') || &encoding !=# 'utf-8' + finish +endif + +" For those who don't want to see `::`... +if get(g:, 'rust_conceal_mod_path', 0) + syn match rustNiceOperator "::" conceal cchar=ㆍ +endif + +syn match rustRightArrowHead contained ">" conceal cchar=  +syn match rustRightArrowTail contained "-" conceal cchar=⟶ +syn match rustNiceOperator "->" contains=rustRightArrowHead,rustRightArrowTail + +syn match rustFatRightArrowHead contained ">" conceal cchar=  +syn match rustFatRightArrowTail contained "=" conceal cchar=⟹ +syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrowTail + +syn match rustNiceOperator /\<\@!_\(_*\>\)\@=/ conceal cchar=′ + +" For those who don't want to see `pub`... +if get(g:, 'rust_conceal_pub', 0) + syn match rustPublicSigil contained "pu" conceal cchar=* + syn match rustPublicRest contained "b" conceal cchar=  + syn match rustNiceOperator "pub " contains=rustPublicSigil,rustPublicRest +endif + +hi link rustNiceOperator Operator + +if !get(g:, 'rust_conceal_mod_path', 0) + hi! link Conceal Operator + + augroup rust.vim.after + autocmd! + " And keep it after a colorscheme change + autocmd ColorScheme hi! link Conceal Operator + augroup END +endif + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/cargo.vim b/sources_non_forked/rust.vim/autoload/cargo.vim new file mode 100644 index 00000000..a95a57f9 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/cargo.vim @@ -0,0 +1,147 @@ +function! cargo#Load() + " Utility call to get this script loaded, for debugging +endfunction + +function! cargo#cmd(args) abort + " Trim trailing spaces. This is necessary since :terminal command parses + " trailing spaces as an empty argument. + let args = substitute(a:args, '\s\+$', '', '') + if exists('g:cargo_shell_command_runner') + let cmd = g:cargo_shell_command_runner + elseif has('terminal') + let cmd = 'terminal' + elseif has('nvim') + let cmd = 'noautocmd new | terminal' + else + let cmd = '!' + endif + execute cmd 'cargo' args +endfunction + +function! s:nearest_cargo(...) abort + " If the second argument is not specified, the first argument determines + " whether we will start from the current directory or the directory of the + " current buffer, otherwise, we start with the provided path on the + " second argument. + + let l:is_getcwd = get(a:, 1, 0) + if l:is_getcwd + let l:starting_path = get(a:, 2, getcwd()) + else + let l:starting_path = get(a:, 2, expand('%:p:h')) + endif + + return findfile('Cargo.toml', l:starting_path . ';') +endfunction + +function! cargo#nearestCargo(is_getcwd) abort + return s:nearest_cargo(a:is_getcwd) +endfunction + +function! cargo#nearestWorkspaceCargo(is_getcwd) abort + let l:nearest = s:nearest_cargo(a:is_getcwd) + while l:nearest !=# '' + for l:line in readfile(l:nearest, '', 0x100) + if l:line =~# '\V[workspace]' + return l:nearest + endif + endfor + let l:next = fnamemodify(l:nearest, ':p:h:h') + let l:nearest = s:nearest_cargo(0, l:next) + endwhile + return '' +endfunction + +function! cargo#nearestRootCargo(is_getcwd) abort + " Try to find a workspace Cargo.toml, and if not found, take the nearest + " regular Cargo.toml + let l:workspace_cargo = cargo#nearestWorkspaceCargo(a:is_getcwd) + if l:workspace_cargo !=# '' + return l:workspace_cargo + endif + return s:nearest_cargo(a:is_getcwd) +endfunction + + +function! cargo#build(args) + call cargo#cmd("build " . a:args) +endfunction + +function! cargo#check(args) + call cargo#cmd("check " . a:args) +endfunction + +function! cargo#clean(args) + call cargo#cmd("clean " . a:args) +endfunction + +function! cargo#doc(args) + call cargo#cmd("doc " . a:args) +endfunction + +function! cargo#new(args) + call cargo#cmd("new " . a:args) + cd `=a:args` +endfunction + +function! cargo#init(args) + call cargo#cmd("init " . a:args) +endfunction + +function! cargo#run(args) + call cargo#cmd("run " . a:args) +endfunction + +function! cargo#test(args) + call cargo#cmd("test " . a:args) +endfunction + +function! cargo#bench(args) + call cargo#cmd("bench " . a:args) +endfunction + +function! cargo#update(args) + call cargo#cmd("update " . a:args) +endfunction + +function! cargo#search(args) + call cargo#cmd("search " . a:args) +endfunction + +function! cargo#publish(args) + call cargo#cmd("publish " . a:args) +endfunction + +function! cargo#install(args) + call cargo#cmd("install " . a:args) +endfunction + +function! cargo#runtarget(args) + let l:filename = expand('%:p') + let l:read_manifest = system('cargo read-manifest') + let l:metadata = json_decode(l:read_manifest) + let l:targets = get(l:metadata, 'targets', []) + let l:did_run = 0 + for l:target in l:targets + let l:src_path = get(l:target, 'src_path', '') + let l:kinds = get(l:target, 'kind', []) + let l:name = get(l:target, 'name', '') + if l:src_path == l:filename + if index(l:kinds, 'example') != -1 + let l:did_run = 1 + call cargo#run("--example " . shellescape(l:name) . " " . a:args) + return + elseif index(l:kinds, 'bin') != -1 + let l:did_run = 1 + call cargo#run("--bin " . shellescape(l:name) . " " . a:args) + return + endif + endif + endfor + if l:did_run != 1 + call cargo#run(a:args) + return + endif +endfunction + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/cargo/quickfix.vim b/sources_non_forked/rust.vim/autoload/cargo/quickfix.vim new file mode 100644 index 00000000..fbeb42f7 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/cargo/quickfix.vim @@ -0,0 +1,27 @@ +function! cargo#quickfix#CmdPre() abort + if &filetype ==# 'rust' && get(b:, 'current_compiler', '') ==# 'cargo' && + \ &makeprg =~ '\V\^cargo\ \.\*' + " Preserve the current directory, and 'lcd' to the nearest Cargo file. + let b:rust_compiler_cargo_qf_has_lcd = haslocaldir() + let b:rust_compiler_cargo_qf_prev_cd = getcwd() + let b:rust_compiler_cargo_qf_prev_cd_saved = 1 + let l:nearest = fnamemodify(cargo#nearestRootCargo(0), ':h') + execute 'lchdir! '.l:nearest + else + let b:rust_compiler_cargo_qf_prev_cd_saved = 0 + endif +endfunction + +function! cargo#quickfix#CmdPost() abort + if exists("b:rust_compiler_cargo_qf_prev_cd_saved") && b:rust_compiler_cargo_qf_prev_cd_saved + " Restore the current directory. + if b:rust_compiler_cargo_qf_has_lcd + execute 'lchdir! '.b:rust_compiler_cargo_qf_prev_cd + else + execute 'chdir! '.b:rust_compiler_cargo_qf_prev_cd + endif + let b:rust_compiler_cargo_qf_prev_cd_saved = 0 + endif +endfunction + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/rust.vim b/sources_non_forked/rust.vim/autoload/rust.vim new file mode 100644 index 00000000..025949c6 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rust.vim @@ -0,0 +1,570 @@ +" Description: Helper functions for Rust commands/mappings +" Last Modified: May 27, 2014 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +function! rust#Load() + " Utility call to get this script loaded, for debugging +endfunction + +function! rust#GetConfigVar(name, default) + " Local buffer variable with same name takes predeence over global + if has_key(b:, a:name) + return get(b:, a:name) + endif + if has_key(g:, a:name) + return get(g:, a:name) + endif + return a:default +endfunction + +" Include expression {{{1 + +function! rust#IncludeExpr(fname) abort + " Remove leading 'crate::' to deal with 2018 edition style 'use' + " statements + let l:fname = substitute(a:fname, '^crate::', '', '') + + " Remove trailing colons arising from lines like + " + " use foo::{Bar, Baz}; + let l:fname = substitute(l:fname, ':\+$', '', '') + + " Replace '::' with '/' + let l:fname = substitute(l:fname, '::', '/', 'g') + + " When we have + " + " use foo::bar::baz; + " + " we can't tell whether baz is a module or a function; and we can't tell + " which modules correspond to files. + " + " So we work our way up, trying + " + " foo/bar/baz.rs + " foo/bar.rs + " foo.rs + while l:fname !=# '.' + let l:path = findfile(l:fname) + if !empty(l:path) + return l:fname + endif + let l:fname = fnamemodify(l:fname, ':h') + endwhile + return l:fname +endfunction + +" Jump {{{1 + +function! rust#Jump(mode, function) range + let cnt = v:count1 + normal! m' + if a:mode ==# 'v' + norm! gv + endif + let foldenable = &foldenable + set nofoldenable + while cnt > 0 + execute "call Jump_" . a:function . "()" + let cnt = cnt - 1 + endwhile + let &foldenable = foldenable +endfunction + +function! s:Jump_Back() + call search('{', 'b') + keepjumps normal! w99[{ +endfunction + +function! s:Jump_Forward() + normal! j0 + call search('{', 'b') + keepjumps normal! w99[{% + call search('{') +endfunction + +" Run {{{1 + +function! rust#Run(bang, args) + let args = s:ShellTokenize(a:args) + if a:bang + let idx = index(l:args, '--') + if idx != -1 + let rustc_args = idx == 0 ? [] : l:args[:idx-1] + let args = l:args[idx+1:] + else + let rustc_args = l:args + let args = [] + endif + else + let rustc_args = [] + endif + + let b:rust_last_rustc_args = l:rustc_args + let b:rust_last_args = l:args + + call s:WithPath(function("s:Run"), rustc_args, args) +endfunction + +function! s:Run(dict, rustc_args, args) + let exepath = a:dict.tmpdir.'/'.fnamemodify(a:dict.path, ':t:r') + if has('win32') + let exepath .= '.exe' + endif + + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let rustc_args = [relpath, '-o', exepath] + a:rustc_args + + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(rustc_args, 'shellescape(v:val)'))) + if output !=# '' + echohl WarningMsg + echo output + echohl None + endif + if !v:shell_error + exe '!' . shellescape(exepath) . " " . join(map(a:args, 'shellescape(v:val)')) + endif +endfunction + +" Expand {{{1 + +function! rust#Expand(bang, args) + let args = s:ShellTokenize(a:args) + if a:bang && !empty(l:args) + let pretty = remove(l:args, 0) + else + let pretty = "expanded" + endif + call s:WithPath(function("s:Expand"), pretty, args) +endfunction + +function! s:Expand(dict, pretty, args) + try + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + if a:pretty =~? '^\%(everybody_loops$\|flowgraph=\)' + let flag = '--xpretty' + else + let flag = '--pretty' + endif + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let args = [relpath, '-Z', 'unstable-options', l:flag, a:pretty] + a:args + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(args, 'shellescape(v:val)'))) + if v:shell_error + echohl WarningMsg + echo output + echohl None + else + new + silent put =output + 1 + d + setl filetype=rust + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + " give the buffer a nice name + let suffix = 1 + let basename = fnamemodify(a:dict.path, ':t:r') + while 1 + let bufname = basename + if suffix > 1 | let bufname .= ' ('.suffix.')' | endif + let bufname .= '.pretty.rs' + if bufexists(bufname) + let suffix += 1 + continue + endif + exe 'silent noautocmd keepalt file' fnameescape(bufname) + break + endwhile + endif + endtry +endfunction + +function! rust#CompleteExpand(lead, line, pos) + if a:line[: a:pos-1] =~# '^RustExpand!\s*\S*$' + " first argument and it has a ! + let list = ["normal", "expanded", "typed", "expanded,identified", "flowgraph=", "everybody_loops"] + if !empty(a:lead) + call filter(list, "v:val[:len(a:lead)-1] == a:lead") + endif + return list + endif + + return glob(escape(a:lead, "*?[") . '*', 0, 1) +endfunction + +" Emit {{{1 + +function! rust#Emit(type, args) + let args = s:ShellTokenize(a:args) + call s:WithPath(function("s:Emit"), a:type, args) +endfunction + +function! s:Emit(dict, type, args) + try + let output_path = a:dict.tmpdir.'/output' + + let rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + + let relpath = get(a:dict, 'tmpdir_relpath', a:dict.path) + let args = [relpath, '--emit', a:type, '-o', output_path] + a:args + let pwd = a:dict.istemp ? a:dict.tmpdir : '' + let output = s:system(pwd, shellescape(rustc) . " " . join(map(args, 'shellescape(v:val)'))) + if output !=# '' + echohl WarningMsg + echo output + echohl None + endif + if !v:shell_error + new + exe 'silent keepalt read' fnameescape(output_path) + 1 + d + if a:type ==# "llvm-ir" + setl filetype=llvm + let extension = 'll' + elseif a:type ==# "asm" + setl filetype=asm + let extension = 's' + endif + setl buftype=nofile + setl bufhidden=hide + setl noswapfile + if exists('l:extension') + " give the buffer a nice name + let suffix = 1 + let basename = fnamemodify(a:dict.path, ':t:r') + while 1 + let bufname = basename + if suffix > 1 | let bufname .= ' ('.suffix.')' | endif + let bufname .= '.'.extension + if bufexists(bufname) + let suffix += 1 + continue + endif + exe 'silent noautocmd keepalt file' fnameescape(bufname) + break + endwhile + endif + endif + endtry +endfunction + +" Utility functions {{{1 + +" Invokes func(dict, ...) +" Where {dict} is a dictionary with the following keys: +" 'path' - The path to the file +" 'tmpdir' - The path to a temporary directory that will be deleted when the +" function returns. +" 'istemp' - 1 if the path is a file inside of {dict.tmpdir} or 0 otherwise. +" If {istemp} is 1 then an additional key is provided: +" 'tmpdir_relpath' - The {path} relative to the {tmpdir}. +" +" {dict.path} may be a path to a file inside of {dict.tmpdir} or it may be the +" existing path of the current buffer. If the path is inside of {dict.tmpdir} +" then it is guaranteed to have a '.rs' extension. +function! s:WithPath(func, ...) + let buf = bufnr('') + let saved = {} + let dict = {} + try + let saved.write = &write + set write + let dict.path = expand('%') + let pathisempty = empty(dict.path) + + " Always create a tmpdir in case the wrapped command wants it + let dict.tmpdir = tempname() + call mkdir(dict.tmpdir) + + if pathisempty || !saved.write + let dict.istemp = 1 + " if we're doing this because of nowrite, preserve the filename + if !pathisempty + let filename = expand('%:t:r').".rs" + else + let filename = 'unnamed.rs' + endif + let dict.tmpdir_relpath = filename + let dict.path = dict.tmpdir.'/'.filename + + let saved.mod = &modified + set nomodified + + silent exe 'keepalt write! ' . fnameescape(dict.path) + if pathisempty + silent keepalt 0file + endif + else + let dict.istemp = 0 + update + endif + + call call(a:func, [dict] + a:000) + finally + if bufexists(buf) + for [opt, value] in items(saved) + silent call setbufvar(buf, '&'.opt, value) + unlet value " avoid variable type mismatches + endfor + endif + if has_key(dict, 'tmpdir') | silent call s:RmDir(dict.tmpdir) | endif + endtry +endfunction + +function! rust#AppendCmdLine(text) + call setcmdpos(getcmdpos()) + let cmd = getcmdline() . a:text + return cmd +endfunction + +" Tokenize the string according to sh parsing rules +function! s:ShellTokenize(text) + " states: + " 0: start of word + " 1: unquoted + " 2: unquoted backslash + " 3: double-quote + " 4: double-quoted backslash + " 5: single-quote + let l:state = 0 + let l:current = '' + let l:args = [] + for c in split(a:text, '\zs') + if l:state == 0 || l:state == 1 " unquoted + if l:c ==# ' ' + if l:state == 0 | continue | endif + call add(l:args, l:current) + let l:current = '' + let l:state = 0 + elseif l:c ==# '\' + let l:state = 2 + elseif l:c ==# '"' + let l:state = 3 + elseif l:c ==# "'" + let l:state = 5 + else + let l:current .= l:c + let l:state = 1 + endif + elseif l:state == 2 " unquoted backslash + if l:c !=# "\n" " can it even be \n? + let l:current .= l:c + endif + let l:state = 1 + elseif l:state == 3 " double-quote + if l:c ==# '\' + let l:state = 4 + elseif l:c ==# '"' + let l:state = 1 + else + let l:current .= l:c + endif + elseif l:state == 4 " double-quoted backslash + if stridx('$`"\', l:c) >= 0 + let l:current .= l:c + elseif l:c ==# "\n" " is this even possible? + " skip it + else + let l:current .= '\'.l:c + endif + let l:state = 3 + elseif l:state == 5 " single-quoted + if l:c ==# "'" + let l:state = 1 + else + let l:current .= l:c + endif + endif + endfor + if l:state != 0 + call add(l:args, l:current) + endif + return l:args +endfunction + +function! s:RmDir(path) + " sanity check; make sure it's not empty, /, or $HOME + if empty(a:path) + echoerr 'Attempted to delete empty path' + return 0 + elseif a:path ==# '/' || a:path ==# $HOME + let l:path = expand(a:path) + if l:path ==# '/' || l:path ==# $HOME + echoerr 'Attempted to delete protected path: ' . a:path + return 0 + endif + endif + + if !isdirectory(a:path) + return 0 + endif + + " delete() returns 0 when removing file successfully + return delete(a:path, 'rf') == 0 +endfunction + +" Executes {cmd} with the cwd set to {pwd}, without changing Vim's cwd. +" If {pwd} is the empty string then it doesn't change the cwd. +function! s:system(pwd, cmd) + let cmd = a:cmd + if !empty(a:pwd) + let cmd = 'cd ' . shellescape(a:pwd) . ' && ' . cmd + endif + return system(cmd) +endfunction + +" Playpen Support {{{1 +" Parts of gist.vim by Yasuhiro Matsumoto reused +" gist.vim available under the BSD license, available at +" http://github.com/mattn/gist-vim +function! s:has_webapi() + if !exists("*webapi#http#post") + try + call webapi#http#post() + catch + endtry + endif + return exists("*webapi#http#post") +endfunction + +function! rust#Play(count, line1, line2, ...) abort + redraw + + let l:rust_playpen_url = get(g:, 'rust_playpen_url', 'https://play.rust-lang.org/') + let l:rust_shortener_url = get(g:, 'rust_shortener_url', 'https://is.gd/') + + if !s:has_webapi() + echohl ErrorMsg | echomsg ':RustPlay depends on webapi.vim (https://github.com/mattn/webapi-vim)' | echohl None + return + endif + + let bufname = bufname('%') + if a:count < 1 + let content = join(getline(a:line1, a:line2), "\n") + else + let save_regcont = @" + let save_regtype = getregtype('"') + silent! normal! gvy + let content = @" + call setreg('"', save_regcont, save_regtype) + endif + + let url = l:rust_playpen_url."?code=".webapi#http#encodeURI(content) + + if strlen(url) > 5000 + echohl ErrorMsg | echomsg 'Buffer too large, max 5000 encoded characters ('.strlen(url).')' | echohl None + return + endif + + let payload = "format=simple&url=".webapi#http#encodeURI(url) + let res = webapi#http#post(l:rust_shortener_url.'create.php', payload, {}) + if res.status[0] ==# '2' + let url = res.content + endif + + let footer = '' + if exists('g:rust_clip_command') + call system(g:rust_clip_command, url) + if !v:shell_error + let footer = ' (copied to clipboard)' + endif + endif + redraw | echomsg 'Done: '.url.footer +endfunction + +" Run a test under the cursor or all tests {{{1 + +" Finds a test function name under the cursor. Returns empty string when a +" test function is not found. +function! s:SearchTestFunctionNameUnderCursor() abort + let cursor_line = line('.') + + " Find #[test] attribute + if search('\m\C#\[test\]', 'bcW') is 0 + return '' + endif + + " Move to an opening brace of the test function + let test_func_line = search('\m\C^\s*fn\s\+\h\w*\s*(.\+{$', 'eW') + if test_func_line is 0 + return '' + endif + + " Search the end of test function (closing brace) to ensure that the + " cursor position is within function definition + if maparg('(MatchitNormalForward)') ==# '' + keepjumps normal! % + else + " Prefer matchit.vim official plugin to native % since the plugin + " provides better behavior than original % (#391) + " To load the plugin, run: + " :packadd matchit + execute 'keepjumps' 'normal' "\(MatchitNormalForward)" + endif + if line('.') < cursor_line + return '' + endif + + return matchstr(getline(test_func_line), '\m\C^\s*fn\s\+\zs\h\w*') +endfunction + +function! rust#Test(mods, winsize, all, options) abort + let manifest = findfile('Cargo.toml', expand('%:p:h') . ';') + if manifest ==# '' + return rust#Run(1, '--test ' . a:options) + endif + + " defaults to 0, but we prefer an empty string + let winsize = a:winsize ? a:winsize : '' + + if has('terminal') + if has('patch-8.0.910') + let cmd = printf('%s noautocmd %snew | terminal ++curwin ', a:mods, winsize) + else + let cmd = printf('%s terminal ', a:mods) + endif + elseif has('nvim') + let cmd = printf('%s noautocmd %snew | terminal ', a:mods, winsize) + else + let cmd = '!' + let manifest = shellescape(manifest) + endif + + if a:all + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest + else + execute cmd . 'cargo test --manifest-path' manifest a:options + endif + return + endif + + let saved = getpos('.') + try + let func_name = s:SearchTestFunctionNameUnderCursor() + finally + call setpos('.', saved) + endtry + if func_name ==# '' + echohl ErrorMsg + echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' + echohl None + return + endif + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest func_name + else + execute cmd . 'cargo test --manifest-path' manifest func_name a:options + endif +endfunction + +" }}}1 + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/rust/debugging.vim b/sources_non_forked/rust.vim/autoload/rust/debugging.vim new file mode 100644 index 00000000..b39f6877 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rust/debugging.vim @@ -0,0 +1,103 @@ +" For debugging, inspired by https://github.com/w0rp/rust/blob/master/autoload/rust/debugging.vim + +let s:global_variable_list = [ + \ '_rustfmt_autosave_because_of_config', + \ 'ftplugin_rust_source_path', + \ 'loaded_syntastic_rust_cargo_checker', + \ 'loaded_syntastic_rust_filetype', + \ 'loaded_syntastic_rust_rustc_checker', + \ 'rust_bang_comment_leader', + \ 'rust_cargo_avoid_whole_workspace', + \ 'rust_clip_command', + \ 'rust_conceal', + \ 'rust_conceal_mod_path', + \ 'rust_conceal_pub', + \ 'rust_fold', + \ 'rust_last_args', + \ 'rust_last_rustc_args', + \ 'rust_original_delimitMate_excluded_regions', + \ 'rust_playpen_url', + \ 'rust_prev_delimitMate_quotes', + \ 'rust_recent_nearest_cargo_tol', + \ 'rust_recent_root_cargo_toml', + \ 'rust_recommended_style', + \ 'rust_set_conceallevel', + \ 'rust_set_conceallevel=1', + \ 'rust_set_foldmethod', + \ 'rust_set_foldmethod=1', + \ 'rust_shortener_url', + \ 'rustc_makeprg_no_percent', + \ 'rustc_path', + \ 'rustfmt_autosave', + \ 'rustfmt_autosave_if_config_present', + \ 'rustfmt_command', + \ 'rustfmt_emit_files', + \ 'rustfmt_fail_silently', + \ 'rustfmt_options', + \ 'syntastic_extra_filetypes', + \ 'syntastic_rust_cargo_fname', + \] + +function! s:Echo(message) abort + execute 'echo a:message' +endfunction + +function! s:EchoGlobalVariables() abort + for l:key in s:global_variable_list + if l:key !~# '^_' + call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null))) + endif + + if has_key(b:, l:key) + call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key])) + endif + endfor +endfunction + +function! rust#debugging#Info() abort + call cargo#Load() + call rust#Load() + call rustfmt#Load() + call s:Echo('rust.vim Global Variables:') + call s:Echo('') + call s:EchoGlobalVariables() + + silent let l:output = system(g:rustfmt_command . ' --version') + echo l:output + + let l:rustc = exists("g:rustc_path") ? g:rustc_path : "rustc" + silent let l:output = system(l:rustc . ' --version') + echo l:output + + silent let l:output = system('cargo --version') + echo l:output + + version + + if exists(":SyntasticInfo") + echo "----" + echo "Info from Syntastic:" + execute "SyntasticInfo" + endif +endfunction + +function! rust#debugging#InfoToClipboard() abort + redir @" + silent call rust#debugging#Info() + redir END + + call s:Echo('RustInfo copied to your clipboard') +endfunction + +function! rust#debugging#InfoToFile(filename) abort + let l:expanded_filename = expand(a:filename) + + redir => l:output + silent call rust#debugging#Info() + redir END + + call writefile(split(l:output, "\n"), l:expanded_filename) + call s:Echo('RustInfo written to ' . l:expanded_filename) +endfunction + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/rust/delimitmate.vim b/sources_non_forked/rust.vim/autoload/rust/delimitmate.vim new file mode 100644 index 00000000..7056d533 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rust/delimitmate.vim @@ -0,0 +1,44 @@ +let s:delimitMate_extra_excluded_regions = ',rustLifetimeCandidate,rustGenericLifetimeCandidate' + +" For this buffer, when delimitMate issues the `User delimitMate_map` +" event in the autocommand system, add the above-defined extra excluded +" regions to delimitMate's state, if they have not already been added. +function! rust#delimitmate#onMap() abort + if &filetype !=# 'rust' + return + endif + + if get(b:, "delimitMate_quotes") + let b:rust_prev_delimitMate_quotes = b:delimitMate_quotes + endif + let b:delimitMate_quotes = "\" `" + + if match(delimitMate#Get("excluded_regions"), + \ s:delimitMate_extra_excluded_regions) == -1 + call delimitMate#Set("excluded_regions", + \delimitMate#Get("excluded_regions").s:delimitMate_extra_excluded_regions) + endif +endfunction + +" For this buffer, when delimitMate issues the `User delimitMate_unmap` +" event in the autocommand system, delete the above-defined extra excluded +" regions from delimitMate's state (the deletion being idempotent and +" having no effect if the extra excluded regions are not present in the +" targeted part of delimitMate's state). +function! rust#delimitmate#onUnmap() abort + if &filetype !=# 'rust' + return + endif + + if get(b:, "rust_prev_delimitMate_quotes") + let b:delimitMate_quotes = b:rust_prev_delimitMate_quotes + endif + + call delimitMate#Set("excluded_regions", substitute( + \ delimitMate#Get("excluded_regions"), + \ '\C\V' . s:delimitMate_extra_excluded_regions, + \ '', 'g')) +endfunction + +" vim: set et sw=4 sts=4 ts=8: + diff --git a/sources_non_forked/rust.vim/autoload/rust/tags.vim b/sources_non_forked/rust.vim/autoload/rust/tags.vim new file mode 100644 index 00000000..0a4cc20e --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rust/tags.vim @@ -0,0 +1,18 @@ +" Tagbar support code, for the sake of not automatically overriding its +" configuration in case Universal Ctags is detected. + +let s:ctags_is_uctags = 0 +let s:checked_ctags = 0 + +function! rust#tags#IsUCtags() abort + if s:checked_ctags == 0 + let l:ctags_bin = get(g:, 'tagbar_ctags_bin', 'ctags') + if system(l:ctags_bin.' --version') =~? 'universal ctags' + let s:ctags_is_uctags = 1 + endif + let s:checked_ctags = 1 + endif + return s:ctags_is_uctags +endfunction + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/autoload/rustfmt.vim b/sources_non_forked/rust.vim/autoload/rustfmt.vim new file mode 100644 index 00000000..59a58e84 --- /dev/null +++ b/sources_non_forked/rust.vim/autoload/rustfmt.vim @@ -0,0 +1,260 @@ +" Author: Stephen Sugden +" +" Adapted from https://github.com/fatih/vim-go +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +if !exists("g:rustfmt_autosave") + let g:rustfmt_autosave = 0 +endif + +if !exists("g:rustfmt_command") + let g:rustfmt_command = "rustfmt" +endif + +if !exists("g:rustfmt_options") + let g:rustfmt_options = "" +endif + +if !exists("g:rustfmt_fail_silently") + let g:rustfmt_fail_silently = 0 +endif + +function! rustfmt#DetectVersion() + " Save rustfmt '--help' for feature inspection + silent let s:rustfmt_help = system(g:rustfmt_command . " --help") + let s:rustfmt_unstable_features = s:rustfmt_help =~# "--unstable-features" + + " Build a comparable rustfmt version varible out of its `--version` output: + silent let l:rustfmt_version_full = system(g:rustfmt_command . " --version") + let l:rustfmt_version_list = matchlist(l:rustfmt_version_full, + \ '\vrustfmt ([0-9]+[.][0-9]+[.][0-9]+)') + if len(l:rustfmt_version_list) < 3 + let s:rustfmt_version = "0" + else + let s:rustfmt_version = l:rustfmt_version_list[1] + endif + return s:rustfmt_version +endfunction + +call rustfmt#DetectVersion() + +if !exists("g:rustfmt_emit_files") + let g:rustfmt_emit_files = s:rustfmt_version >= "0.8.2" +endif + +if !exists("g:rustfmt_file_lines") + let g:rustfmt_file_lines = s:rustfmt_help =~# "--file-lines JSON" +endif + +let s:got_fmt_error = 0 + +function! rustfmt#Load() + " Utility call to get this script loaded, for debugging +endfunction + +function! s:RustfmtWriteMode() + if g:rustfmt_emit_files + return "--emit=files" + else + return "--write-mode=overwrite" + endif +endfunction + +function! s:RustfmtConfigOptions() + let l:rustfmt_toml = findfile('rustfmt.toml', expand('%:p:h') . ';') + if l:rustfmt_toml !=# '' + return '--config-path '.shellescape(fnamemodify(l:rustfmt_toml, ":p")) + endif + + let l:_rustfmt_toml = findfile('.rustfmt.toml', expand('%:p:h') . ';') + if l:_rustfmt_toml !=# '' + return '--config-path '.shellescape(fnamemodify(l:_rustfmt_toml, ":p")) + endif + + " Default to edition 2018 in case no rustfmt.toml was found. + return '--edition 2018' +endfunction + +function! s:RustfmtCommandRange(filename, line1, line2) + if g:rustfmt_file_lines == 0 + echo "--file-lines is not supported in the installed `rustfmt` executable" + return + endif + + let l:arg = {"file": shellescape(a:filename), "range": [a:line1, a:line2]} + let l:write_mode = s:RustfmtWriteMode() + let l:rustfmt_config = s:RustfmtConfigOptions() + + " FIXME: When --file-lines gets to be stable, add version range checking + " accordingly. + let l:unstable_features = s:rustfmt_unstable_features ? '--unstable-features' : '' + + let l:cmd = printf("%s %s %s %s %s --file-lines '[%s]' %s", g:rustfmt_command, + \ l:write_mode, g:rustfmt_options, + \ l:unstable_features, l:rustfmt_config, + \ json_encode(l:arg), shellescape(a:filename)) + return l:cmd +endfunction + +function! s:RustfmtCommand() + let write_mode = g:rustfmt_emit_files ? '--emit=stdout' : '--write-mode=display' + let config = s:RustfmtConfigOptions() + return join([g:rustfmt_command, write_mode, config, g:rustfmt_options]) +endfunction + +function! s:DeleteLines(start, end) abort + silent! execute a:start . ',' . a:end . 'delete _' +endfunction + +function! s:RunRustfmt(command, tmpname, from_writepre) + let l:view = winsaveview() + + let l:stderr_tmpname = tempname() + call writefile([], l:stderr_tmpname) + + let l:command = a:command . ' 2> ' . l:stderr_tmpname + + if a:tmpname ==# '' + " Rustfmt in stdin/stdout mode + + " chdir to the directory of the file + let l:has_lcd = haslocaldir() + let l:prev_cd = getcwd() + execute 'lchdir! '.expand('%:h') + + let l:buffer = getline(1, '$') + if exists("*systemlist") + silent let out = systemlist(l:command, l:buffer) + else + silent let out = split(system(l:command, + \ join(l:buffer, "\n")), '\r\?\n') + endif + else + if exists("*systemlist") + silent let out = systemlist(l:command) + else + silent let out = split(system(l:command), '\r\?\n') + endif + endif + + let l:stderr = readfile(l:stderr_tmpname) + + call delete(l:stderr_tmpname) + + let l:open_lwindow = 0 + if v:shell_error == 0 + if a:from_writepre + " remove undo point caused via BufWritePre + try | silent undojoin | catch | endtry + endif + + if a:tmpname ==# '' + let l:content = l:out + else + " take the tmpfile's content, this is better than rename + " because it preserves file modes. + let l:content = readfile(a:tmpname) + endif + + call s:DeleteLines(len(l:content), line('$')) + call setline(1, l:content) + + " only clear location list if it was previously filled to prevent + " clobbering other additions + if s:got_fmt_error + let s:got_fmt_error = 0 + call setloclist(0, []) + let l:open_lwindow = 1 + endif + elseif g:rustfmt_fail_silently == 0 && !a:from_writepre + " otherwise get the errors and put them in the location list + let l:errors = [] + + let l:prev_line = "" + for l:line in l:stderr + " error: expected one of `;` or `as`, found `extern` + " --> src/main.rs:2:1 + let tokens = matchlist(l:line, '^\s\+-->\s\(.\{-}\):\(\d\+\):\(\d\+\)$') + if !empty(tokens) + call add(l:errors, {"filename": @%, + \"lnum": tokens[2], + \"col": tokens[3], + \"text": l:prev_line}) + endif + let l:prev_line = l:line + endfor + + if !empty(l:errors) + call setloclist(0, l:errors, 'r') + echohl Error | echomsg "rustfmt returned error" | echohl None + else + echo "rust.vim: was not able to parse rustfmt messages. Here is the raw output:" + echo "\n" + for l:line in l:stderr + echo l:line + endfor + endif + + let s:got_fmt_error = 1 + let l:open_lwindow = 1 + endif + + " Restore the current directory if needed + if a:tmpname ==# '' + if l:has_lcd + execute 'lchdir! '.l:prev_cd + else + execute 'chdir! '.l:prev_cd + endif + endif + + " Open lwindow after we have changed back to the previous directory + if l:open_lwindow == 1 + lwindow + endif + + call winrestview(l:view) +endfunction + +function! rustfmt#FormatRange(line1, line2) + let l:tmpname = tempname() + call writefile(getline(1, '$'), l:tmpname) + let command = s:RustfmtCommandRange(l:tmpname, a:line1, a:line2) + call s:RunRustfmt(command, l:tmpname, v:false) + call delete(l:tmpname) +endfunction + +function! rustfmt#Format() + call s:RunRustfmt(s:RustfmtCommand(), '', v:false) +endfunction + +function! rustfmt#Cmd() + " Mainly for debugging + return s:RustfmtCommand() +endfunction + +function! rustfmt#PreWrite() + if !filereadable(expand("%@")) + return + endif + if rust#GetConfigVar('rustfmt_autosave_if_config_present', 0) + if findfile('rustfmt.toml', '.;') !=# '' || findfile('.rustfmt.toml', '.;') !=# '' + let b:rustfmt_autosave = 1 + let b:_rustfmt_autosave_because_of_config = 1 + endif + else + if has_key(b:, '_rustfmt_autosave_because_of_config') + unlet b:_rustfmt_autosave_because_of_config + unlet b:rustfmt_autosave + endif + endif + + if !rust#GetConfigVar("rustfmt_autosave", 0) + return + endif + + call s:RunRustfmt(s:RustfmtCommand(), '', v:true) +endfunction + + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/compiler/cargo.vim b/sources_non_forked/rust.vim/compiler/cargo.vim new file mode 100644 index 00000000..a511ef6f --- /dev/null +++ b/sources_non_forked/rust.vim/compiler/cargo.vim @@ -0,0 +1,51 @@ +" Vim compiler file +" Compiler: Cargo Compiler +" Maintainer: Damien Radtke +" Latest Revision: 2014 Sep 24 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +if exists('current_compiler') + finish +endif +runtime compiler/rustc.vim +let current_compiler = "cargo" + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal +endif + +if exists('g:cargo_makeprg_params') + execute 'CompilerSet makeprg=cargo\ '.escape(g:cargo_makeprg_params, ' \|"').'\ $*' +else + CompilerSet makeprg=cargo\ $* +endif + +augroup RustCargoQuickFixHooks + autocmd! + autocmd QuickFixCmdPre make call cargo#quickfix#CmdPre() + autocmd QuickFixCmdPost make call cargo#quickfix#CmdPost() +augroup END + +" Ignore general cargo progress messages +CompilerSet errorformat+= + \%-G%\\s%#Downloading%.%#, + \%-G%\\s%#Checking%.%#, + \%-G%\\s%#Compiling%.%#, + \%-G%\\s%#Finished%.%#, + \%-G%\\s%#error:\ Could\ not\ compile\ %.%#, + \%-G%\\s%#To\ learn\ more\\,%.%#, + \%-G%\\s%#For\ more\ information\ about\ this\ error\\,%.%#, + \%-Gnote:\ Run\ with\ \`RUST_BACKTRACE=%.%#, + \%.%#panicked\ at\ \\'%m\\'\\,\ %f:%l:%c + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/compiler/rustc.vim b/sources_non_forked/rust.vim/compiler/rustc.vim new file mode 100644 index 00000000..9b70732a --- /dev/null +++ b/sources_non_forked/rust.vim/compiler/rustc.vim @@ -0,0 +1,57 @@ +" Vim compiler file +" Compiler: Rust Compiler +" Maintainer: Chris Morgan +" Latest Revision: 2013 Jul 12 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +if exists("current_compiler") + finish +endif +let current_compiler = "rustc" + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +if get(g:, 'rustc_makeprg_no_percent', 0) + CompilerSet makeprg=rustc +else + if has('patch-7.4.191') + CompilerSet makeprg=rustc\ \%:S + else + CompilerSet makeprg=rustc\ \"%\" + endif +endif + +" New errorformat (after nightly 2016/08/10) +CompilerSet errorformat= + \%-G, + \%-Gerror:\ aborting\ %.%#, + \%-Gerror:\ Could\ not\ compile\ %.%#, + \%Eerror:\ %m, + \%Eerror[E%n]:\ %m, + \%Wwarning:\ %m, + \%Inote:\ %m, + \%C\ %#-->\ %f:%l:%c, + \%E\ \ left:%m,%C\ right:%m\ %f:%l:%c,%Z + +" Old errorformat (before nightly 2016/08/10) +CompilerSet errorformat+= + \%f:%l:%c:\ %t%*[^:]:\ %m, + \%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m, + \%-G%f:%l\ %s, + \%-G%*[\ ]^, + \%-G%*[\ ]^%*[~], + \%-G%*[\ ]... + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/ctags/rust.ctags b/sources_non_forked/rust.vim/ctags/rust.ctags new file mode 100644 index 00000000..d4f474e6 --- /dev/null +++ b/sources_non_forked/rust.vim/ctags/rust.ctags @@ -0,0 +1,11 @@ +--langdef=Rust +--langmap=Rust:.rs +--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?(static|const)[ \t]+([a-zA-Z0-9_]+)/\3/c,consts,static constants/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\2/t,traits,traits/ +--regex-Rust=/^[ \t]*(pub[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+(for)[ \t]+)?([a-zA-Z0-9_]+)/\4 \6 \7/i,impls,trait implementations/ +--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/ diff --git a/sources_non_forked/rust.vim/doc/rust.txt b/sources_non_forked/rust.vim/doc/rust.txt new file mode 100644 index 00000000..9d5eb8cc --- /dev/null +++ b/sources_non_forked/rust.vim/doc/rust.txt @@ -0,0 +1,486 @@ +*ft_rust.txt* Filetype plugin for Rust + +============================================================================== +CONTENTS *rust* + +1. Introduction |rust-intro| +2. Settings |rust-settings| +3. Commands |rust-commands| +4. Mappings |rust-mappings| + +============================================================================== +INTRODUCTION *rust-intro* + +This plugin provides syntax and supporting functionality for the Rust +filetype. It requires Vim 8 or higher for full functionality. Some commands +will not work on earlier versions. + +============================================================================== +SETTINGS *rust-settings* + +This plugin has a few variables you can define in your vimrc that change the +behavior of the plugin. + +Some variables can be set buffer local (`:b` prefix), and the buffer local +will take precedence over the global `g:` counterpart. + + *g:rustc_path* +g:rustc_path~ + Set this option to the path to rustc for use in the |:RustRun| and + |:RustExpand| commands. If unset, "rustc" will be located in $PATH: > + let g:rustc_path = $HOME."/bin/rustc" +< + + *g:rustc_makeprg_no_percent* +g:rustc_makeprg_no_percent~ + Set this option to 1 to have 'makeprg' default to "rustc" instead of + "rustc %": > + let g:rustc_makeprg_no_percent = 1 +< + + *g:rust_conceal* +g:rust_conceal~ + Set this option to turn on the basic |conceal| support: > + let g:rust_conceal = 1 +< + + *g:rust_conceal_mod_path* +g:rust_conceal_mod_path~ + Set this option to turn on |conceal| for the path connecting token + "::": > + let g:rust_conceal_mod_path = 1 +< + + *g:rust_conceal_pub* +g:rust_conceal_pub~ + Set this option to turn on |conceal| for the "pub" token: > + let g:rust_conceal_pub = 1 +< + + *g:rust_recommended_style* +g:rust_recommended_style~ + Set this option to enable vim indentation and textwidth settings to + conform to style conventions of the rust standard library (i.e. use 4 + spaces for indents and sets 'textwidth' to 99). This option is enabled + by default. To disable it: > + let g:rust_recommended_style = 0 +< + + *g:rust_fold* +g:rust_fold~ + Set this option to turn on |folding|: > + let g:rust_fold = 1 +< + Value Effect ~ + 0 No folding + 1 Braced blocks are folded. All folds are open by + default. + 2 Braced blocks are folded. 'foldlevel' is left at the + global value (all folds are closed by default). + + *g:rust_bang_comment_leader* +g:rust_bang_comment_leader~ + Set this option to 1 to preserve the leader on multi-line doc comments + using the /*! syntax: > + let g:rust_bang_comment_leader = 1 +< + + *g:rust_use_custom_ctags_defs* +g:rust_use_custom_ctags_defs~ + Set this option to 1 if you have customized ctags definitions for Rust + and do not wish for those included with rust.vim to be used: > + let g:rust_use_custom_ctags_defs = 1 +< + + NOTE: rust.vim's built-in definitions are only used for the Tagbar Vim + plugin, if you have it installed, AND if Universal Ctags is not + detected. This is because Universal Ctags already has built-in + support for Rust when used with Tagbar. + + Also, note that when using ctags other than Universal Ctags, it is not + automatically used when generating |tags| files that Vim can use to + navigate to definitions across different source files. Feel free to + copy `rust.vim/ctags/rust.ctags` into your own `~/.ctags` if you wish + to generate |tags| files. + + + *g:ftplugin_rust_source_path* +g:ftplugin_rust_source_path~ + Set this option to a path that should be prepended to 'path' for Rust + source files: > + let g:ftplugin_rust_source_path = $HOME.'/dev/rust' +< + + *g:rustfmt_command* +g:rustfmt_command~ + Set this option to the name of the 'rustfmt' executable in your $PATH. If + not specified it defaults to 'rustfmt' : > + let g:rustfmt_command = 'rustfmt' +< + *g:rustfmt_autosave* +g:rustfmt_autosave~ + Set this option to 1 to run |:RustFmt| automatically when saving a + buffer. If not specified it defaults to 0 : > + let g:rustfmt_autosave = 0 +< + There is also a buffer-local b:rustfmt_autosave that can be set for + the same purpose, and can override the global setting. + + *g:rustfmt_autosave_if_config_present* +g:rustfmt_autosave_if_config_present~ + Set this option to 1 to have *b:rustfmt_autosave* be set automatically + if a `rustfmt.toml` file is present in any parent directly leading to + the file being edited. If not set, default to 0: > + let g:rustfmt_autosave_if_config_present = 0 +< + This is useful to have `rustfmt` only execute on save, on projects + that have `rustfmt.toml` configuration. + + There is also a buffer-local b:rustfmt_autosave_if_config_present + that can be set for the same purpose, which can overrides the global + setting. + *g:rustfmt_fail_silently* +g:rustfmt_fail_silently~ + Set this option to 1 to prevent 'rustfmt' from populating the + |location-list| with errors. If not specified it defaults to 0: > + let g:rustfmt_fail_silently = 0 +< + *g:rustfmt_options* +g:rustfmt_options~ + Set this option to a string of options to pass to 'rustfmt'. The + write-mode is already set to 'overwrite'. If not specified it + defaults to '' : > + let g:rustfmt_options = '' +< + *g:rustfmt_emit_files* +g:rustfmt_emit_files~ + If not specified rust.vim tries to detect the right parameter to + pass to rustfmt based on its reported version. Otherwise, it + determines whether to run rustfmt with '--emit=files' (when 1 is + provided) instead of '--write-mode=overwrite'. > + let g:rustfmt_emit_files = 0 + + + *g:rust_playpen_url* +g:rust_playpen_url~ + Set this option to override the url for the playpen to use: > + let g:rust_playpen_url = 'https://play.rust-lang.org/' +< + + *g:rust_shortener_url* +g:rust_shortener_url~ + Set this option to override the url for the url shortener: > + let g:rust_shortener_url = 'https://is.gd/' +< + + *g:rust_clip_command* +g:rust_clip_command~ + Set this option to the command used in your OS to copy the Rust Play + url to the clipboard: > + let g:rust_clip_command = 'xclip -selection clipboard' +< + + *g:cargo_makeprg_params* +g:cargo_makeprg_params~ + Set this option to the string of parameters to pass to cargo. If not + specified it defaults to '$*' : > + let g:cargo_makeprg_params = 'build' +< + + *g:cargo_shell_command_runner* +g:cargo_shell_command_runner~ + Set this option to change how to run shell commands for cargo commands + |:Cargo|, |:Cbuild|, |:Crun|, ... + By default, |:terminal| is used to run shell command in terminal window + asynchronously. But if you prefer |:!| for running the commands, it can + be specified: > + let g:cargo_shell_command_runner = '!' +< + + +Integration with Syntastic *rust-syntastic* +-------------------------- + +This plugin automatically integrates with the Syntastic checker. There are two +checkers provided: 'rustc', and 'cargo'. The latter invokes 'Cargo' in order to +build code, and the former delivers a single edited '.rs' file as a compilation +target directly to the Rust compiler, `rustc`. + +Because Cargo is almost exclusively being used for building Rust code these +days, 'cargo' is the default checker. > + + let g:syntastic_rust_checkers = ['cargo'] +< +If you would like to change it, you can set `g:syntastic_rust_checkers` to a +different value. + *g:rust_cargo_avoid_whole_workspace* + *b:rust_cargo_avoid_whole_workspace* +g:rust_cargo_avoid_whole_workspace~ + When editing a crate that is part of a Cargo workspace, and this + option is set to 1 (the default), then 'cargo' will be executed + directly in that crate directory instead of in the workspace + directory. Setting 0 prevents this behavior - however be aware that if + you are working in large workspace, Cargo commands may take more time, + plus the Syntastic error list may include all the crates in the + workspace. > + let g:rust_cargo_avoid_whole_workspace = 0 +< + *g:rust_cargo_check_all_targets* + *b:rust_cargo_check_all_targets* +g:rust_cargo_check_all_targets~ + When set to 1, the `--all-targets` option will be passed to cargo when + Syntastic executes it, allowing the linting of all targets under the + package. + The default is 0. + + *g:rust_cargo_check_all_features* + *b:rust_cargo_check_all_features* +g:rust_cargo_check_all_features~ + When set to 1, the `--all-features` option will be passed to cargo when + Syntastic executes it, allowing the linting of all features of the + package. + The default is 0. + + *g:rust_cargo_check_examples* + *b:rust_cargo_check_examples* +g:rust_cargo_check_examples~ + When set to 1, the `--examples` option will be passed to cargo when + Syntastic executes it, to prevent the exclusion of examples from + linting. The examples are normally under the `examples/` directory of + the crate. + The default is 0. + + *g:rust_cargo_check_tests* + *b:rust_cargo_check_tests* +g:rust_cargo_check_tests~ + When set to 1, the `--tests` option will be passed to cargo when + Syntastic executes it, to prevent the exclusion of tests from linting. + The tests are normally under the `tests/` directory of the crate. + The default is 0. + + *g:rust_cargo_check_benches* + *b:rust_cargo_check_benches* +g:rust_cargo_check_benches~ + When set to 1, the `--benches` option will be passed to cargo when + Syntastic executes it. The benches are normally under the `benches/` + directory of the crate. + The default is 0. + +Integration with auto-pairs *rust-auto-pairs* +--------------------------- + +This plugin automatically configures the auto-pairs plugin not to duplicate +single quotes, which are used more often for lifetime annotations than for +single character literals. + + *g:rust_keep_autopairs_default* +g:rust_keep_autopairs_default~ + + Don't override auto-pairs default for the Rust filetype. The default + is 0. + +============================================================================== +COMMANDS *rust-commands* + +Invoking Cargo +-------------- + +This plug defines very simple shortcuts for invoking Cargo from with Vim. + +:Cargo *:Cargo* + Runs 'cargo' with the provided arguments. + +:Cbuild *:Cbuild* + Shortcut for 'cargo build`. + +:Cclean *:Cclean* + Shortcut for 'cargo clean`. + +:Cdoc *:Cdoc* + Shortcut for 'cargo doc`. + +:Cinit *:Cinit* + Shortcut for 'cargo init`. + +:Crun *:Crun* + Shortcut for 'cargo run`. + +:Ctest *:Ctest* + Shortcut for 'cargo test`. + +:Cupdate *:Cupdate* + Shortcut for 'cargo update`. + +:Cbench *:Cbench* + Shortcut for 'cargo bench`. + +:Csearch *:Csearch* + Shortcut for 'cargo search`. + +:Cpublish *:Cpublish* + Shortcut for 'cargo publish`. + +:Cinstall *:Cinstall* + Shortcut for 'cargo install`. + +:Cruntarget *:Cruntarget* + Shortcut for 'cargo run --bin' or 'cargo run --example', + depending on the currently open buffer. + +Formatting +---------- + +:RustFmt *:RustFmt* + Runs |g:rustfmt_command| on the current buffer. If + |g:rustfmt_options| is set then those will be passed to the + executable. + + If |g:rustfmt_fail_silently| is 0 (the default) then it + will populate the |location-list| with the errors from + |g:rustfmt_command|. If |g:rustfmt_fail_silently| is set to 1 + then it will not populate the |location-list|. + +:RustFmtRange *:RustFmtRange* + Runs |g:rustfmt_command| with selected range. See + |:RustFmt| for any other information. + + +Playpen integration +------------------- + +:RustPlay *:RustPlay* + This command will only work if you have web-api.vim installed + (available at https://github.com/mattn/webapi-vim). It sends the + current selection, or if nothing is selected, the entirety of the + current buffer to the Rust playpen, and emits a message with the + shortened URL to the playpen. + + |g:rust_playpen_url| is the base URL to the playpen, by default + "https://play.rust-lang.org/". + + |g:rust_shortener_url| is the base url for the shorterner, by + default "https://is.gd/" + + |g:rust_clip_command| is the command to run to copy the + playpen url to the clipboard of your system. + + +Evaluation of a single Rust file +-------------------------------- + +NOTE: These commands are useful only when working with standalone Rust files, +which is usually not the case for common Rust development. If you wish to +building Rust crates from with Vim can should use Vim's make, Syntastic, or +functionality from other plugins. + + +:RustRun [args] *:RustRun* +:RustRun! [rustc-args] [--] [args] + Compiles and runs the current file. If it has unsaved changes, + it will be saved first using |:update|. If the current file is + an unnamed buffer, it will be written to a temporary file + first. The compiled binary is always placed in a temporary + directory, but is run from the current directory. + + The arguments given to |:RustRun| will be passed to the + compiled binary. + + If ! is specified, the arguments are passed to rustc instead. + A "--" argument will separate the rustc arguments from the + arguments passed to the binary. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustExpand [args] *:RustExpand* +:RustExpand! [TYPE] [args] + Expands the current file using --pretty and displays the + results in a new split. If the current file has unsaved + changes, it will be saved first using |:update|. If the + current file is an unnamed buffer, it will be written to a + temporary file first. + + The arguments given to |:RustExpand| will be passed to rustc. + This is largely intended for specifying various --cfg + configurations. + + If ! is specified, the first argument is the expansion type to + pass to rustc --pretty. Otherwise it will default to + "expanded". + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustEmitIr [args] *:RustEmitIr* + Compiles the current file to LLVM IR and displays the results + in a new split. If the current file has unsaved changes, it + will be saved first using |:update|. If the current file is an + unnamed buffer, it will be written to a temporary file first. + + The arguments given to |:RustEmitIr| will be passed to rustc. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + +:RustEmitAsm [args] *:RustEmitAsm* + Compiles the current file to assembly and displays the results + in a new split. If the current file has unsaved changes, it + will be saved first using |:update|. If the current file is an + unnamed buffer, it will be written to a temporary file first. + + The arguments given to |:RustEmitAsm| will be passed to rustc. + + If |g:rustc_path| is defined, it is used as the path to rustc. + Otherwise it is assumed rustc can be found in $PATH. + + +Running test(s) +--------------- + +:[N]RustTest[!] [options] *:RustTest* + Runs a test under the cursor when the current buffer is in a + cargo project with "cargo test" command. If the command did + not find any test function under the cursor, it stops with an + error message. + + When N is given, adjust the size of the new window to N lines + or columns. + + When ! is given, runs all tests regardless of current cursor + position. + + When [options] is given, it is passed to "cargo" command + arguments. + + When the current buffer is outside cargo project, the command + runs "rustc --test" command instead of "cargo test" as + fallback. All tests are run regardless of adding ! since there + is no way to run specific test function with rustc. [options] + is passed to "rustc" command arguments in the case. + + Takes optional modifiers (see ||): > + :tab RustTest + :belowright 16RustTest + :leftabove vert 80RustTest +< +rust.vim Debugging +------------------ + +:RustInfo *:RustInfo* + Emits debugging info of the Vim Rust plugin. + +:RustInfoToClipboard *:RustInfoClipboard* + Saves debugging info of the Vim Rust plugin to the default + register. + +:RustInfoToFile [filename] *:RustInfoToFile* + Saves debugging info of the Vim Rust plugin to the the given + file, overwritting it. + +============================================================================== +MAPPINGS *rust-mappings* + +This plugin defines mappings for |[[| and |]]| to support hanging indents. + +============================================================================== + vim:tw=78:sw=4:noet:ts=8:ft=help:norl: diff --git a/sources_non_forked/rust.vim/ftdetect/rust.vim b/sources_non_forked/rust.vim/ftdetect/rust.vim new file mode 100644 index 00000000..e0950930 --- /dev/null +++ b/sources_non_forked/rust.vim/ftdetect/rust.vim @@ -0,0 +1,15 @@ +" vint: -ProhibitAutocmdWithNoGroup + +autocmd BufRead,BufNewFile *.rs call s:set_rust_filetype() + +if has('patch-8.0.613') + autocmd BufRead,BufNewFile Cargo.toml setf FALLBACK cfg +endif + +function! s:set_rust_filetype() abort + if &filetype !=# 'rust' + set filetype=rust + endif +endfunction + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/ftplugin/rust.vim b/sources_non_forked/rust.vim/ftplugin/rust.vim new file mode 100644 index 00000000..fb048cac --- /dev/null +++ b/sources_non_forked/rust.vim/ftplugin/rust.vim @@ -0,0 +1,200 @@ +" Language: Rust +" Description: Vim ftplugin for Rust +" Maintainer: Chris Morgan +" Last Change: June 08, 2016 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +if get(b:, 'current_compiler', '') ==# '' + if strlen(findfile('Cargo.toml', '.;')) > 0 + compiler cargo + else + compiler rustc + endif +endif + +" Variables {{{1 + +" The rust source code at present seems to typically omit a leader on /*! +" comments, so we'll use that as our default, but make it easy to switch. +" This does not affect indentation at all (I tested it with and without +" leader), merely whether a leader is inserted by default or not. +if get(g:, 'rust_bang_comment_leader', 0) + " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why, + " but without it, */ gets indented one space even if there were no + " leaders. I'm fairly sure that's a Vim bug. + setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// +else + setlocal comments=s0:/*!,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// +endif +setlocal commentstring=//%s +setlocal formatoptions-=t formatoptions+=croqnl +" j was only added in 7.3.541, so stop complaints about its nonexistence +silent! setlocal formatoptions+=j + +" smartindent will be overridden by indentexpr if filetype indent is on, but +" otherwise it's better than nothing. +setlocal smartindent nocindent + +if get(g:, 'rust_recommended_style', 1) + let b:rust_set_style = 1 + setlocal shiftwidth=4 softtabstop=4 expandtab + setlocal textwidth=99 +endif + +setlocal include=\\v^\\s*(pub\\s+)?use\\s+\\zs(\\f\|:)+ +setlocal includeexpr=rust#IncludeExpr(v:fname) + +setlocal suffixesadd=.rs + +if exists("g:ftplugin_rust_source_path") + let &l:path=g:ftplugin_rust_source_path . ',' . &l:path +endif + +if exists("g:loaded_delimitMate") + if exists("b:delimitMate_excluded_regions") + let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions + endif + + augroup rust.vim.DelimitMate + autocmd! + + autocmd User delimitMate_map :call rust#delimitmate#onMap() + autocmd User delimitMate_unmap :call rust#delimitmate#onUnmap() + augroup END +endif + +" Integration with auto-pairs (https://github.com/jiangmiao/auto-pairs) +if exists("g:AutoPairsLoaded") && !get(g:, 'rust_keep_autopairs_default', 0) + let b:AutoPairs = {'(':')', '[':']', '{':'}','"':'"', '`':'`'} +endif + +if has("folding") && get(g:, 'rust_fold', 0) + let b:rust_set_foldmethod=1 + setlocal foldmethod=syntax + if g:rust_fold == 2 + setlocal foldlevel< + else + setlocal foldlevel=99 + endif +endif + +if has('conceal') && get(g:, 'rust_conceal', 0) + let b:rust_set_conceallevel=1 + setlocal conceallevel=2 +endif + +" Motion Commands {{{1 + +" Bind motion commands to support hanging indents +nnoremap [[ :call rust#Jump('n', 'Back') +nnoremap ]] :call rust#Jump('n', 'Forward') +xnoremap [[ :call rust#Jump('v', 'Back') +xnoremap ]] :call rust#Jump('v', 'Forward') +onoremap [[ :call rust#Jump('o', 'Back') +onoremap ]] :call rust#Jump('o', 'Forward') + +" Commands {{{1 + +" See |:RustRun| for docs +command! -nargs=* -complete=file -bang -buffer RustRun call rust#Run(0, ) + +" See |:RustExpand| for docs +command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -buffer RustExpand call rust#Expand(0, ) + +" See |:RustEmitIr| for docs +command! -nargs=* -buffer RustEmitIr call rust#Emit("llvm-ir", ) + +" See |:RustEmitAsm| for docs +command! -nargs=* -buffer RustEmitAsm call rust#Emit("asm", ) + +" See |:RustPlay| for docs +command! -range=% RustPlay :call rust#Play(, , , ) + +" See |:RustFmt| for docs +command! -bar -buffer RustFmt call rustfmt#Format() + +" See |:RustFmtRange| for docs +command! -range -buffer RustFmtRange call rustfmt#FormatRange(, ) + +" See |:RustInfo| for docs +command! -bar RustInfo call rust#debugging#Info() + +" See |:RustInfoToClipboard| for docs +command! -bar RustInfoToClipboard call rust#debugging#InfoToClipboard() + +" See |:RustInfoToFile| for docs +command! -bar -nargs=1 RustInfoToFile call rust#debugging#InfoToFile() + +" See |:RustTest| for docs +command! -buffer -nargs=* -count -bang RustTest call rust#Test(, , 0, ) + +if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args") + let b:rust_last_rustc_args = [] + let b:rust_last_args = [] +endif + +" Cleanup {{{1 + +let b:undo_ftplugin = " + \ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd< + \|if exists('b:rust_set_style') + \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< + \|endif + \|if exists('b:rust_original_delimitMate_excluded_regions') + \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions + \|unlet b:rust_original_delimitMate_excluded_regions + \|else + \|unlet! b:delimitMate_excluded_regions + \|endif + \|if exists('b:rust_set_foldmethod') + \|setlocal foldmethod< foldlevel< + \|unlet b:rust_set_foldmethod + \|endif + \|if exists('b:rust_set_conceallevel') + \|setlocal conceallevel< + \|unlet b:rust_set_conceallevel + \|endif + \|unlet! b:rust_last_rustc_args b:rust_last_args + \|delcommand RustRun + \|delcommand RustExpand + \|delcommand RustEmitIr + \|delcommand RustEmitAsm + \|delcommand RustPlay + \|nunmap [[ + \|nunmap ]] + \|xunmap [[ + \|xunmap ]] + \|ounmap [[ + \|ounmap ]] + \|setlocal matchpairs-=<:> + \|unlet b:match_skip + \" + +" }}}1 + +" Code formatting on save +augroup rust.vim.PreWrite + autocmd! + autocmd BufWritePre *.rs silent! call rustfmt#PreWrite() +augroup END + +setlocal matchpairs+=<:> +" For matchit.vim (rustArrow stops `Fn() -> X` messing things up) +let b:match_skip = 's:comment\|string\|rustCharacter\|rustArrow' + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/ftplugin/rust/tagbar.vim b/sources_non_forked/rust.vim/ftplugin/rust/tagbar.vim new file mode 100644 index 00000000..de8a094c --- /dev/null +++ b/sources_non_forked/rust.vim/ftplugin/rust/tagbar.vim @@ -0,0 +1,40 @@ +" +" Support for Tagbar -- https://github.com/majutsushi/tagbar +" +if !exists(':Tagbar') || rust#tags#IsUCtags() + finish +endif + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +if !exists('g:tagbar_type_rust') + let g:tagbar_type_rust = { + \ 'ctagstype' : 'rust', + \ 'kinds' : [ + \'T:types', + \'f:functions', + \'g:enumerations', + \'s:structures', + \'m:modules', + \'c:constants', + \'t:traits', + \'i:trait implementations', + \ ] + \ } +endif + +" In case you've updated/customized your ~/.ctags and prefer to use it. +if !get(g:, 'rust_use_custom_ctags_defs', 0) + let g:tagbar_type_rust.deffile = expand(':p:h:h:h') . '/ctags/rust.ctags' +endif + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/indent/rust.vim b/sources_non_forked/rust.vim/indent/rust.vim new file mode 100644 index 00000000..e0c847cb --- /dev/null +++ b/sources_non_forked/rust.vim/indent/rust.vim @@ -0,0 +1,286 @@ +" Vim indent file +" Language: Rust +" Author: Chris Morgan +" Last Change: 2018 Jan 10 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal cindent +setlocal cinoptions=L0,(s,Ws,J1,j1,m1 +setlocal cinkeys=0{,0},!^F,o,O,0[,0],0(,0) +" Don't think cinwords will actually do anything at all... never mind +setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro + +" Some preliminary settings +setlocal nolisp " Make sure lisp indenting doesn't supersede us +setlocal autoindent " indentexpr isn't much help otherwise +" Also do indentkeys, otherwise # gets shoved to column 0 :-/ +setlocal indentkeys=0{,0},!^F,o,O,0[,0],0(,0) + +setlocal indentexpr=GetRustIndent(v:lnum) + +let b:undo_indent = "setlocal cindent< cinoptions< cinkeys< cinwords< lisp< autoindent< indentkeys< indentexpr<" + +" Only define the function once. +if exists("*GetRustIndent") + finish +endif + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +" Come here when loading the script the first time. + +function! s:get_line_trimmed(lnum) + " Get the line and remove a trailing comment. + " Use syntax highlighting attributes when possible. + " NOTE: this is not accurate; /* */ or a line continuation could trick it + let line = getline(a:lnum) + let line_len = strlen(line) + if has('syntax_items') + " If the last character in the line is a comment, do a binary search for + " the start of the comment. synID() is slow, a linear search would take + " too long on a long line. + if synIDattr(synID(a:lnum, line_len, 1), "name") =~? 'Comment\|Todo' + let min = 1 + let max = line_len + while min < max + let col = (min + max) / 2 + if synIDattr(synID(a:lnum, col, 1), "name") =~? 'Comment\|Todo' + let max = col + else + let min = col + 1 + endif + endwhile + let line = strpart(line, 0, min - 1) + endif + return substitute(line, "\s*$", "", "") + else + " Sorry, this is not complete, nor fully correct (e.g. string "//"). + " Such is life. + return substitute(line, "\s*//.*$", "", "") + endif +endfunction + +function! s:is_string_comment(lnum, col) + if has('syntax_items') + for id in synstack(a:lnum, a:col) + let synname = synIDattr(id, "name") + if synname ==# "rustString" || synname =~# "^rustComment" + return 1 + endif + endfor + else + " without syntax, let's not even try + return 0 + endif +endfunction + +if exists('*shiftwidth') + function! s:shiftwidth() + return shiftwidth() + endfunc +else + function! s:shiftwidth() + return &shiftwidth + endfunc +endif + +function GetRustIndent(lnum) + " Starting assumption: cindent (called at the end) will do it right + " normally. We just want to fix up a few cases. + + let line = getline(a:lnum) + + if has('syntax_items') + let synname = synIDattr(synID(a:lnum, 1, 1), "name") + if synname ==# "rustString" + " If the start of the line is in a string, don't change the indent + return -1 + elseif synname =~? '\(Comment\|Todo\)' + \ && line !~# '^\s*/\*' " not /* opening line + if synname =~? "CommentML" " multi-line + if line !~# '^\s*\*' && getline(a:lnum - 1) =~# '^\s*/\*' + " This is (hopefully) the line after a /*, and it has no + " leader, so the correct indentation is that of the + " previous line. + return GetRustIndent(a:lnum - 1) + endif + endif + " If it's in a comment, let cindent take care of it now. This is + " for cases like "/*" where the next line should start " * ", not + " "* " as the code below would otherwise cause for module scope + " Fun fact: " /*\n*\n*/" takes two calls to get right! + return cindent(a:lnum) + endif + endif + + " cindent gets second and subsequent match patterns/struct members wrong, + " as it treats the comma as indicating an unfinished statement:: + " + " match a { + " b => c, + " d => e, + " f => g, + " }; + + " Search backwards for the previous non-empty line. + let prevlinenum = prevnonblank(a:lnum - 1) + let prevline = s:get_line_trimmed(prevlinenum) + while prevlinenum > 1 && prevline !~# '[^[:blank:]]' + let prevlinenum = prevnonblank(prevlinenum - 1) + let prevline = s:get_line_trimmed(prevlinenum) + endwhile + + " A standalone '{', '}', or 'where' + let l:standalone_open = line =~# '\V\^\s\*{\s\*\$' + let l:standalone_close = line =~# '\V\^\s\*}\s\*\$' + let l:standalone_where = line =~# '\V\^\s\*where\s\*\$' + if l:standalone_open || l:standalone_close || l:standalone_where + " ToDo: we can search for more items than 'fn' and 'if'. + let [l:found_line, l:col, l:submatch] = + \ searchpos('\<\(fn\)\|\(if\)\>', 'bnWp') + if l:found_line !=# 0 + " Now we count the number of '{' and '}' in between the match + " locations and the current line (there is probably a better + " way to compute this). + let l:i = l:found_line + let l:search_line = strpart(getline(l:i), l:col - 1) + let l:opens = 0 + let l:closes = 0 + while l:i < a:lnum + let l:search_line2 = substitute(l:search_line, '\V{', '', 'g') + let l:opens += strlen(l:search_line) - strlen(l:search_line2) + let l:search_line3 = substitute(l:search_line2, '\V}', '', 'g') + let l:closes += strlen(l:search_line2) - strlen(l:search_line3) + let l:i += 1 + let l:search_line = getline(l:i) + endwhile + if l:standalone_open || l:standalone_where + if l:opens ==# l:closes + return indent(l:found_line) + endif + else + " Expect to find just one more close than an open + if l:opens ==# l:closes + 1 + return indent(l:found_line) + endif + endif + endif + endif + + " A standalone 'where' adds a shift. + let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$' + if l:standalone_prevline_where + return indent(prevlinenum) + 4 + endif + + " Handle where clauses nicely: subsequent values should line up nicely. + if prevline[len(prevline) - 1] ==# "," + \ && prevline =~# '^\s*where\s' + return indent(prevlinenum) + 6 + endif + + let l:last_prevline_character = prevline[len(prevline) - 1] + + " A line that ends with '.;' is probably an end of a long list + " of method operations. + if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';' + call cursor(a:lnum - 1, 1) + let l:scope_start = searchpair('{\|(', '', '}\|)', 'nbW', + \ 's:is_string_comment(line("."), col("."))') + if l:scope_start != 0 && l:scope_start < a:lnum + return indent(l:scope_start) + 4 + endif + endif + + if l:last_prevline_character ==# "," + \ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{})]' + \ && prevline !~# '^\s*fn\s' + \ && prevline !~# '([^()]\+,$' + \ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>' + " Oh ho! The previous line ended in a comma! I bet cindent will try to + " take this too far... For now, let's normally use the previous line's + " indent. + + " One case where this doesn't work out is where *this* line contains + " square or curly brackets; then we normally *do* want to be indenting + " further. + " + " Another case where we don't want to is one like a function + " definition with arguments spread over multiple lines: + " + " fn foo(baz: Baz, + " baz: Baz) // <-- cindent gets this right by itself + " + " Another case is similar to the previous, except calling a function + " instead of defining it, or any conditional expression that leaves + " an open paren: + " + " foo(baz, + " baz); + " + " if baz && (foo || + " bar) { + " + " Another case is when the current line is a new match arm. + " + " There are probably other cases where we don't want to do this as + " well. Add them as needed. + return indent(prevlinenum) + endif + + if !has("patch-7.4.355") + " cindent before 7.4.355 doesn't do the module scope well at all; e.g.:: + " + " static FOO : &'static [bool] = [ + " true, + " false, + " false, + " true, + " ]; + " + " uh oh, next statement is indented further! + + " Note that this does *not* apply the line continuation pattern properly; + " that's too hard to do correctly for my liking at present, so I'll just + " start with these two main cases (square brackets and not returning to + " column zero) + + call cursor(a:lnum, 1) + if searchpair('{\|(', '', '}\|)', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + if searchpair('\[', '', '\]', 'nbW', + \ 's:is_string_comment(line("."), col("."))') == 0 + " Global scope, should be zero + return 0 + else + " At the module scope, inside square brackets only + "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum + if line =~# "^\\s*]" + " It's the closing line, dedent it + return 0 + else + return &shiftwidth + endif + endif + endif + endif + + " Fall back on cindent, which does it mostly right + return cindent(a:lnum) +endfunction + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/plugin/cargo.vim b/sources_non_forked/rust.vim/plugin/cargo.vim new file mode 100644 index 00000000..efc38768 --- /dev/null +++ b/sources_non_forked/rust.vim/plugin/cargo.vim @@ -0,0 +1,27 @@ +if exists('g:loaded_rust_vim_plugin_cargo') + finish +endif +let g:loaded_rust_vim_plugin_cargo = 1 +let s:save_cpo = &cpoptions +set cpoptions&vim + +command! -nargs=+ Cargo call cargo#cmd() +command! -nargs=* Cbuild call cargo#build() +command! -nargs=* Ccheck call cargo#check() +command! -nargs=* Cclean call cargo#clean() +command! -nargs=* Cdoc call cargo#doc() +command! -nargs=+ Cnew call cargo#new() +command! -nargs=* Cinit call cargo#init() +command! -nargs=* Crun call cargo#run() +command! -nargs=* Ctest call cargo#test() +command! -nargs=* Cbench call cargo#bench() +command! -nargs=* Cupdate call cargo#update() +command! -nargs=* Csearch call cargo#search() +command! -nargs=* Cpublish call cargo#publish() +command! -nargs=* Cinstall call cargo#install() +command! -nargs=* Cruntarget call cargo#runtarget() + +let &cpoptions = s:save_cpo +unlet s:save_cpo + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/plugin/rust.vim b/sources_non_forked/rust.vim/plugin/rust.vim new file mode 100644 index 00000000..5fe77ccb --- /dev/null +++ b/sources_non_forked/rust.vim/plugin/rust.vim @@ -0,0 +1,28 @@ +" Vim syntastic plugin helper +" Language: Rust +" Maintainer: Andrew Gallant + +if exists('g:loaded_rust_vim') + finish +endif +let g:loaded_rust_vim = 1 +let s:save_cpo = &cpoptions +set cpoptions&vim + +" This is to let Syntastic know about the Rust filetype. +" It enables tab completion for the 'SyntasticInfo' command. +" (This does not actually register the syntax checker.) +if exists('g:syntastic_extra_filetypes') + call add(g:syntastic_extra_filetypes, 'rust') +else + let g:syntastic_extra_filetypes = ['rust'] +endif + +if !exists('g:syntastic_rust_checkers') + let g:syntastic_rust_checkers = ['cargo'] +endif + +let &cpoptions = s:save_cpo +unlet s:save_cpo + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/syntax/rust.vim b/sources_non_forked/rust.vim/syntax/rust.vim new file mode 100644 index 00000000..8407b56e --- /dev/null +++ b/sources_non_forked/rust.vim/syntax/rust.vim @@ -0,0 +1,387 @@ +" Vim syntax file +" Language: Rust +" Maintainer: Patrick Walton +" Maintainer: Ben Blum +" Maintainer: Chris Morgan +" Last Change: Feb 24, 2016 +" For bugs, patches and license go to https://github.com/rust-lang/rust.vim + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Syntax definitions {{{1 +" Basic keywords {{{2 +syn keyword rustConditional match if else +syn keyword rustRepeat loop while +" `:syn match` must be used to prioritize highlighting `for` keyword. +syn match rustRepeat /\/ +" Highlight `for` keyword in `impl ... for ... {}` statement. This line must +" be put after previous `syn match` line to overwrite it. +syn match rustKeyword /\%(\.\+\)\@<=\/ +syn keyword rustRepeat in +syn keyword rustTypedef type nextgroup=rustIdentifier skipwhite skipempty +syn keyword rustStructure struct enum nextgroup=rustIdentifier skipwhite skipempty +syn keyword rustUnion union nextgroup=rustIdentifier skipwhite skipempty contained +syn match rustUnionContextual /\/ +syn keyword rustAwait await +syn match rustKeyword /\!\@!/ display + +syn keyword rustPubScopeCrate crate contained +syn match rustPubScopeDelim /[()]/ contained +syn match rustPubScope /([^()]*)/ contained contains=rustPubScopeDelim,rustPubScopeCrate,rustSuper,rustModPath,rustModPathSep,rustSelf transparent + +syn keyword rustExternCrate crate contained nextgroup=rustIdentifier,rustExternCrateString skipwhite skipempty +" This is to get the `bar` part of `extern crate "foo" as bar;` highlighting. +syn match rustExternCrateString /".*"\_s*as/ contained nextgroup=rustIdentifier skipwhite transparent skipempty contains=rustString,rustOperator +syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite skipempty + +syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained +syn match rustFuncName "\%(r#\)\=\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained + +syn region rustMacroRepeat matchgroup=rustMacroRepeatDelimiters start="$(" end="),\=[*+]" contains=TOP +syn match rustMacroVariable "$\w\+" +syn match rustRawIdent "\(); + +" This is merely a convention; note also the use of [A-Z], restricting it to +" latin identifiers rather than the full Unicode uppercase. I have not used +" [:upper:] as it depends upon 'noignorecase' +"syn match rustCapsIdent display "[A-Z]\w\(\w\)*" + +syn match rustOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?" +" This one isn't *quite* right, as we could have binary-& with a reference +syn match rustSigil display /&\s\+[&~@*][^)= \t\r\n]/he=e-1,me=e-1 +syn match rustSigil display /[&~@*][^)= \t\r\n]/he=e-1,me=e-1 +" This isn't actually correct; a closure with no arguments can be `|| { }`. +" Last, because the & in && isn't a sigil +syn match rustOperator display "&&\|||" +" This is rustArrowCharacter rather than rustArrow for the sake of matchparen, +" so it skips the ->; see http://stackoverflow.com/a/30309949 for details. +syn match rustArrowCharacter display "->" +syn match rustQuestionMark display "?\([a-zA-Z]\+\)\@!" + +syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustPanic +syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustPanic + +syn match rustEscapeError display contained /\\./ +syn match rustEscape display contained /\\\([nrt0\\'"]\|x\x\{2}\)/ +syn match rustEscapeUnicode display contained /\\u{\%(\x_*\)\{1,6}}/ +syn match rustStringContinuation display contained /\\\n\s*/ +syn region rustString matchgroup=rustStringDelimiter start=+b"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeError,rustStringContinuation +syn region rustString matchgroup=rustStringDelimiter start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustStringContinuation,@Spell +syn region rustString matchgroup=rustStringDelimiter start='b\?r\z(#*\)"' end='"\z1' contains=@Spell + +" Match attributes with either arbitrary syntax or special highlighting for +" derives. We still highlight strings and comments inside of the attribute. +syn region rustAttribute start="#!\?\[" end="\]" contains=@rustAttributeContents,rustAttributeParenthesizedParens,rustAttributeParenthesizedCurly,rustAttributeParenthesizedBrackets,rustDerive +syn region rustAttributeParenthesizedParens matchgroup=rustAttribute start="\w\%(\w\)*("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeParenthesizedCurly matchgroup=rustAttribute start="\w\%(\w\)*{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeParenthesizedBrackets matchgroup=rustAttribute start="\w\%(\w\)*\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn region rustAttributeBalancedParens matchgroup=rustAttribute start="("rs=e end=")"re=s transparent contained contains=rustAttributeBalancedParens,@rustAttributeContents +syn region rustAttributeBalancedCurly matchgroup=rustAttribute start="{"rs=e end="}"re=s transparent contained contains=rustAttributeBalancedCurly,@rustAttributeContents +syn region rustAttributeBalancedBrackets matchgroup=rustAttribute start="\["rs=e end="\]"re=s transparent contained contains=rustAttributeBalancedBrackets,@rustAttributeContents +syn cluster rustAttributeContents contains=rustString,rustCommentLine,rustCommentBlock,rustCommentLineDocError,rustCommentBlockDocError +syn region rustDerive start="derive(" end=")" contained contains=rustDeriveTrait +" This list comes from src/libsyntax/ext/deriving/mod.rs +" Some are deprecated (Encodable, Decodable) or to be removed after a new snapshot (Show). +syn keyword rustDeriveTrait contained Clone Hash RustcEncodable RustcDecodable Encodable Decodable PartialEq Eq PartialOrd Ord Rand Show Debug Default FromPrimitive Send Sync Copy + +" dyn keyword: It's only a keyword when used inside a type expression, so +" we make effort here to highlight it only when Rust identifiers follow it +" (not minding the case of pre-2018 Rust where a path starting with :: can +" follow). +" +" This is so that uses of dyn variable names such as in 'let &dyn = &2' +" and 'let dyn = 2' will not get highlighted as a keyword. +syn match rustKeyword "\/ contains=rustGenericLifetimeCandidate +syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime + +"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting +syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" +syn match rustLabel display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*:" +syn match rustLabel display "\%(\<\%(break\|continue\)\s*\)\@<=\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" +syn match rustCharacterInvalid display contained /b\?'\zs[\n\r\t']\ze'/ +" The groups negated here add up to 0-255 but nothing else (they do not seem to go beyond ASCII). +syn match rustCharacterInvalidUnicode display contained /b'\zs[^[:cntrl:][:graph:][:alnum:][:space:]]\ze'/ +syn match rustCharacter /b'\([^\\]\|\\\(.\|x\x\{2}\)\)'/ contains=rustEscape,rustEscapeError,rustCharacterInvalid,rustCharacterInvalidUnicode +syn match rustCharacter /'\([^\\]\|\\\(.\|x\x\{2}\|u{\%(\x_*\)\{1,6}}\)\)'/ contains=rustEscape,rustEscapeUnicode,rustEscapeError,rustCharacterInvalid + +syn match rustShebang /\%^#![^[].*/ +syn region rustCommentLine start="//" end="$" contains=rustTodo,@Spell +syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell +syn region rustCommentLineDocError start="//\%(//\@!\|!\)" end="$" contains=rustTodo,@Spell contained +syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell +syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNest,rustCommentBlockDocRustCode,@Spell +syn region rustCommentBlockDocError matchgroup=rustCommentBlockDocError start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained +syn region rustCommentBlockNest matchgroup=rustCommentBlock start="/\*" end="\*/" contains=rustTodo,rustCommentBlockNest,@Spell contained transparent +syn region rustCommentBlockDocNest matchgroup=rustCommentBlockDoc start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNest,@Spell contained transparent +syn region rustCommentBlockDocNestError matchgroup=rustCommentBlockDocError start="/\*" end="\*/" contains=rustTodo,rustCommentBlockDocNestError,@Spell contained transparent + +" FIXME: this is a really ugly and not fully correct implementation. Most +" importantly, a case like ``/* */*`` should have the final ``*`` not being in +" a comment, but in practice at present it leaves comments open two levels +" deep. But as long as you stay away from that particular case, I *believe* +" the highlighting is correct. Due to the way Vim's syntax engine works +" (greedy for start matches, unlike Rust's tokeniser which is searching for +" the earliest-starting match, start or end), I believe this cannot be solved. +" Oh you who would fix it, don't bother with things like duplicating the Block +" rules and putting ``\*\@:p:h/rust.vim + unlet b:current_syntax_embed + + " Currently regions marked as ``` will not get + " highlighted at all. In the future, we can do as vim-markdown does and + " highlight with the other syntax. But for now, let's make sure we find + " the closing block marker, because the rules below won't catch it. + syn region rustCommentLinesDocNonRustCode matchgroup=rustCommentDocCodeFence start='^\z(\s*//[!/]\s*```\).\+$' end='^\z1$' keepend contains=rustCommentLineDoc + + " We borrow the rules from rust’s src/librustdoc/html/markdown.rs, so that + " we only highlight as Rust what it would perceive as Rust (almost; it’s + " possible to trick it if you try hard, and indented code blocks aren’t + " supported because Markdown is a menace to parse and only mad dogs and + " Englishmen would try to handle that case correctly in this syntax file). + syn region rustCommentLinesDocRustCode matchgroup=rustCommentDocCodeFence start='^\z(\s*//[!/]\s*```\)[^A-Za-z0-9_-]*\%(\%(should_panic\|no_run\|ignore\|allow_fail\|rust\|test_harness\|compile_fail\|E\d\{4}\|edition201[58]\)\%([^A-Za-z0-9_-]\+\|$\)\)*$' end='^\z1$' keepend contains=@RustCodeInComment,rustCommentLineDocLeader + syn region rustCommentBlockDocRustCode matchgroup=rustCommentDocCodeFence start='^\z(\%(\s*\*\)\?\s*```\)[^A-Za-z0-9_-]*\%(\%(should_panic\|no_run\|ignore\|allow_fail\|rust\|test_harness\|compile_fail\|E\d\{4}\|edition201[58]\)\%([^A-Za-z0-9_-]\+\|$\)\)*$' end='^\z1$' keepend contains=@RustCodeInComment,rustCommentBlockDocStar + " Strictly, this may or may not be correct; this code, for example, would + " mishighlight: + " + " /** + " ```rust + " println!("{}", 1 + " * 1); + " ``` + " */ + " + " … but I don’t care. Balance of probability, and all that. + syn match rustCommentBlockDocStar /^\s*\*\s\?/ contained + syn match rustCommentLineDocLeader "^\s*//\%(//\@!\|!\)" contained +endif + +" Default highlighting {{{1 +hi def link rustDecNumber rustNumber +hi def link rustHexNumber rustNumber +hi def link rustOctNumber rustNumber +hi def link rustBinNumber rustNumber +hi def link rustIdentifierPrime rustIdentifier +hi def link rustTrait rustType +hi def link rustDeriveTrait rustTrait + +hi def link rustMacroRepeatDelimiters Macro +hi def link rustMacroVariable Define +hi def link rustSigil StorageClass +hi def link rustEscape Special +hi def link rustEscapeUnicode rustEscape +hi def link rustEscapeError Error +hi def link rustStringContinuation Special +hi def link rustString String +hi def link rustStringDelimiter String +hi def link rustCharacterInvalid Error +hi def link rustCharacterInvalidUnicode rustCharacterInvalid +hi def link rustCharacter Character +hi def link rustNumber Number +hi def link rustBoolean Boolean +hi def link rustEnum rustType +hi def link rustEnumVariant rustConstant +hi def link rustConstant Constant +hi def link rustSelf Constant +hi def link rustFloat Float +hi def link rustArrowCharacter rustOperator +hi def link rustOperator Operator +hi def link rustKeyword Keyword +hi def link rustDynKeyword rustKeyword +hi def link rustTypedef Keyword " More precise is Typedef, but it doesn't feel right for Rust +hi def link rustStructure Keyword " More precise is Structure +hi def link rustUnion rustStructure +hi def link rustExistential rustKeyword +hi def link rustPubScopeDelim Delimiter +hi def link rustPubScopeCrate rustKeyword +hi def link rustSuper rustKeyword +hi def link rustUnsafeKeyword Exception +hi def link rustReservedKeyword Error +hi def link rustRepeat Conditional +hi def link rustConditional Conditional +hi def link rustIdentifier Identifier +hi def link rustCapsIdent rustIdentifier +hi def link rustModPath Include +hi def link rustModPathSep Delimiter +hi def link rustFunction Function +hi def link rustFuncName Function +hi def link rustFuncCall Function +hi def link rustShebang Comment +hi def link rustCommentLine Comment +hi def link rustCommentLineDoc SpecialComment +hi def link rustCommentLineDocLeader rustCommentLineDoc +hi def link rustCommentLineDocError Error +hi def link rustCommentBlock rustCommentLine +hi def link rustCommentBlockDoc rustCommentLineDoc +hi def link rustCommentBlockDocStar rustCommentBlockDoc +hi def link rustCommentBlockDocError Error +hi def link rustCommentDocCodeFence rustCommentLineDoc +hi def link rustAssert PreCondit +hi def link rustPanic PreCondit +hi def link rustMacro Macro +hi def link rustType Type +hi def link rustTodo Todo +hi def link rustAttribute PreProc +hi def link rustDerive PreProc +hi def link rustDefault StorageClass +hi def link rustStorage StorageClass +hi def link rustObsoleteStorage Error +hi def link rustLifetime Special +hi def link rustLabel Label +hi def link rustExternCrate rustKeyword +hi def link rustObsoleteExternMod Error +hi def link rustQuestionMark Special +hi def link rustAsync rustKeyword +hi def link rustAwait rustKeyword +hi def link rustAsmDirSpec rustKeyword +hi def link rustAsmSym rustKeyword +hi def link rustAsmOptions rustKeyword +hi def link rustAsmOptionsKey rustAttribute + +" Other Suggestions: +" hi rustAttribute ctermfg=cyan +" hi rustDerive ctermfg=cyan +" hi rustAssert ctermfg=yellow +" hi rustPanic ctermfg=red +" hi rustMacro ctermfg=magenta + +syn sync minlines=200 +syn sync maxlines=500 + +let b:current_syntax = "rust" + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/syntax_checkers/rust/cargo.vim b/sources_non_forked/rust.vim/syntax_checkers/rust/cargo.vim new file mode 100644 index 00000000..f7b6953c --- /dev/null +++ b/sources_non_forked/rust.vim/syntax_checkers/rust/cargo.vim @@ -0,0 +1,93 @@ +" Vim syntastic plugin +" Language: Rust +" Maintainer: Julien Levesy +" +" See for details on how to add an external Syntastic checker: +" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external + +if exists("g:loaded_syntastic_rust_cargo_checker") + finish +endif + +let g:loaded_syntastic_rust_cargo_checker = 1 + +" Force syntastic to call cargo without a specific file name +let g:syntastic_rust_cargo_fname = "" + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_rust_cargo_IsAvailable() dict + if exists("*syntastic#util#getVersion") + echom "rust.vim: version of Syntastic is too old. Needs to be at least 3.7.0." + return v:false + endif + + return executable(self.getExec()) && + \ syntastic#util#versionIsAtLeast(self.getVersion(), [0, 16, 0]) +endfunction + +function! SyntaxCheckers_rust_cargo_GetLocList() dict + let makeprg = self.makeprgBuild({ "args": "check" }) + let l:root_cargo_toml = cargo#nearestRootCargo(0) + let l:nearest_cargo_toml = cargo#nearestCargo(0) + let b:rust_recent_root_cargo_toml = l:root_cargo_toml + let b:rust_recent_nearest_cargo_toml = l:nearest_cargo_toml + + " All pathname prints are relative to the Cargo.toml of the workspace, if + " there is a workspace, otherwise they are relative to the Cargo.toml of + " the single crate. Where to actually execute under these varying + " circumtances 'cargo' is determined here, and controlled by + " configuration. + + if rust#GetConfigVar('rust_cargo_avoid_whole_workspace', 1) + if l:root_cargo_toml !=# l:nearest_cargo_toml + let makeprg = "cd " . fnamemodify(l:nearest_cargo_toml, ":p:h") + \ . " && " . makeprg + endif + else + let makeprg = "cd " . fnamemodify(l:root_cargo_toml, ":p:h") + \ . " && " . makeprg + endif + + let l:check_all_targets = rust#GetConfigVar('rust_cargo_check_all_targets', 0) + let l:check_all_features = rust#GetConfigVar('rust_cargo_check_all_features', 0) + let l:check_examples = rust#GetConfigVar('rust_cargo_check_examples', 0) + let l:check_tests = rust#GetConfigVar('rust_cargo_check_tests', 0) + let l:check_benches = rust#GetConfigVar('rust_cargo_check_benches', 0) + + let makeprg = makeprg. ' ' + \ . (l:check_all_targets ? ' --all-targets' : '') + \ . (l:check_all_features ? ' --all-features' : '') + \ . (l:check_benches ? ' --benches' : '') + \ . (l:check_examples ? ' --examples' : '') + \ . (l:check_tests ? ' --tests' : '') + + " Ignored patterns, and blank lines + let errorformat = + \ '%-G,' . + \ '%-Gerror: aborting %.%#,' . + \ '%-Gerror: Could not compile %.%#,' + + " Meaningful lines (errors, notes, warnings, contextual information) + let errorformat .= + \ '%Eerror: %m,' . + \ '%Eerror[E%n]: %m,' . + \ '%Wwarning: %m,' . + \ '%Inote: %m,' . + \ '%C %#--> %f:%l:%c' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'cwd': fnamemodify(l:root_cargo_toml, ":p:h:."), + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'rust', + \ 'name': 'cargo'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/syntax_checkers/rust/rustc.vim b/sources_non_forked/rust.vim/syntax_checkers/rust/rustc.vim new file mode 100644 index 00000000..d60a3d3a --- /dev/null +++ b/sources_non_forked/rust.vim/syntax_checkers/rust/rustc.vim @@ -0,0 +1,54 @@ +" Vim syntastic plugin +" Language: Rust +" Maintainer: Andrew Gallant +" +" See for details on how to add an external Syntastic checker: +" https://github.com/scrooloose/syntastic/wiki/Syntax-Checker-Guide#external + +if exists("g:loaded_syntastic_rust_rustc_checker") + finish +endif +let g:loaded_syntastic_rust_rustc_checker = 1 + +" vint: -ProhibitAbbreviationOption +let s:save_cpo = &cpo +set cpo&vim +" vint: +ProhibitAbbreviationOption + +function! SyntaxCheckers_rust_rustc_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + " Old errorformat (before nightly 2016/08/10) + let errorformat = + \ '%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,' . + \ '%W%f:%l:%c: %\d%#:%\d%# %.%\{-}warning:%.%\{-} %m,' . + \ '%C%f:%l %m' + + " New errorformat (after nightly 2016/08/10) + let errorformat .= + \ ',' . + \ '%-G,' . + \ '%-Gerror: aborting %.%#,' . + \ '%-Gerror: Could not compile %.%#,' . + \ '%Eerror: %m,' . + \ '%Eerror[E%n]: %m,' . + \ '%-Gwarning: the option `Z` is unstable %.%#,' . + \ '%Wwarning: %m,' . + \ '%Inote: %m,' . + \ '%C %#--> %f:%l:%c' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'rust', + \ 'name': 'rustc'}) + +" vint: -ProhibitAbbreviationOption +let &cpo = s:save_cpo +unlet s:save_cpo +" vint: +ProhibitAbbreviationOption + +" vim: set et sw=4 sts=4 ts=8: diff --git a/sources_non_forked/rust.vim/test/.gitignore b/sources_non_forked/rust.vim/test/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/sources_non_forked/rust.vim/test/Dockerfile b/sources_non_forked/rust.vim/test/Dockerfile new file mode 100644 index 00000000..c84c49e9 --- /dev/null +++ b/sources_non_forked/rust.vim/test/Dockerfile @@ -0,0 +1,34 @@ +# This is brought as reference, to be able to reproduce a new image + +FROM alonid/vim-testbed:10 + +RUN install_vim -tag v7.4.052 -name vim74-trusty -build \ + -tag v8.0.1850 -name vim80 -build \ + -tag v8.1.0105 -name vim81 -build \ + -tag neovim:v0.1.7 -build \ + -tag neovim:v0.2.2 -build + +ENV PACKAGES="\ + bash \ + git \ + python \ + python2-pip \ + curl \ +" + +RUN dnf install -y $PACKAGES + +RUN pip install vim-vint==0.3.19 + +RUN export HOME=/rust ; mkdir $HOME ; curl https://sh.rustup.rs -sSf | sh -s -- -y + +RUN chown vimtest.vimtest -R /rust + +RUN (dnf remove -y gcc \*-devel ; \ + dnf install -y gpm msgpack libvterm libtermkey unibilium ) || true +RUN dnf clean all + +RUN echo "export PATH=~/.cargo/bin:$PATH" >> ~/.bashrc + +RUN git clone https://github.com/da-x/vader.vim vader && \ + cd vader && git checkout v2017-12-26 diff --git a/sources_non_forked/rust.vim/test/coverage.vader b/sources_non_forked/rust.vim/test/coverage.vader new file mode 100644 index 00000000..84734e7d --- /dev/null +++ b/sources_non_forked/rust.vim/test/coverage.vader @@ -0,0 +1,24 @@ +Given rust (Some Rust code): + fn main() { + println!("Hello World\n") + } + +Execute (RustInfo - call it to see that it works): + redir => m + silent RustInfo + redir END + Log m + +Execute (RustEmitAsm - see that we actually get assembly output): + silent! w test.rs + silent! e! test.rs + redir => m + silent! RustEmitAsm + redir END + AssertEqual 'asm', &filetype + normal! ggVGy:q + AssertEqual 1,(@" =~# '\V.section') + bd + call delete('test.rs') + +# TODO: a lot more tests diff --git a/sources_non_forked/rust.vim/test/indent.vader b/sources_non_forked/rust.vim/test/indent.vader new file mode 100644 index 00000000..91f65806 --- /dev/null +++ b/sources_non_forked/rust.vim/test/indent.vader @@ -0,0 +1,292 @@ +Given rust: + fn main() { + let a = 2; + println!("Hello World\n") + } + +Do: + vip= + +Expect rust (very basic indentation result): + fn main() { + let a = 2; + println!("Hello World\n") + } + +############################################ +# Issue #195 + +Given rust: + fn main() { + let paths: Vec<_> = ({ + fs::read_dir("test_data") + .unwrap() + .cloned() + }) + .collect(); + + println!("Hello World\n"); + } + +Do: + /collect\ + ostatement();\\ + +Expect rust (issue #195): + fn main() { + let paths: Vec<_> = ({ + fs::read_dir("test_data") + .unwrap() + .cloned() + }) + .collect(); + statement(); + + println!("Hello World\n"); + } + +############################################ +# Issue #189 + +Given rust: + impl X for { + pub fn get(&self, key: &Q) -> Option> + where + K: Borrow, + Q: Ord + ?Sized, + { + self.inner.get(key).map(Entry::new) + } + } + +Do: + vip= + +Expect rust (issue #189): + impl X for { + pub fn get(&self, key: &Q) -> Option> + where + K: Borrow, + Q: Ord + ?Sized, + { + self.inner.get(key).map(Entry::new) + } + } + +############################################ +# Issue #189b + +Given rust: + impl X for { + pub fn get(&self, key: &Q) -> Option> + where + K: Borrow, + Q: Ord + ?Sized + { + self.inner.get(key).map(Entry::new) + } + } + +Do: + vip= + +Expect rust (issue #189b): + impl X for { + pub fn get(&self, key: &Q) -> Option> + where + K: Borrow, + Q: Ord + ?Sized + { + self.inner.get(key).map(Entry::new) + } + } + +############################################ +# Issue #189c + +Given rust: + impl X for { + pub fn get(&self, key: &Q) -> Option> + where K: Borrow, Q: Ord + ?Sized + { + self.inner.get(key).map(Entry::new) + } + } + +Do: + vip= + +Expect rust (issue #189b): + impl X for { + pub fn get(&self, key: &Q) -> Option> + where K: Borrow, Q: Ord + ?Sized + { + self.inner.get(key).map(Entry::new) + } + } + + +############################################ +# Issue #149 + +Given rust: + fn test() { + let t = "a + wah"; + } + +Do: + /wah\ + i#\\ + /;\o + statement();\\ + +# Disabled +# Expect rust (issue #149): + fn test() { + let t = "a + #wah"; + statement(); + } + + +############################################ +# Issue #77 + +Given rust: + fn test() { + } + +Do: + of(x, y,\z);\ + f((x, y),\z);\ + +# Disabled +# Expect rust (issue #77): + fn test() { + f(x, y, + z); + f((x, y), + z); + + } + +############################################ +# Issue #44 + +Given rust: + fn main() { + a + + let philosophers = vec![ + Philosopher::new("Judith Butler"), + Philosopher::new("Gilles Deleuze"), + Philosopher::new("Karl Marx"), + Philosopher::new("Emma Goldman"), + Philosopher::new("Michel Foucault"), + ]; + } + +Do: + /let\ + vip= + +# Disabled +# Expect rust (issue #44): + fn main() { + a + + let philosophers = vec![ + Philosopher::new("Judith Butler"), + Philosopher::new("Gilles Deleuze"), + Philosopher::new("Karl Marx"), + Philosopher::new("Emma Goldman"), + Philosopher::new("Michel Foucault"), + ]; + } + +############################################ +# Issue #5 + +Given rust: + fn f() { + if x && + y { + } + } + +Do: + vip= + +Expect rust (issue #5): + fn f() { + if x && + y { + } + } + +############################################ +# Issue #366 + +Given rust: + fn f() { + g(|_| { + h(); + }) + .unwrap(); + h(); + } + +Do: + vip= + +Expect rust (issue #366): + fn f() { + g(|_| { + h(); + }) + .unwrap(); + h(); + } + +Given rust: + fn f() { + let a = g(|_| { + h(); + }) + .unwrap(); + h(); + } + +Do: + vip= + +Expect rust (issue #366, variation #2): + fn f() { + let a = g(|_| { + h(); + }) + .unwrap(); + h(); + } + +############################################ + +Given rust: + fn f() { + let mut state = State::new( + backend, + header.clone(), + ).expect("Something"); + } + +Do: + vip= + +Expect rust (Trailing comma in call): + fn f() { + let mut state = State::new( + backend, + header.clone(), + ).expect("Something"); + } diff --git a/sources_non_forked/rust.vim/test/run-tests b/sources_non_forked/rust.vim/test/run-tests new file mode 100644 index 00000000..9e11ba5c --- /dev/null +++ b/sources_non_forked/rust.vim/test/run-tests @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +import os +import sys + +REPO = "alonid/vim-testbed" +TAG = "10-rust.vim" +IMAGE = "%s:%s" % (REPO, TAG) + +class Error(Exception): + pass + +def system(cmd, capture=False, ok_fail=False): + if capture: + f = os.popen(cmd) + d = f.read() + return d + + res = os.system(cmd) + if res != 0: + if ok_fail: + return res + + raise Error("Error executing: %s" % (cmd, )) + return 0 + +def root(): + return os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + +def prep(): + d = os.path.join(root(), "test") + for i in [".cargo", ".rustup", ".multirust"]: + l = os.path.join(d, i) + if not os.path.lexists(l): + os.symlink("/rust/" + i, l) + + l = os.path.join(root(), "test/.vimrc") + if not os.path.lexists(l): + os.symlink("vimrc", l) + + if not os.path.exists(os.path.join(d, ".profile")): + f = open(os.path.join(d, ".profile"), "w") + f.write('export PATH="$HOME/.cargo/bin:$PATH"\n') + f.close() + +def docker_run(cmd, interactive=False, ok_fail=False): + prep() + d = root() + params = "-v %s:/testplugin -v %s/test:/home/vimtest" % (d, d) + params += " -e HOME=/home/vimtest" + if not interactive: + params += " -a stderr" + params += " -e VADER_OUTPUT_FILE=/dev/stderr" + params += " -u %s" % (os.getuid(), ) + params += " -w /testplugin" + if interactive: + interactive_str = "-it" + else: + interactive_str = "" + return system("docker run %s --rm %s %s %s" % (interactive_str, params, IMAGE, cmd), + ok_fail=ok_fail) + +def image_exists(): + r = system("docker images -q %s" % (IMAGE, ), capture=True) + return len(r.strip().splitlines()) >= 1 + +def tests_on_docker(): + res = docker_run("bash -lc 'python /home/vimtest/run-tests inside-docker'", ok_fail=True) + if res == 0: + print("Tests OK") + else: + print("Tests Failed") + sys.exit(1) + +def inside_docker(): + res = system("/vim-build/bin/vim80 --not-a-term '+Vader! test/*.vader'", ok_fail=True) + if res != 0: + sys.exit(1) + +def run_with_vimrc(vimrc): + res = system("vim -u %s --not-a-term '+Vader! test/*.vader'" % (vimrc, ), ok_fail=True) + if res != 0: + sys.exit(1) + +def main(): + if sys.argv[1:] == ["inside-docker"]: + inside_docker() + return + + if sys.argv[1:2] == ["run-with-vimrc"]: + run_with_vimrc(sys.argv[2]) + return + + if not image_exists(): + print("Need to take image from remote") + system("docker pull %s" % (IMAGE, )) + + if "-i" in sys.argv[1:]: + docker_run("bash -l", interactive=True) + return + + tests_on_docker() + +if __name__ == "__main__": + main() diff --git a/sources_non_forked/rust.vim/test/sample.rs b/sources_non_forked/rust.vim/test/sample.rs new file mode 100644 index 00000000..e69de29b diff --git a/sources_non_forked/rust.vim/test/vimrc b/sources_non_forked/rust.vim/test/vimrc new file mode 100644 index 00000000..f7f1533d --- /dev/null +++ b/sources_non_forked/rust.vim/test/vimrc @@ -0,0 +1,30 @@ +" vint: -ProhibitSetNoCompatible +" + +set nocompatible +filetype off + +" This script is currently designed to be run from within Docker, the +" following paths are intrinsic to the container: +source /rtp.vim + +" Paths need prepending (instead of what is originally done +" in vim-testbed) in order to supersede the rust.vim that is +" supplied with Vim. +exec 'set runtimepath=/vader,/testplugin,' . &runtimepath +cd /testplugin + +filetype plugin indent on +syntax on + +set nocompatible +set tabstop=8 +set softtabstop=4 +set shiftwidth=4 +set expandtab +set backspace=2 +set nofoldenable +set foldmethod=syntax +set foldlevelstart=10 +set foldnestmax=10 +set ttimeoutlen=0 diff --git a/sources_non_forked/rust.vim/triagebot.toml b/sources_non_forked/rust.vim/triagebot.toml new file mode 100644 index 00000000..fa0824ac --- /dev/null +++ b/sources_non_forked/rust.vim/triagebot.toml @@ -0,0 +1 @@ +[assign] diff --git a/sources_non_forked/tabular/.gitignore b/sources_non_forked/tabular/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/tabular/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/tabular/LICENSE.md b/sources_non_forked/tabular/LICENSE.md new file mode 100644 index 00000000..2cc76e9d --- /dev/null +++ b/sources_non_forked/tabular/LICENSE.md @@ -0,0 +1,24 @@ +Copyright (c) 2016, Matthew J. Wozniski +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of the contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/sources_non_forked/tabular/README.md b/sources_non_forked/tabular/README.md new file mode 100644 index 00000000..adbfeb00 --- /dev/null +++ b/sources_non_forked/tabular/README.md @@ -0,0 +1,29 @@ +Tabular +============== +Sometimes, it's useful to line up text. Naturally, it's nicer to have the +computer do this for you, since aligning things by hand quickly becomes +unpleasant. While there are other plugins for aligning text, the ones I've +tried are either impossibly difficult to understand and use, or too simplistic +to handle complicated tasks. This plugin aims to make the easy things easy +and the hard things possible, without providing an unnecessarily obtuse +interface. It's still a work in progress, and criticisms are welcome. + +See [Aligning Text with Tabular.vim](http://vimcasts.org/episodes/aligning-text-with-tabular-vim/) +for a screencast that shows how Tabular.vim works. + +See [doc/Tabular.txt](http://raw.github.com/godlygeek/tabular/master/doc/Tabular.txt) +for detailed documentation. + +Installation +============== +If you don't have a preferred installation method, I recommend installing +[pathogen.vim](https://github.com/tpope/vim-pathogen), and then simply +copy and paste: + + mkdir -p ~/.vim/bundle + cd ~/.vim/bundle + git clone git://github.com/godlygeek/tabular.git + +Once help tags have been generated (either using Pathogen's `:Helptags` +command, or by pointing vim's `:helptags` command at the directory where you +installed Tabular), you can view the manual with `:help tabular`. diff --git a/sources_non_forked/tabular/after/plugin/TabularMaps.vim b/sources_non_forked/tabular/after/plugin/TabularMaps.vim new file mode 100644 index 00000000..998346fc --- /dev/null +++ b/sources_non_forked/tabular/after/plugin/TabularMaps.vim @@ -0,0 +1,73 @@ +" Copyright (c) 2016, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +if !exists(':Tabularize') || get(g:, 'no_default_tabular_maps', 0) + finish " Tabular.vim wasn't loaded or the default maps are unwanted +endif + +let s:save_cpo = &cpo +set cpo&vim + +AddTabularPattern! assignment /[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=/l1r1 +AddTabularPattern! two_spaces / /l0 + +AddTabularPipeline! multiple_spaces / / map(a:lines, "substitute(v:val, ' *', ' ', 'g')") | tabular#TabularizeStrings(a:lines, ' ', 'l0') + +AddTabularPipeline! argument_list /(.*)/ map(a:lines, 'substitute(v:val, ''\s*\([(,)]\)\s*'', ''\1'', ''g'')') + \ | tabular#TabularizeStrings(a:lines, '[(,)]', 'l0') + \ | map(a:lines, 'substitute(v:val, ''\(\s*\),'', '',\1 '', "g")') + \ | map(a:lines, 'substitute(v:val, ''\s*)'', ")", "g")') + +function! SplitCDeclarations(lines) + let rv = [] + for line in a:lines + " split the line into declaractions + let split = split(line, '\s*[,;]\s*') + " separate the type from the first declaration + let type = substitute(split[0], '\%(\%([&*]\s*\)*\)\=\k\+$', '', '') + " add the ; back on every declaration + call map(split, 'v:val . ";"') + " add the first element to the return as-is, and remove it from the list + let rv += [ remove(split, 0) ] + " transform the other elements by adding the type on at the beginning + call map(split, 'type . v:val') + " and add them all to the return + let rv += split + endfor + return rv +endfunction + +AddTabularPipeline! split_declarations /,.*;/ SplitCDeclarations(a:lines) + +AddTabularPattern! ternary_operator /^.\{-}\zs?\|:/l1 + +AddTabularPattern! cpp_io /<<\|>>/l1 + +AddTabularPattern! pascal_assign /:=/l1 + +AddTabularPattern! trailing_c_comments /\/\*\|\*\/\|\/\//l1 + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tabular/autoload/tabular.vim b/sources_non_forked/tabular/autoload/tabular.vim new file mode 100644 index 00000000..f60a73ca --- /dev/null +++ b/sources_non_forked/tabular/autoload/tabular.vim @@ -0,0 +1,409 @@ +" Tabular: Align columnar data using regex-designated column boundaries +" Maintainer: Matthew Wozniski (godlygeek@gmail.com) +" Date: Thu, 03 May 2012 20:49:32 -0400 +" Version: 1.0 +" +" Long Description: +" Sometimes, it's useful to line up text. Naturally, it's nicer to have the +" computer do this for you, since aligning things by hand quickly becomes +" unpleasant. While there are other plugins for aligning text, the ones I've +" tried are either impossibly difficult to understand and use, or too simplistic +" to handle complicated tasks. This plugin aims to make the easy things easy +" and the hard things possible, without providing an unnecessarily obtuse +" interface. It's still a work in progress, and criticisms are welcome. +" +" License: +" Copyright (c) 2012, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" Stupid vimscript crap {{{1 +let s:savecpo = &cpo +set cpo&vim + +" Private Functions {{{1 + +" Return the number of bytes in a string after expanding tabs to spaces. {{{2 +" This expansion is done based on the current value of 'tabstop' +if exists('*strdisplaywidth') + " Needs vim 7.3 + let s:Strlen = function("strdisplaywidth") +else + function! s:Strlen(string) + " Implement the tab handling part of strdisplaywidth for vim 7.2 and + " earlier - not much that can be done about handling doublewidth + " characters. + let rv = 0 + let i = 0 + + for char in split(a:string, '\zs') + if char == "\t" + let rv += &ts - i + let i = 0 + else + let rv += 1 + let i = (i + 1) % &ts + endif + endfor + + return rv + endfunction +endif + +" Align a string within a field {{{2 +" These functions do not trim leading and trailing spaces. + +" Right align 'string' in a field of size 'fieldwidth' +function! s:Right(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + return matchstr(a:string, '^\s*') . repeat(" ", spaces) . substitute(a:string, '^\s*', '', '') +endfunction + +" Left align 'string' in a field of size 'fieldwidth' +function! s:Left(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + return a:string . repeat(" ", spaces) +endfunction + +" Center align 'string' in a field of size 'fieldwidth' +function! s:Center(string, fieldwidth) + let spaces = a:fieldwidth - s:Strlen(a:string) + let right = spaces / 2 + let left = right + (right * 2 != spaces) + return repeat(" ", left) . a:string . repeat(" ", right) +endfunction + +" Remove spaces around a string {{{2 + +" Remove all trailing spaces from a string. +function! s:StripTrailingSpaces(string) + return matchstr(a:string, '^.\{-}\ze\s*$') +endfunction + +" Remove all leading spaces from a string. +function! s:StripLeadingSpaces(string) + return matchstr(a:string, '^\s*\zs.*$') +endfunction + +" Split a string into fields and delimiters {{{2 +" Like split(), but include the delimiters as elements +" All odd numbered elements are delimiters +" All even numbered elements are non-delimiters (including zero) +function! s:SplitDelim(string, delim) + let rv = [] + let beg = 0 + + let len = len(a:string) + let searchoff = 0 + + while 1 + let mid = match(a:string, a:delim, beg + searchoff, 1) + if mid == -1 || mid == len + break + endif + + let matchstr = matchstr(a:string, a:delim, beg + searchoff, 1) + let length = strlen(matchstr) + + if length == 0 && beg == mid + " Zero-length match for a zero-length delimiter - advance past it + let searchoff += 1 + continue + endif + + if beg == mid + let rv += [ "" ] + else + let rv += [ a:string[beg : mid-1] ] + endif + + let rv += [ matchstr ] + + let beg = mid + length + let searchoff = 0 + endwhile + + let rv += [ strpart(a:string, beg) ] + + return rv +endfunction + +" Replace lines from `start' to `start + len - 1' with the given strings. {{{2 +" If more lines are needed to show all strings, they will be added. +" If there are too few strings to fill all lines, lines will be removed. +function! s:SetLines(start, len, strings) + if a:start > line('$') + 1 || a:start < 1 + throw "Invalid start line!" + endif + + if len(a:strings) > a:len + let fensave = &fen + let view = winsaveview() + call append(a:start + a:len - 1, repeat([''], len(a:strings) - a:len)) + call winrestview(view) + let &fen = fensave + elseif len(a:strings) < a:len + let fensave = &fen + let view = winsaveview() + sil exe (a:start + len(a:strings)) . ',' . (a:start + a:len - 1) . 'd_' + call winrestview(view) + let &fen = fensave + endif + + call setline(a:start, a:strings) +endfunction + +" Runs the given commandstring argument as an expression. {{{2 +" The commandstring expression is expected to reference the a:lines argument. +" If the commandstring expression returns a list the items of that list will +" replace the items in a:lines, otherwise the expression is assumed to have +" modified a:lines itself. +function! s:FilterString(lines, commandstring) + exe 'let rv = ' . a:commandstring + + if type(rv) == type(a:lines) && rv isnot a:lines + call filter(a:lines, 0) + call extend(a:lines, rv) + endif +endfunction + +" Public API {{{1 + +if !exists("g:tabular_default_format") + let g:tabular_default_format = "l1" +endif + +let s:formatelempat = '\%([lrc]\d\+\)' + +function! tabular#ElementFormatPattern() + return s:formatelempat +endfunction + +" Given a list of strings and a delimiter, split each string on every +" occurrence of the delimiter pattern, format each element according to either +" the provided format (optional) or the default format, and join them back +" together with enough space padding to guarantee that the nth delimiter of +" each string is aligned. +function! tabular#TabularizeStrings(strings, delim, ...) + if a:0 > 1 + echoerr "TabularizeStrings accepts only 2 or 3 arguments (got ".(a:0+2).")" + return 1 + endif + + let formatstr = (a:0 ? a:1 : g:tabular_default_format) + + if formatstr !~? s:formatelempat . '\+' + echoerr "Tabular: Invalid format \"" . formatstr . "\" specified!" + return 1 + endif + + let format = split(formatstr, s:formatelempat . '\zs') + + let lines = map(a:strings, 's:SplitDelim(v:val, a:delim)') + + " Strip spaces + " - Only from non-delimiters; spaces in delimiters must have been matched + " intentionally + " - Don't strip leading spaces from the first element; we like indenting. + for line in lines + if len(line) == 1 && s:do_gtabularize + continue " Leave non-matching lines unchanged for GTabularize + endif + + if line[0] !~ '^\s*$' + let line[0] = s:StripTrailingSpaces(line[0]) + endif + if len(line) >= 3 + for i in range(2, len(line)-1, 2) + let line[i] = s:StripLeadingSpaces(s:StripTrailingSpaces(line[i])) + endfor + endif + endfor + + " Find the max length of each field + let maxes = [] + for line in lines + if len(line) == 1 && s:do_gtabularize + continue " non-matching lines don't affect field widths for GTabularize + endif + + for i in range(len(line)) + if i == len(maxes) + let maxes += [ s:Strlen(line[i]) ] + else + let maxes[i] = max( [ maxes[i], s:Strlen(line[i]) ] ) + endif + endfor + endfor + + let lead_blank = empty(filter(copy(lines), 'v:val[0] =~ "\\S"')) + + " Concatenate the fields, according to the format pattern. + for idx in range(len(lines)) + let line = lines[idx] + + if len(line) == 1 && s:do_gtabularize + let lines[idx] = line[0] " GTabularize doesn't change non-matching lines + continue + endif + + for i in range(len(line)) + let how = format[i % len(format)][0] + let pad = format[i % len(format)][1:-1] + + if how =~? 'l' + let field = s:Left(line[i], maxes[i]) + elseif how =~? 'r' + let field = s:Right(line[i], maxes[i]) + elseif how =~? 'c' + let field = s:Center(line[i], maxes[i]) + endif + + let line[i] = field . (lead_blank && i == 0 ? '' : repeat(" ", pad)) + endfor + + let lines[idx] = s:StripTrailingSpaces(join(line, '')) + endfor +endfunction + +" Apply 0 or more filters, in sequence, to selected text in the buffer {{{2 +" The lines to be filtered are determined as follows: +" If the function is called with a range containing multiple lines, then +" those lines will be used as the range. +" If the function is called with no range or with a range of 1 line, then +" if GTabularize mode is being used, +" the range will not be adjusted +" if "includepat" is not specified, +" that 1 line will be filtered, +" if "includepat" is specified and that line does not match it, +" no lines will be filtered +" if "includepat" is specified and that line does match it, +" all contiguous lines above and below the specified line matching the +" pattern will be filtered. +" +" The remaining arguments must each be a filter to apply to the text. +" Each filter must either be a String evaluating to a function to be called. +function! tabular#PipeRange(includepat, ...) range + exe a:firstline . ',' . a:lastline + \ . 'call tabular#PipeRangeWithOptions(a:includepat, a:000, {})' +endfunction + +" Extended version of tabular#PipeRange, which +" 1) Takes the list of filters as an explicit list rather than as varargs +" 2) Supports passing a dictionary of options to control the routine. +" Currently, the only supported option is 'mode', which determines whether +" to behave as :Tabularize or as :GTabularize +" This allows me to add new features here without breaking API compatibility +" in the future. +function! tabular#PipeRangeWithOptions(includepat, filterlist, options) range + let top = a:firstline + let bot = a:lastline + + let s:do_gtabularize = (get(a:options, 'mode', '') ==# 'GTabularize') + + if !s:do_gtabularize + " In the default mode, apply range extension logic + if a:includepat != '' && top == bot + if top < 0 || top > line('$') || getline(top) !~ a:includepat + return + endif + while top > 1 && getline(top-1) =~ a:includepat + let top -= 1 + endwhile + while bot < line('$') && getline(bot+1) =~ a:includepat + let bot += 1 + endwhile + endif + endif + + let lines = map(range(top, bot), 'getline(v:val)') + + for filter in a:filterlist + if type(filter) != type("") + echoerr "PipeRange: Bad filter: " . string(filter) + endif + + call s:FilterString(lines, filter) + + unlet filter + endfor + + call s:SetLines(top, bot - top + 1, lines) +endfunction + +" Part of the public interface so interested pipelines can query this and +" adjust their behavior appropriately. +function! tabular#DoGTabularize() + return s:do_gtabularize +endfunction + +function! s:SplitDelimTest(string, delim, expected) + let result = s:SplitDelim(a:string, a:delim) + + if result !=# a:expected + echomsg 'Test failed!' + echomsg ' string=' . string(a:string) . ' delim=' . string(a:delim) + echomsg ' Returned=' . string(result) + echomsg ' Expected=' . string(a:expected) + endif +endfunction + +function! tabular#SplitDelimUnitTest() + let assignment = '[|&+*/%<>=!~-]\@!=]=\|=\~\)\@![|&+*/%<>=!~-]*=' + let two_spaces = ' ' + let ternary_operator = '^.\{-}\zs?\|:' + let cpp_io = '<<\|>>' + let pascal_assign = ':=' + let trailing_c_comments = '\/\*\|\*\/\|\/\/' + + call s:SplitDelimTest('a+=b', assignment, ['a', '+=', 'b']) + call s:SplitDelimTest('a-=b', assignment, ['a', '-=', 'b']) + call s:SplitDelimTest('a!=b', assignment, ['a!=b']) + call s:SplitDelimTest('a==b', assignment, ['a==b']) + call s:SplitDelimTest('a&=b', assignment, ['a', '&=', 'b']) + call s:SplitDelimTest('a|=b', assignment, ['a', '|=', 'b']) + call s:SplitDelimTest('a=b=c', assignment, ['a', '=', 'b', '=', 'c']) + + call s:SplitDelimTest('a b c', two_spaces, ['a', ' ', 'b', ' ', 'c']) + call s:SplitDelimTest('a b c', two_spaces, ['a b', ' ', ' c']) + call s:SplitDelimTest('ab c', two_spaces, ['ab', ' ', '', ' ', 'c']) + + call s:SplitDelimTest('a?b:c', ternary_operator, ['a', '?', 'b', ':', 'c']) + + call s:SplitDelimTest('a< + :let g:tabular_loaded = 1 + +============================================================================== +1. Description *tabular-intro* + +Sometimes, it's useful to line up text. Naturally, it's nicer to have the +computer do this for you, since aligning things by hand quickly becomes +unpleasant. While there are other plugins for aligning text, the ones I've +tried are either impossibly difficult to understand and use, or too simplistic +to handle complicated tasks. This plugin aims to make the easy things easy +and the hard things possible, without providing an unnecessarily obtuse +interface. It's still a work in progress, and criticisms are welcome. + +============================================================================== +2. Walkthrough *tabular-walkthrough* *:Tabularize* + +Tabular's commands are based largely on regular expressions. The basic +technique used by Tabular is taking some regex to match field delimiters, +splitting the input lines at those delimiters, trimming unnecessary spaces +from the non-delimiter parts, padding the non-delimiter parts of the lines +with spaces to make them the same length, and joining things back together +again. + +For instance, consider starting with the following lines: +> + Some short phrase,some other phrase + A much longer phrase here,and another long phrase +< +Let's say we want to line these lines up at the commas. We can tell +Tabularize to do this by passing a pattern matching , to the Tabularize +command: +> + :Tabularize /, + + Some short phrase , some other phrase + A much longer phrase here , and another long phrase +< +I encourage you to try copying those lines to another buffer and trying to +call :Tabularize. You'll want to take notice of two things quickly: First, +instead of requiring a range, Tabularize tries to figure out what you want to +happen. Since it knows that you want to act on lines matching a comma, it +will look upwards and downwards for lines around the current line that match a +comma, and consider all contiguous lines matching the pattern to be the range +to be acted upon. You can always override this by specifying a range, though. + +The second thing you should notice is that you'll almost certainly be able to +abbreviate :Tabularize to :Tab - using this form in mappings and scripts is +discouraged as it will make conflicts with other scripts more likely, but for +interactive use it's a nice timesaver. Another convenience feature is that +running :Tabularize without providing a new pattern will cause it to reuse the +last pattern it was called with. + +So, anyway, now the commas line up. Splitting the lines on commas, Tabular +realized that 'Some short phrase' would need to be padded with spaces to match +the length of 'A much longer phrase here', and it did that before joining the +lines back together. You'll also notice that, in addition to the spaces +inserting for padding, extra spaces were inserted between fields. That's +because by default, Tabular prints things left-aligned with one space between +fields. If you wanted to print things right-aligned with no spaces between +fields, you would provide a different format to the Tabularize command: +> + :Tabularize /,/r0 + + Some short phrase, some other phrase + A much longer phrase here,and another long phrase +< +A format specifier is either l, r, or c, followed by one or more digits. If +the letter is l, the field will be left aligned, similarly for r and right +aligning and c and center aligning. The number following the letter is the +number of spaces padding to insert before the start of the next field. +Multiple format specifiers can be added to the same command - each field will +be printed with the next format specifier in the list; when they all have been +used the first will be used again, and so on. So, the last command right +aligned every field, then inserted 0 spaces of padding before the next field. +What if we wanted to right align the text before the comma, and left align the +text after the comma? The command would look like this: +> + :Tabularize /,/r1c1l0 + + Some short phrase , some other phrase + A much longer phrase here , and another long phrase +< +That command would be read as "Align the matching text, splitting fields on +commas. Print everything before the first comma right aligned, then 1 space, +then the comma center aligned, then 1 space, then everything after the comma +left aligned." Notice that the alignment of the field the comma is in is +irrelevant - since it's only 1 cell wide, it looks the same whether it's right, +left, or center aligned. Also notice that the 0 padding spaces specified for +the 3rd field are unused - but they would be used if there were enough fields +to require looping through the fields again. For instance: +> + abc,def,ghi + a,b + a,b,c + + :Tabularize /,/r1c1l0 + + abc , def, ghi + a , b + a , b , c +< +Notice that now, the format pattern has been reused; field 4 (the second comma) +is right aligned, field 5 is center aligned. No spaces were inserted between +the 3rd field (containing "def") and the 4th field (the second comma) because +the format specified 'l0'. + +But, what if you only wanted to act on the first comma on the line, rather than +all of the commas on the line? Let's say we want everything before the first +comma right aligned, then the comma, then everything after the comma left +aligned: +> + abc,def,ghi + a,b + a,b,c + + :Tabularize /^[^,]*\zs,/r0c0l0 + + abc,def,ghi + a,b + a,b,c +< +Here, we used a Vim regex that would only match the first comma on the line. +It matches the beginning of the line, followed by all the non-comma characters +up to the first comma, and then forgets about what it matched so far and +pretends that the match starts exactly at the comma. + +But, now that this command does exactly what we want it to, it's become pretty +unwieldy. It would be unpleasant to need to type that more than once or +twice. The solution is to assign a name to it. +> + :AddTabularPattern first_comma /^[^,]*\zs,/r0c0l0 +< +Now, typing ":Tabularize first_comma" will do the same thing as typing the +whole pattern out each time. Of course this is more useful if you store the +name in a file to be used later. + +NOTE: In order to make these new commands available every time vim starts, +you'll need to put those new commands into a .vim file in a plugin directory +somewhere in your 'runtimepath'. In order to make sure that Tabular.vim has +already been loaded before your file tries to use :AddTabularPattern or +:AddTabularPipeline, the new file should be installed in an after/plugin +directory in 'runtimepath'. In general, it will be safe to find out where the +TabularMaps.vim plugin was installed, and place other files extending +Tabular.vim in the same directory as TabularMaps.vim. For more information, +and some suggested best practices, check out the |tabular-scripting| section. + +Lastly, we'll approach the case where tabular cannot achieve your desired goal +just by splitting lines appart, trimming whitespace, padding with whitespace, +and rejoining the lines. As an example, consider the multiple_spaces command +from TabularMaps.vim. The goal is to split using two or more spaces as a +field delimiter, and join fields back together, properly lined up, with only +two spaces between the end of each field and the beginning of the next. +Unfortunately, Tabular can't do this with only the commands we know so far: +> + :Tabularize / / +< +The above function won't work, because it will consider "a b" as 5 fields +delimited by two pairs of 2 spaces ( 'a', ' ', '', ' ', 'b' ) instead of as +3 fields delimited by one set of 2 or more spaces ( 'a', ' ', 'b' ). +> + :Tabularize / \+/ +< +The above function won't work either, because it will leave the delimiter as 4 +spaces when used against "a b", meaning that we would fail at our goal of +collapsing everything down to two spaces between fields. So, we need a new +command to get around this: +> + :AddTabularPipeline multiple_spaces / \{2,}/ + \ map(a:lines, "substitute(v:val, ' \{2,}', ' ', 'g')") + \ | tabular#TabularizeStrings(a:lines, ' ', 'l0') +< +Yeah. I know it looks complicated. Bear with me. I probably will try to add +in some shortcuts for this syntax, but this verbose will be guaranteed to +always work. + +You should already recognize the name being assigned. The next thing to +happen is / \{2,}/ which is a pattern specifying which lines should +automatically be included in the range when no range is given. Without this, +there would be no pattern to use for extending the range. Everything after +that is a | separated list of expressions to be evaluated. In the context in +which they will be evaluated, a:lines will be set to a List of Strings +containing the text of the lines being filtered as they procede through the +pipeline you've set up. The \ at the start of the lines are just vim's line +continuation marker; you needn't worry much about them. So, the first +expression in the pipeline transforms each line by replacing every instance of +2 or more spaces with exactly two spaces. The second command in the pipeline +performs the equivalent of ":Tabularize / /l0"; the only difference is that +it is operating on a List of Strings rather than text in the buffer. At the +end of the pipeline, the Strings in the modified a:lines (or the return value +of the last expression in the pipeline, if it returns a List) will replace the +chosen range. + +============================================================================== +3. Extending *tabular-scripting* + +As mentioned above, the most important consideration when extending Tabular +with new maps or commands is that your plugin must be loaded after Tabular.vim +has finished loading, and only if Tabular.vim has loaded successfully. The +easiest approach to making sure it loads after Tabular.vim is simply putting +the new file (we'll call it "tabular_extra.vim" as an example) into an +"after/plugin/" directory in 'runtimepath', for instance: +> + ~/.vim/after/plugin/tabular_extra.vim +< +The default set of mappings, found in "TabularMaps.vim", is installed in +the after/plugin/ subdirectory of whatever directory Tabular was installed to. + +The other important consideration is making sure that your commands are only +called if Tabular.vim was actually loaded. The easiest way to do this is by +checking for the existence of the :Tabularize command at the start of your +plugin. A short example plugin would look like this: +> + " after/plugin/my_tabular_commands.vim + " Provides extra :Tabularize commands + + if !exists(':Tabularize') + finish " Give up here; the Tabular plugin musn't have been loaded + endif + + " Make line wrapping possible by resetting the 'cpo' option, first saving it + let s:save_cpo = &cpo + set cpo&vim + + AddTabularPattern! asterisk /*/l1 + + AddTabularPipeline! remove_leading_spaces /^ / + \ map(a:lines, "substitute(v:val, '^ *', '', '')") + + " Restore the saved value of 'cpo' + let &cpo = s:save_cpo + unlet s:save_cpo +< +============================================================================== +vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl: diff --git a/sources_non_forked/tabular/plugin/Tabular.vim b/sources_non_forked/tabular/plugin/Tabular.vim new file mode 100644 index 00000000..e73329ac --- /dev/null +++ b/sources_non_forked/tabular/plugin/Tabular.vim @@ -0,0 +1,346 @@ +" Tabular: Align columnar data using regex-designated column boundaries +" Maintainer: Matthew Wozniski (godlygeek@gmail.com) +" Date: Thu, 03 May 2012 20:49:32 -0400 +" Version: 1.0 +" +" Long Description: +" Sometimes, it's useful to line up text. Naturally, it's nicer to have the +" computer do this for you, since aligning things by hand quickly becomes +" unpleasant. While there are other plugins for aligning text, the ones I've +" tried are either impossibly difficult to understand and use, or too simplistic +" to handle complicated tasks. This plugin aims to make the easy things easy +" and the hard things possible, without providing an unnecessarily obtuse +" interface. It's still a work in progress, and criticisms are welcome. +" +" License: +" Copyright (c) 2012, Matthew J. Wozniski +" All rights reserved. +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are met: +" * Redistributions of source code must retain the above copyright notice, +" this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above copyright +" notice, this list of conditions and the following disclaimer in the +" documentation and/or other materials provided with the distribution. +" * The names of the contributors may not be used to endorse or promote +" products derived from this software without specific prior written +" permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS +" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +" NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, +" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +" OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" Abort if running in vi-compatible mode or the user doesn't want us. +if &cp || exists('g:tabular_loaded') + if &cp && &verbose + echo "Not loading Tabular in compatible mode." + endif + finish +endif + +let g:tabular_loaded = 1 + +" Stupid vimscript crap {{{1 +let s:savecpo = &cpo +set cpo&vim + +" Private Things {{{1 + +" Dictionary of command name to command +let s:TabularCommands = {} + +" Generate tab completion list for :Tabularize {{{2 +" Return a list of commands that match the command line typed so far. +" NOTE: Tries to handle commands with spaces in the name, but Vim doesn't seem +" to handle that terribly well... maybe I should give up on that. +function! s:CompleteTabularizeCommand(argstart, cmdline, cursorpos) + let names = keys(s:TabularCommands) + if exists("b:TabularCommands") + let names += keys(b:TabularCommands) + endif + + let cmdstart = substitute(a:cmdline, '^\s*\S\+\s*', '', '') + + return filter(names, 'v:val =~# ''^\V'' . escape(cmdstart, ''\'')') +endfunction + +" Choose the proper command map from the given command line {{{2 +" Returns [ command map, command line with leading removed ] +function! s:ChooseCommandMap(commandline) + let map = s:TabularCommands + let cmd = a:commandline + + if cmd =~# '^\s\+' + if !exists('b:TabularCommands') + let b:TabularCommands = {} + endif + let map = b:TabularCommands + let cmd = substitute(cmd, '^\s\+', '', '') + endif + + return [ map, cmd ] +endfunction + +" Parse '/pattern/format' into separate pattern and format parts. {{{2 +" If parsing fails, return [ '', '' ] +function! s:ParsePattern(string) + if a:string[0] != '/' + return ['',''] + endif + + let pat = '\\\@ 0)] =~ '^\s*$' + throw "Empty element" + endif + + if end == -1 + let rv = [ a:string ] + else + let rv = [ a:string[0 : end-1] ] + s:SplitCommands(a:string[end+1 : -1]) + endif + + return rv +endfunction + +" Public Things {{{1 + +" Command associating a command name with a simple pattern command {{{2 +" AddTabularPattern[!] [] name /pattern[/format] +" +" If is provided, the command will only be available in the current +" buffer, and will be used instead of any global command with the same name. +" +" If a command with the same name and scope already exists, it is an error, +" unless the ! is provided, in which case the existing command will be +" replaced. +" +" pattern is a regex describing the delimiter to be used. +" +" format describes the format pattern to be used. The default will be used if +" none is provided. +com! -nargs=+ -bang AddTabularPattern + \ call AddTabularPattern(, 0) + +function! AddTabularPattern(command, force) + try + let [ commandmap, rest ] = s:ChooseCommandMap(a:command) + + let name = matchstr(rest, '.\{-}\ze\s*/') + let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') + + let [ pattern, format ] = s:ParsePattern(pattern) + + if empty(name) || empty(pattern) + throw "Invalid arguments!" + endif + + if !a:force && has_key(commandmap, name) + throw string(name) . " is already defined, use ! to overwrite." + endif + + let command = "tabular#TabularizeStrings(a:lines, " . string(pattern) + + if !empty(format) + let command .= ", " . string(format) + endif + + let command .= ")" + + let commandmap[name] = { 'pattern' : pattern, 'commands' : [ command ] } + catch + echohl ErrorMsg + echomsg "AddTabularPattern: " . v:exception + echohl None + endtry +endfunction + +" Command associating a command name with a pipeline of functions {{{2 +" AddTabularPipeline[!] [] name /pattern/ func [ | func2 [ | func3 ] ] +" +" If is provided, the command will only be available in the current +" buffer, and will be used instead of any global command with the same name. +" +" If a command with the same name and scope already exists, it is an error, +" unless the ! is provided, in which case the existing command will be +" replaced. +" +" pattern is a regex that will be used to determine which lines will be +" filtered. If the cursor line doesn't match the pattern, using the command +" will be a no-op, otherwise the cursor and all contiguous lines matching the +" pattern will be filtered. +" +" Each 'func' argument represents a function to be called. This function +" will have access to a:lines, a List containing one String per line being +" filtered. +com! -nargs=+ -bang AddTabularPipeline + \ call AddTabularPipeline(, 0) + +function! AddTabularPipeline(command, force) + try + let [ commandmap, rest ] = s:ChooseCommandMap(a:command) + + let name = matchstr(rest, '.\{-}\ze\s*/') + let pattern = substitute(rest, '.\{-}\s*\ze/', '', '') + + let commands = matchstr(pattern, '^/.\{-}\\\@CompleteTabularizeCommand + \ Tabularize ,call Tabularize() + +function! Tabularize(command, ...) range + let piperange_opt = {} + if a:0 + let piperange_opt = a:1 + endif + + if empty(a:command) + if !exists("s:last_tabularize_command") + echohl ErrorMsg + echomsg "Tabularize hasn't been called yet; no pattern/command to reuse!" + echohl None + return + endif + else + let s:last_tabularize_command = a:command + endif + + let command = s:last_tabularize_command + + let range = a:firstline . ',' . a:lastline + + try + let [ pattern, format ] = s:ParsePattern(command) + + if !empty(pattern) + let cmd = "tabular#TabularizeStrings(a:lines, " . string(pattern) + + if !empty(format) + let cmd .= "," . string(format) + endif + + let cmd .= ")" + + exe range . 'call tabular#PipeRangeWithOptions(pattern, [ cmd ], ' + \ . 'piperange_opt)' + else + if exists('b:TabularCommands') && has_key(b:TabularCommands, command) + let usercmd = b:TabularCommands[command] + elseif has_key(s:TabularCommands, command) + let usercmd = s:TabularCommands[command] + else + throw "Unrecognized command " . string(command) + endif + + exe range . 'call tabular#PipeRangeWithOptions(usercmd["pattern"], ' + \ . 'usercmd["commands"], piperange_opt)' + endif + catch + echohl ErrorMsg + echomsg "Tabularize: " . v:exception + echohl None + return + endtry +endfunction + +" GTabularize /pattern[/format] {{{2 +" GTabularize name +" +" Align text on only matching lines, either using the given pattern, or the +" command associated with the given name. Mnemonically, this is similar to +" the :global command, which takes some action on all rows matching a pattern +" in a range. This command is different from normal :Tabularize in 3 ways: +" 1) If a line in the range does not match the pattern, it will be left +" unchanged, and not in any way affect the outcome of other lines in the +" range (at least, normally - but Pipelines can and will still look at +" non-matching rows unless they are specifically written to be aware of +" tabular#DoGTabularize() and handle it appropriately). +" 2) No automatic range determination - :Tabularize automatically expands +" a single-line range (or a call with no range) to include all adjacent +" matching lines. That behavior does not make sense for this command. +" 3) If called without a range, it will act on all lines in the buffer (like +" :global) rather than only a single line +com! -nargs=* -range=% -complete=customlist,CompleteTabularizeCommand + \ GTabularize , + \ call Tabularize(, { 'mode': 'GTabularize' } ) + +" Stupid vimscript crap, part 2 {{{1 +let &cpo = s:savecpo +unlet s:savecpo + +" vim:set sw=2 sts=2 fdm=marker: diff --git a/sources_non_forked/tlib/.gitignore b/sources_non_forked/tlib/.gitignore new file mode 100644 index 00000000..e626a86d --- /dev/null +++ b/sources_non_forked/tlib/.gitignore @@ -0,0 +1,13 @@ +tags +!doc/tags +Makefile +TODO.TXT +TODO_archived.viki +*.vba +*.vmb +*.zip +.last_* +test +test_* +tmp +var diff --git a/sources_non_forked/tlib/CHANGES.TXT b/sources_non_forked/tlib/CHANGES.TXT new file mode 100644 index 00000000..e54e1007 --- /dev/null +++ b/sources_non_forked/tlib/CHANGES.TXT @@ -0,0 +1,919 @@ +0.1 +Initial release + +0.2 +- More list convenience functions +- tlib#EditList() +- tlib#InputList(): properly handle duplicate items; it type contains +'i', the list index + 1 is returned, not the element + +0.3 +- tlib#InputList(): Show feedback in statusline instead of the echo area +- tlib#GetVar(), tlib#GetValue() + +0.4 +- tlib#InputList(): Up/Down keys wrap around list +- tlib#InputList(): FIX: Problem when reducing the filter & using AND +- tlib#InputList(): Made work (can be configured via +- tlib#InputList(): special display_format: "filename" +- tlib#Object: experimental support for some kind of OOP +- tlib#World: Extracted some functions from tlib.vim to tlib/World.vim +- tlib#FileJoin(), tlib#FileSplit(), tlib#RelativeFilename() +- tlib#Let() +- tlib#EnsureDirectoryExists(dir) +- tlib#DirName(dir) +- tlib#DecodeURL(url), tlib#EncodeChar(char), tlib#EncodeURL(url) +- FIX: Problem when using shift-up/down with filtered lists + +0.5 +- tlib#InputList(): FIX: Selecting items in filtered view +- tlib#InputList(): : Remove last AND pattern from filter + +0.6 +- tlib#InputList(): Disabled map +- tlib#InputList(): try to be smart about user itentions only if a +list's length is < g:tlib_sortprefs_threshold (default: 200) +- tlib#Object: Super() method +- tlib#MyRuntimeDir() +- tlib#GetCacheName(), tlib#CacheSave(), tlib#CacheGet() +- tlib#Args(), tlib#GetArg() +- FIX: tlib#InputList(): Display problem with first item + +0.7 +- tlib#InputList(): ... Suspend/Resume input +- tlib#InputList(): ... Input text on the command line (useful on +slow systems when working with very large lists) +- tlib#InputList(): AND-pattern starting with '!' will work as 'exclude +matches' +- tlib#InputList(): FIX pop OR-patterns properly +- tlib#InputList(): display_format == filename: don't add '/' to +directory names (avoid filesystem access) + +0.8 +- FIX: Return empty cache name for buffers that have no files attached to it +- Some re-arranging + +0.9 +- Re-arrangements & modularization (this means many function names have +changed, on the other hand only those functions are loaded that are +actually needed) +- tlib#input#List(): Added maps with m-modifiers for , , +- tlib#input#List(): Make sure &fdm is manual +- tlib#input#List(): When exiting the list view, consume the next 5 +characters in the queue (if any) +- tlib#input#EditList(): Now has cut, copy, paste functionality. +- Added documentation and examples + +0.10 +- tlib#input#List(): (v)split type of commands leave the original window +untouched (you may use to replace its contents) +- tlib#file#With(): Check whether an existing buffer is loaded. +- Scratch related functions went to tlib/scratch.vim so that they are +accessible from other scripts. +- Configure the list window height via g:tlib_inputlist_pct (1..100%) + +0.11 +NEW: + - The :TLet command replaces :TLLet (which was removed) + - :TScratch[!] command (with ! don't split but use the whole window) + - tlib#rx#Escape(text, ?magic='m') + - tlib#buffer#GetList(?show_hidden=0) + - tlib#dir#CD(), tlib#dir#Push(), tlib#dir#Pop() + - tlib#input#ListW: A slightly remodeled version of tlib#input#List + that takes a World as second argument. + - Added some documentation doc/tlib.txt (most of it is automatically + compiled from the source files) +CHANGES: + - tlib#input#List(): The default keys for AND, NOT have changed to + be more Google-like (space, minus); the keys can be configured via + global variables. +IMPROVEMENTS: + - In file listings, indicate if a file is loaded, listed, modified + etc. + - tlib#input#List(): Highlight the filter pattern + - tlib#input#List(): scrolls g:tlib_scroll_lines + (default=10) lines +FIXES: + - tlib#input#List(): Centering line, clear match, clear & restore + the search register + - tlib#input#List(): Ensure the window layout doesn't change (if the + number of windows hasn't changed) + - tlib#arg#Ex(): Don't escape backslashes by default + +0.12 +NEW: + - tlib/tab.vim +CHANGES: + - Renamed tlib#win#SetWin() to tlib#win#Set() +IMPROVEMENTS: + - tlib#input#List(): , keys work in some lists + - tlib#input#List(): If an index_table is provided this will be used + instead of the item's list index. +FIXES: + - tlib#input#List(): Problem with scrolling, when the list was + shorter than the window (eg when using a vertical window). + - tlib#cache#Filename(): Don't rewrite name as relative filename if + explicitly given as argument. Avoid double (back)slashes. + - TLet: simplified + +0.13 +CHANGES: + - Scratch: Set &fdc=0. + - The cache directory can be configured via g:tlib_cache + - Renamed tlib#buffer#SetBuffer() to tlib#buffer#Set(). +FIXES: + - tlib#input#List(): Select the active item per mouse. + - TLet: simplified + +0.14 +NEW: + - tlib#buffer#InsertText() +CHANGES: + - tlib#win#[SG]etLayout(): Use a dictionnary, set &cmdheight. +FIXES: + - Wrong order with pre-defined filters. + +0.15 +NEW: + - tlib#string#TrimLeft(), tlib#string#TrimRight(), tlib#string#Strip() + - Progress bar + +0.16 +NEW: + - tlib#string#Printf1() + +0.17 +NEW: + - TBrowseOutput +- Some minor changes + +0.18 +NEW: + - tlib/time.vim + - g:tlib_inputlist_livesearch_threshold +CHANGES: + - tlib#input#ListD(), World: Don't redisplay the list while typing + new letters; calculate filter regexps only once before filtering the + list. + - World.vim: Minor changes to how filenames are handled. + +0.19 +NEW: + - tag.vim +FIX: + - dir.vim: Use plain dir name in tlib#dir#Ensure() + - tlib#input#List(): An initial filter argument creates [[filter]] + and not as before [[''], [filter]]. + - tlib#input#List(): When type was "si" and the item was picked by + filter, the wrong index was returned. + - tlib#input#List(): Don't check if chars are typed when displaying + the list for the first time. + +0.20 +- The arguments of tlib#tag#Collect() have changed. +- tlib#input#List(): The view can be "suspended" on initial display. +- tlib#input#List(): Follow/trace cursor functionality + +0.21 +- tlib#buffer#InsertText(): Respect tabs and (experimental) formatoptions+=or +- tlib/syntax.vim: Syntax-related functions + +0.22 +- FIX: very magic mode for tlib#rx#Escape() (thanks A Politz) +- FIX: tlib#arg#Ex: escape "!" + +0.23 +- Respect the setting of g:tlib_inputlist_filename_indicators +- tlib#input#List(): Reset syntax on resume; option to make list window "sticky" +- tlib#agent#ToggleStickyList() +- Simplified tlib#url#Decode() +- tlib#arg#Ex(): use fnameescape() if available + +0.24 +- s:prototype.SetInitialFilter: accept list as argument +- Maintain buffer MRU if required + +0.25 +- NEW: tlib#notify#TrimMessage(): trim message to prevent "Press ENTER" +messages (contributed by Erik Falor) +- NEW: tlib#notify#Echo() +- FIX: World.CloseScratch(): Set window +- FIX: tlib#input#ListW(): Set initial_display = 1 on reset + +0.26 +- NEW: tlib#normal#WithRegister() +- FIX: Try not to change numbered registers + +0.27 +- FIX: Cosmetic bug, wrong packaging (thanks Nathan Neff) +- Meaning of World#filter_format changed; new World#filter_options +- Filtering didn't work as advertised +- tlib#string#Count() + +0.28 +- tlib#input#List(): +-- Improved handling of sticky lists; and resume a +suspended list and immediately selects the item under the cursor +-- Experimental "seq" matching style: the conjunctions are sequentially +ordered, they are combined with "OR" (disjunctions), the regexp is +'magic', and "." is expanded to '.\{-}' +-- Experimental "cnfd" matching style: Same as cnf but with an "elastic" +dot "." that matches '\.\{-}' +-- Filtering acts as if &ic=1 && $sc=1 +-- Weighting is done by the filter +- tlib#agent#Input(): Consume when aborting input() +- INCOMPATIBLE CHANGE: Changed eligible values of g:tlib_inputlist_match +to "cnf", "cnfd", "seq" and "fuzzy" +- NEW: tlib#buffer#KeepCursorPosition() +- tlib#buffer#InsertText(): Take care of the extra line when appending +text to an empty buffer. + +0.29 +- tlib#string#Strip(): Strip also control characters (newlines etc.) +- tlib#rx#Suffixes(): 'suffixes' as Regexp +- World#RestoreOrigin(): Don't assume &splitbelow + +0.30 +- World#RestoreOrigin(): Don't assume &splitright + +0.31 +- :TRequire command +-tlib#input#List: For i-type list views, make sure agents are called +with the base indices. + +0.32 +- tlib#agent#Exit: explicitly return empty value (as a consequence, +pressing when browsing an index-list, returns 0 and not "") +- tlib#signs +- tlib#input#List: set local statusline + +0.33 +- Don't reset statusline +- Don't use fnamemodify() to split filenames (for performance reasons) +- scratch: Set ft after setting up scratch options +- tlib#map#PumAccept(key) + +0.34 +- tlib#buffer#HighlightLine(line): call tlib#autocmdgroup#Init() +(reported by Sergey Khorev) + +0.35 +- tlib#input#EditList(): return the list if the user presses esc + +0.36 +- Display a message when the filter is for whatever reason invalid +- Removed tlib#paragraph#Delete() +- New: tlib#paragraph#Define(), tlib#textobjects#StandardParagraph() +- Try to speed up list display (a rewrite of World.DisplayList() etc. is +required) + +0.37 +- g:tlib_inputlist_livesearch_threshold defaults to 1000 +- tlib#World: optional scratch_pos field +- tlib#input#List: By default selects by number but NUMBER is +interpreted as string +- tlib#date +- TTimeCommand + +0.38 +- tlib#World#Resize: set winfix{height|width} + +0.39 +- g:tlib#cache#dont_purge +- tlib#vim#RestoreWindow() +- tlib#ballon#...() + +0.40 +- tlib#agent#ViewFile: Use split/sbuffer if nohidden && modified +- tlib#buffer#GetList(): order by "basename" + +version: "0.41" + - World.UseScratch(): keepalt + - Really include balloon.vim + MD5 checksum: 3fcbc4f7556f5378d39622e62ab8f379 + +version: "0.42" + - tlib#input#List: inserts a *-like wildcard (represented as "__") + - Check if a cache file cannot be created because a directory of the same name exists (display a message if so) + - tlib#cache#Filename: Removed check if a directory of the same name exists (due to inconsistent use) + - Minor improvements related to buffer handling (scratch_split) + - .gitignore + - docs (thanks to blueyed) + - There is no "edit" answer possibility. + - Fix first purge: do nothing if no timestamp file. + - g:tlib_pick_single_item + - Removed pick_single_item. Changed the default behavour when a list has only 1 item. See doc for g:tlib_pick_last_item. + - Updated help for tlib#input#List(); help_extra attribute + - EXPERIMENTAL: cache_var, restore_from_cache, on_leave properties; #Initialize(), #Leave() + - added tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command + - tlib#cmd#BrowseOutputWithCallback function and :TBrowseScriptnames command documentation + - s:prototype.Initialize(): unlet self.cache_var after restoring values + - tlib#input#List: filter-specific help + - Removed the seq filter (use cnfd or fuzzy instead) + - tlib#input#List: temp_prompt (for help message) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.42" + - g:tlib#cache#silent: don't display messages when purging the cache (fixes #9) + - Changed message when deleting directories in the cache. + - g:tlib#input#use_popup: Don't rely on has('menu') but also check for gtk & win gui (fixes #10) + - debug + - tlib#input#ListW(): Didn't return a list when type == "m" + - docs (solves #11) + MD5 checksum: aa8b5a4602235cc1a5bc9ee45d801b81 + +version: "0.45" + - fuzzy mode: prototype.highlight defaults to g:tlib_inputlist_higroup + - tlib#scratch: Use noautocmd + - tlib#input#ListW(): Use world.RestoreOrigin() instead of tlib#win#SetLayout(world.winview) + - tlib#input#ListW(): Revert to tlib#win#SetLayout(world.winview) + - tlib#cmd#OutputAsList(): Also save output in g:tlib#cmd#last_output + - tlib#agent#Suspend(): Resume on BufEnter + - tlib#input#Resume(): Make sure we are in the right buffer + - tlib#agent#Suspend(): Use only BufEnter event to trigger a Resume + - tlib#input#ListW(): When redisplaying a list, make sure prefix > 0 + - tlib#vcs: Access vcs (initially only git is supported) + - tlib#vcs: improved + - tlib#persistent: Persistent data file names + - tlib#file#With(): Trigger BufRead autocommands + - Duplicate help tags (fixes #13) + - Make sure scrolloff is 0 while viewing the list (fixes https://github.com/tomtom/vikitasks_vim/issues/2) + MD5 checksum: 0af19ebc0e424727a598a988fdc90f4e + + - Support for tinykeymap (move paragraph) + - Moved para_move to autoload/tinykeymap/map + - tlib#vcs: some "diff" commands were defined as "ls"; updated hg def; %s is optional + MD5 checksum: f2f2fe0893e75bb9423c1ddcd01f38f6 +version: "0.46" + + - tlib#input#List: optimizations + - Prepare for multi-mode maps + - tlib#input#List: cnfx is new default filter + - Filters: minor changes to how the pattern is displayed + - g:tlib#input#format_filename: alternative method for formatting filenames + - tlib#input#List: allow multiple keymaps / modes + - Handle rezise events + - Don't initialize the same window twice + - Minor optimizations to how help is displayed + - Handle VimResize event per buffer + - Improve display of filenames & highlighting + - Filename highlighter: set Highlight_filename() + - RunStateHandlers(): set world variable + - Optimize help display + MD5 checksum: e3652927722bdc51935eb1a04238546b +version: "1.00" + + - Set g:tlib_inputlist_and to ' ' again + - g:tlib#input#filename_max_width: maximum display width of filenames + - tlib#input#List: , : run command by name + MD5 checksum: a42f90275cdbe9f7d92cac61b884a2d1 +version: "1.01" + + - #UseInputListScratch(): Make sure the TLib autogroup was created (fixes #14) + MD5 checksum: 5a6da7fc99c7fc7584e8fc2f7bf86fe4 +version: "1.02" + + - tlib#cache#Value(cfile, generator, ftime, ...): cache value & check timestamp + - Replaced g:tlib#cache#silent with g:tlib#cache#verbosity + - FormatFilenames: improved handling of utf8 characters + - tlib#persistent#Value() + - tlib#input#List: Allow filename indiactors defined by the caller + - Custom filename_indicators are displayed after (and clearly separted from) the standard indicators + - Check the return value of an unknown_key agent + - Format filename = "l": Allow ".." as start of a directory name + - Format filename = "l": If the filename is just a filename's tail, display it on both sides + - Set g:tlib_filename_sep to "\" on Windows (again) + - g:tlib#cache#max_filename: If the cache filename is longer than N characters, use |pathshorten()|. + MD5 checksum: b64ce6764f39f40bfc95f3916bbb0057 +version: "1.04" + +version: "1.05" + - tlib#hash: Adler32 & CRC32 (using zlib via ruby) algorithms + - tlib#cache#Filename(): If the cache filename is too long, add the Adler32 checksum to the shortened path + - tlib#cache#Filename(): Use tlib#hash#Adler32() only if the or() function exists + - tlib#hash#Adler32(): Raise error, if or() doesn't exist + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet, thus currently disabled) + - tlib#bitwise: Bitwise operations for older versions of vim + - tlib#number: Base conversion + - tlib#input#ListW(): Handle mouse clicks more correctly + - tlib#bitwise#Num2Bits(): Supports returning floats + - tlib#hash#CRC32(): Alternative implementation of crc32 (doesn't work yet) + - tlib#hash#CRC32(): Re-enable ruby version + - tlib#hash#CRC32B(): Implementation of CRC32B checksum in vimscript (used only if +ruby isn't available) + - tlib#hash#CRC32B(): vim version: cache the crc table + - tlib#cache#Filename(): Use tlib#hash#CRC32B(file) instead of not Adler32 for filenames too long + - tlib#hash#CRC32B(): ruby version: return upper case hex value + - g:tlib#hash#use_crc32: define which crc32b version should be used + - Moved spec files from vimtlib to tlib_vim + - tlib#bitwise#Add() and tlib#bitwise#Sub() + - tlib#file#Relative(): Wrong results for filenames that don't exist + - Implementation of hash#Adler32 for earlier vim versions; g:tlib#hash#use_adler32 + - tlib#cache#Filename(): Use adler32 again + - addon-info + - tlib#file#Absolute(): remove redundant "." parts in full filename + - win32: Fix moving window when using :vertical for tlib#inpu#List() + - tlib#cache#Filename(): Don't create wrong directory if the cache filename is too long + - tlib#file#Join(): if strip_slashes, also strip redundant (back)slashes + - tlib#input#ListW(): Always set post_keys variable + - tlib#file#With(): escape backslashes + - tlib#cmd#OutputAsList(): Support for nesting + - tlib#dir#NativeName(dirname) + MD5 checksum: 493f9beca44374de386f20d1613155e3 + + - Rename g:tlib_debug to g:tlib#debug + - Renamed g:tlib_sortprefs_threshold to g:tlib#input#sortprefs_threshold + - Renamed g:tlib#input#livesearch_threshold + - Renamed g:tlib_inputlist_match to g:tlib#input#filter_mode + - Renamed g:tlib_inputlist_higroup to g:tlib#input#higroup + - Renamed g:tlib#debug + - Moved g:tlib_pick_last_item + - Renamed g:tlib#input#and, g:tlib#input#or, g:tlib#input#not + - Moved g:tlib_numeric_chars to autoload/tlib/input.vim + - Renamed g:tlib#input#keyagents_InputList_s, g:tlib#input#keyagents_InputList_m, g:tlib#input#handlers_EditList + - Moved g:tlib_inputlist_pct, g:tlib_inputlist_width_filename, g:tlib_inputlist_filename_indicators, g:tlib_inputlist_shortmessage to autoload/tlib/World.vim + - Renamed tlib#input#pick_last_item (2) + - prototype.SelectItemsByNames() + - filtered_items: Restricted view + - prototype.PrintLines() + - Restricted view (2) + - Moved g:tlib_scroll_lines to autoload/tlib/agent.vim + - prototype.PrintLines() (2) + - tlib#input: Improved handling of popup menu (allows submenu) + - tlib#input: Allow mods in keys + - Moved g:tlib_scratch_pos to autoload/tlib/scratch.vim + - Moved g:tlib_tags_extra, g:tlib_tag_substitute to autoload/tlib/tag.vim + - tlib#agent#CompleteAgentNames(): Respect Arglead + - Move g:tlib_viewline_position to autoload/tlib/buffer.vim + - Move g:tlib_cache to autoload/tlib/cache.vim + - Renamed g:tlib_filename_sep to g:tlib#dir#sep + - prototype.UseScratch(): Set b:tlib_world + - tlib#input: f9 toggles resticted view + - tlib#input: next_agent, next_eval + - tlib#input: Revised use of the popup menu + - tlib#input: Disable popup menu for gui_gtk + - tlib#input: Re-enabled the popup menu for gtk gui + - tlib#input: FIX popup menu on Windows + - Renamed g:tlib_numeric_chars to g:tlib#input#numeric_chars (disabled per-buffer values) (fixes #35) + - Improve scratch list + - New: tlib#grep + - Merge branch 'master' of https://github.com/bruno-/tlib_vim into pull16 + - g:tlib_scratch_hidden: Configure how to "hide" the scratch buffer + - tlib#grep#Do: don't escape "*" in patterns + - Optimize use of visible scratch buffers + - World.scratch_hidden parameter + - scratch: Always use keepalt & keepjumps + MD5 checksum: 2e40449c47dc606ccef57aa0b1e22e8e +version: "1.06" + +version: "1.07" + - Help template + - prototype.Highlight_filename(): Use matchstr() instead of fnamemodify() + - Display buffer-related filename indicators only if g:tlib_inputlist_filename_indicators is true + - tlib#file#Join(): strip_slashes defaults to 1 + MD5 checksum: 6c8fa96fd3747be05df848ee93dd789b + +version: "1.08" + - list#input: Improved support for file indicators (closes #17) + - tlib#char#Get(): Optionally, also return mod + - tlib#input#ListW: Use #DisplayFormat(world.list) + - Renamed cnfx filter to glob & minor filter-related enhancements + - list#input: Make help available as command; help cannot be called via ? + - list#input: Improved help message + - list#input: Support Home & End keys + - list#input: Added glob filter + - tlib#agent#ShowInfo: Show full filename + - tlib#cmd#BrowseOutputWithCallback: Support calling callback with multiple results + - tlib#cmd#ParseScriptname: Properly parse results from :scriptnames + - tlib#tab#Set() + - Prepare for proper handling of scratch_split == -1 + - tlib#vim#CopyFunction() + - tlib#cache#Value(): If generator is empty, use the optional argument as start value + - tlib#persistent#Get() refers to tlib#cache#Get() + MD5 checksum: 459ec620168d1ae9b18c69eb3f991832 + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#cache#Filename(): Use sha256() for VIM >= 7.4 + - tlib#cache#Value(): Undo previous hack + - tlib#list#Uniq(): option to remove empty values + - tlib#cache#MTime(); tlib#persistent#Save() calls tlib#cache#Save() + - tlib#input#ListW: Temporarily set noshowmode + - tlib#list#Uniq(): Fix handling of empty items + - lis picker: Remove from help + - tlib#list#Uniq(): Implementation based on syntastic#util#unique(list) by scrooloose + MD5 checksum: b5fb4107d63930c2c8b1f0f6b3a7ff07 +version: "1.09" + + - tlib#string#Chomp: Optional argument: max number of chars that should be removed + MD5 checksum: 8c1b94e25045580874e2f892d509291b +version: "1.10" + + - tlib#vcs#FindVCS(filename): Wrong parameters to fnamemodifiy if filename is a directory + - Some system-related functions (e.g. facilitate use of cygwin tools) + - tlib#arg#StringAsKeyArgsEqual(), tlib#arg#StringAsKeyArgs(): Support "key=val" type argument lists + - tlib#vcs#Executable() + - scripts/create_crc_table.rb + - tlib#var#Get(): For namespaces other than global, replace "#" with "_" + MD5 checksum: 4a33f2f23e1fc6600b32e7f8323e001e +version: "1.11" + + - tlib#list#ToDictionary() + - tlib#dir#CanonicName(): Use tlib#file#Canonic() + - tlib#file#Canonic() + MD5 checksum: 7995ab58f31eb6673d20deab8761838e +version: "1.12" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + + - SetInitialFilter(): Use deepcopy() + - tlib#var#List(): use keys(namespace) for newer versions of vim + - g:tlib#input#user_shortcuts (not functional yet) + - tlib#input#List: state "picked" + - UseInputListScratch(): Allow customization via self.index_next_syntax + - tlib#cmd#Capture() + - Facilitate customization of key agents via g:tlib_extend_keyagents_InputList_s, g:tlib_extend_keyagents_InputList_m + MD5 checksum: 7dd8b17a1a5b555df979381dcbd4c9aa +version: "1.13" + +version: "1.14" + - FIX #18: Make sure the scratch isn't readonly + - FIX: display filter (properly handle backslashes) + - Remove loaded_* guard from autoload files + - tlib#notify#Echo(): minor changes + - tlib#file#Edit() (used by tlib#agent#ViewFile) + - tlib#buffer#GetList(): Buffer numbers are converted to numbers + - tlib#sys: Change order of functions (move tlib#sys#IsCygwinBin to the (possibly FIX #19) + - g:tlib#sys#check_cygpath: Call tlib#sys#IsExecutable('cygpath', 1) (possibly FIX #19) + MD5 checksum: 2cf6386218736a2d09db43c8e751e5a4 + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + +version: "1.15" + - tlib#file#Join(): New optional argument: maybe_absolute Drop preceding parts if a part looks like an absolute filename + - tlib#sys#Open(), tlib#sys#IsSpecial() (moved from viki) + - tlib#list#Uniq(): Handle hetergenous lists + - FIX #21: duplicate help tag + - NEW tlib#dictionary#Rev() + - tlib#input#List(): Use to complete current word + - NEW tlib#arg#GetOpts(); ENH tlib#arg#StringAsKeyArgsEqual() + - cache: Allow for in memory cache + - NEW tlib#eval#Extend() + - Move qfl/loclist browser from trag to tlib + - FIX tlib#eval#Extend() + - Simplify tlib#eval#Extend() + - World.index_next_syntax may be a dict + - tlib#qfl#QflList: Use copy() + - tlib#arg#GetOpts: Handle exit code + MD5 checksum: 13fd8b0e4ba9cd932c57fc40ac3f641f + + - tlib#arg#GetOpts: Handle short options + - tlib#arg: support short flags & facilitate completion + - NEW :TLibTrace + - tlib#sys#system_browser: FIX XDG string + - NEW tlib#sys#SystemInDir() (used by tlib#vcs#Ls) + - tlib#agent#Complete: improve fltrx + - Remove tlib#arg#Key(), :TKeyArg + - Move :TRequire, :TTimeCommand to macros/tlib.vim + - NEW tlib#cmd#TBrowseScriptnames() + - TScratch: use empty('') + - NEW :TLibTrace + - tlib#qfl: FIX TTagedFilesFilename regexp + - Remove tlib#arg#Key() + - tlib#buffer#InsertText(): Don't use TKeyArg + - tlib#eval#Extend: don't assign value + - NEW :TLibTrace, tlib#trace (was tlib#debug) + - NEW tlib#string#SplitCommaList() + - NEW tlib#time#FormatNow() + - tlib#arg#GetOpts: selectively disable "long", "short" flags + - tlib#arg#CComplete(): Support values completion (complete_customlist field) + - NEW tlib#date#Shift() + - tlib#qfl#Balloon(): Handle items with no bufnr + - NEW tlib#file#Glob, tlib#file#Globpath + - tlib#progressbar#Display(): optional "always" argument + - tlib#vcs#GitLsPostprocess(): Try to handle encoded filenames from git ls-files + - tlib#vcs#GitLsPostprocess: Eval only \ddd substrings + - FIX #22: duplicate tag + - tlib#buffer: Use 2match instead of 3match (incompatibility with matchparen) + - FIX #23: duplicate help tag + - tlib#string#SplitCommaList: optional "sep" argument + - Rename TLibTrace -> Tlibtrace; NEW Tlibtraceset command + - Rename s:SetSyntax -> tlib#qfl#SetSyntax + - mv tlib#rx#Convert to incubator + MD5 checksum: f3656fb35b7b3033084d6c5e504aca61 +version: "1.16" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#input#List: #ReduceFilter: make sure the regexp is valid + - TTimeCommand -> Ttimecommand + - tlib#eval#Extend: mode argument for expand() compatibility + - tlib#input#List: Key handlers can have additional arguments + - tlib#qfl#AgentWithSelected: Set world + - prototype.UseInputListScratch: Run tlib_UseInputListScratch hook earlier + - tlib#qfl#AgentWithSelected: typo + - tlib#arg#GetOpts: type conversion (comma-separated lists etc.) + - tlib#arg: validators + - NEW tlib#date#IsDate() + - tlib#balloon#Remove: Unset &ballooneval, &balloonexpr + - NEW tlib#balloon#Expand() + - NEW tlib#date#Format() + - FIX tlib#date#Shift(..., "+Xm") for months + - NEW tlib#trace#Backtrace() + - NEW tlib#type#Is(), tlib#type#Are(), tlib#type#Has(), tlib#type#Have() + - NEW :Tlibassert + MD5 checksum: 3c4125a28ff1860accd254846651c251 +version: "1.17" + + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c3a1fe7d3cd86becbd3f7b0ba7ae9cd8 +version: "1.19" + +version: "1.20" + - tlib#arg: Completion for comma-separated lists + - Use "silent cd" + - NEW tlib#type#DefSchema(); FIX tlib#type#Has() + - tlib#cache#Value(): minor change + - tlib#date#IsDate() also checks whether the date is valid + - ! tlib#sys#Open(): escape special chars only once + - tlib#trace#Print: Allow for strings + - :Tlibtrace, :Tlibtraceset, :Tlibassert remove `-bar` + - NEW :Tlibtype (type/schema assertions); tlib#type#Is() also accepts schemas as "types" + - tlib#dir#CD(): Use haslocaldir() + - tlib#qfl#AgentGotoQFE: Don't use wincmd w + - NEW tlib#string#Input() + - FIX g:tlib#sys#system_rx; add OpenOffice exensions to g:tlib#sys#special_suffixes + - NEW tlib#selection#GetSelection() + - tlib#date#Shift(): Fix "Xm", ++specs + - tlib#trace#Set: FIX Properly handly "-label" + MD5 checksum: c919e0782931a8c628c6996903f989d3 + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - tlib#date#Shift(): Support for business days 'Nb' + - tlib#list#Uniq: Properly handle empty strings + - tlib#trace: Use g:tlib#trace#printer and tlib#trace#Printer_{printer} + - tlib#dictionary#Rev: Optional argument `opts = {}`; properly handle empty values etc. + - NEW g:tlib#trace#hl + - NEW spec/dictionary.vim + - tlib#agent#CompleteAgentNames: case insensitive + - tlib#arg#CComplete: --[no-]debug option + - tlib#date#Format: use localtime() if no arg is provided + - NEW tlib#file#IsAbsolute + - NEW tlib#notify#PrintError() + - tlib#trace#Print: FIX s/exec/call/ + - tlib#type#Is() match full type name + - NEW tlib#string#MatchAll() + - Tlibtraceset, tlib#trace#Set(): If no `+` or `-` is prepended, assume `+`. + - tlib#list#Input: fix highlighting for filenames + - tlib#input#ListW: use world.CloseScratch(1) + - tlib#agent#ViewFile: Ignore errors in :exec back + - NEW tlib#agent#EditFileInWindow() + - :Tlibtraceset uses tlib#arg#GetOpts(), i.e. you can set the log file more easily + MD5 checksum: 20a48e225f32b9f58808096a5377af04 +version: "1.22" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + + - bump version 1.23 + misc changes + - FIX #24: avoid vim8 features + - tlib#win#GetID(): Alternative implementation sets a window variable to identify the window + - tlib#arg#GetOpts(): If args is a dict, return it + - tlib#file#FilterFiles(): FIX typo + - tlib#trace#Set: Experimental support for log levels + - tlib#input#ListW: make sure to close scratch when <= 1 items are in the list + - FIX #25: set win_nr again; fix some lint warnings + - tlib#progressbar#Init(): returns a statusline definition that can be used for restor + MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3 +version: "1.23" + +version: '1.28' + - Remove unnecessary executable flags from files + - Merge pull request #28 from gbence/master + - Fix error E1208 raised by vim >=8.2.3141 + - Merge pull request #30 from stac47/fix_for_vim_8_2_3141 + - Fix win_id format mismatch on vim7 or bellow + - Merge pull request #37 from moodoofish/master + - tlib#number#ConvertBase: support base > 36 + SHA256 checksum: 666e632a1ebacebf6e774cdf5c541418343ce1a3949268685ebcb60e480b9f1d + diff --git a/sources_non_forked/tlib/LICENSE.TXT b/sources_non_forked/tlib/LICENSE.TXT new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/sources_non_forked/tlib/LICENSE.TXT @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/sources_non_forked/tlib/README b/sources_non_forked/tlib/README new file mode 100644 index 00000000..98a20bb6 --- /dev/null +++ b/sources_non_forked/tlib/README @@ -0,0 +1,32 @@ +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + + + + +License: GPLv3 or later + + diff --git a/sources_non_forked/tlib/addon-info.json b/sources_non_forked/tlib/addon-info.json new file mode 100644 index 00000000..35855310 --- /dev/null +++ b/sources_non_forked/tlib/addon-info.json @@ -0,0 +1,9 @@ +{ + "name" : "tlib", + "version" : "dev", + "author" : "Tom Link ", + "maintainer" : "Tom Link ", + "repository" : {"type": "git", "url": "git://github.com/tomtom/tlib_vim.git"}, + "dependencies" : {}, + "description" : "tlib -- A library of vim functions" +} diff --git a/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim b/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim new file mode 100644 index 00000000..908f5f7d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tinykeymap/map/para_move.vim @@ -0,0 +1,12 @@ +" para_move.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-08-28. +" @Last Change: 2012-08-29. +" @Revision: 3 + +" Move paragraphs +call tinykeymap#EnterMap("para_move", "gp", {'name': 'move paragraph'}) +call tinykeymap#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '')") +call tinykeymap#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '')") + diff --git a/sources_non_forked/tlib/autoload/tlib.vim b/sources_non_forked/tlib/autoload/tlib.vim new file mode 100644 index 00000000..5d805ac9 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib.vim @@ -0,0 +1,8 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + +" :nodefault: +TLet g:tlib#debug = 0 + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim new file mode 100644 index 00000000..bfdbda38 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnf.vim @@ -0,0 +1,152 @@ +" Filter_cnf.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2017-09-28. +" @Revision: 11.0.114 + +let s:prototype = tlib#Object#New({'_class': ['Filter_cnf'], 'name': 'cnf'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + +" The search pattern for |tlib#input#List()| is in conjunctive normal +" form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... +" The pattern is a '/\V' very no-'/magic' regexp pattern. +" +" Pressing joins two patterns with AND. +" Pressing | joins two patterns with OR. +" I.e. In order to get "lala AND (foo OR bar)", you type +" "lala foo|bar". +" +" This is also the base class for other filters. +function! tlib#Filter_cnf#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call a:world.PushHelp( + \ printf('"%s", "%s", "%sWORD"', g:tlib#input#and, g:tlib#input#or, g:tlib#input#not), + \ 'AND, OR, NOT') +endf + + +" :nodoc: +function! s:prototype.AssessName(world, name) dict "{{{3 + let xa = 0 + let prefix = self.FilterRxPrefix() + for flt in a:world.filter_pos + " let flt = prefix . a:world.GetRx(fltl) + " if flt =~# '\u' && a:name =~# flt + " let xa += 5 + " endif + let rel = 1.0 + 5.0 * len(flt) / len(a:name) + let xa += float2nr(rel) + if a:name =~ '\^'. flt + let xa += 4 + elseif a:name =~ '\<'. flt + let xa += 3 + " elseif a:name =~ '[[:punct:][:space:][:digit:]]'. flt + " let xa += 2 + elseif a:name =~ '\A'. flt .'\|'. flt .'\A' + let xa += 1 + endif + endfor + " TLogVAR a:name, xa + return xa +endf + + +" :nodoc: +function! s:prototype.Match(world, text) dict "{{{3 + " TLogVAR a:text + " let sc = &smartcase + " let ic = &ignorecase + " if &ignorecase + " set smartcase + " endif + " try + if !empty(a:world.filter_neg) + for rx in a:world.filter_neg + " TLogVAR rx + if a:text =~ rx + return 0 + endif + endfor + endif + if !empty(a:world.filter_pos) + for rx in a:world.filter_pos + " TLogVAR rx + if a:text !~ rx + return 0 + endif + endfor + endif + " finally + " let &smartcase = sc + " let &ignorecase = ic + " endtry + return 1 +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + let filter1 = deepcopy(a:filter) + call map(filter1, '"(". join(reverse(self.Pretty(v:val)), " OR ") .")"') + return join(reverse(filter1), ' AND ') +endf + + +function! s:prototype.Pretty(filter) dict "{{{3 + " call map(a:filter, 'substitute(v:val, ''\\\.\\{-}'', ''=>'', ''g'')') + call map(a:filter, 'self.CleanFilter(v:val)') + return a:filter +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = reverse(split(a:pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let filter = a:world.filter[0][0] + " TLogVAR filter + let str = matchstr(filter, '\(\\\(\.\\{-}\|[.?*+$^]\)\|\)$') + if empty(str) + let filter = filter[0 : -2] + else + let filter = tlib#string#Strcharpart(filter, 0, len(filter) - len(str)) + endif + " TLogVAR str, filter + let a:world.filter[0][0] = filter +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict "{{{3 + return '\V' +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return a:filter +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim new file mode 100644 index 00000000..27f00fe1 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_cnfd.vim @@ -0,0 +1,53 @@ +" Filter_cnfd.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-01-23. +" @Revision: 0.0.57 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_cnfd'], 'name': 'cnfd'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. +" As a consequence, patterns cannot match dots. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_cnfd#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('.', 'Any characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, '\.', '\\.\\{-}', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let a:world.filter[0][0] .= a:char == 46 ? '\.\{-}' : nr2char(a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\.\\{-}', '.', 'g') +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim b/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim new file mode 100644 index 00000000..349bfd57 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_fuzzy.vim @@ -0,0 +1,83 @@ +" Filter_fuzzy.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2013-09-25. +" @Revision: 0.0.47 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_fuzzy'], 'name': 'fuzzy'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" Support for "fuzzy" pattern matching in |tlib#input#List()|. +" Patterns are interpreted as if characters were connected with '.\{-}'. +" +" In "fuzzy" mode, the pretty printing of filenames is disabled. +function! tlib#Filter_fuzzy#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +" :nodoc: +function! s:prototype.Init(world) dict "{{{3 + " TLogVAR a:world.display_format + " :nodoc: + function! a:world.Set_display_format(value) dict + if a:value == 'filename' + let self.display_format = '' + else + let self.display_format = a:value + endif + endf +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp('Patterns are interpreted as if characters were connected with .\{-}') +endf + + +" :nodoc: +function! s:prototype.DisplayFilter(filter) dict "{{{3 + " TLogVAR a:filter + let filter1 = deepcopy(a:filter) + call map(filter1, '"{". join(reverse(v:val), " OR ") ."}"') + return join(reverse(filter1), ' AND ') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let a:world.filter[0] = map(reverse(split(a:pattern, '\s*|\s*')), 'join(map(split(v:val, ''\zs''), ''tlib#rx#Escape(v:val, "V")''), ''\.\{-}'')') + a:world.filter[0][1 : -1] + endif +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + let ch = tlib#rx#Escape(nr2char(a:char), 'V') + if empty(a:world.filter[0][0]) + let a:world.filter[0][0] .= ch + else + let a:world.filter[0][0] .= '\.\{-}'. ch + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFrontFilter(world) dict "{{{3 + let a:world.filter[0][0] = substitute(a:world.filter[0][0], '\(\\\.\\{-}\)\?.$', '', '') +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + return substitute(a:filter, '\\\.\\{-}', '', 'g') +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim new file mode 100644 index 00000000..904b2261 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Filter_glob.vim @@ -0,0 +1,68 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-11-25. +" @Last Change: 2014-11-18. +" @Revision: 0.0.82 + +let s:prototype = tlib#Filter_cnf#New({'_class': ['Filter_glob'], 'name': 'glob'}) "{{{2 +let s:prototype.highlight = g:tlib#input#higroup + + +" A character that should be expanded to '\.\{-}'. +TLet g:tlib#Filter_glob#seq = '*' + + +" A character that should be expanded to '\.\?'. +TLet g:tlib#Filter_glob#char = '?' + + +" The same as |tlib#Filter_cnf#New()| but a a customizable character +" |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and +" |g:tlib#Filter_glob#char| is expanded to '\.'. +" The pattern is a '/\V' very no-'/magic' regexp pattern. +function! tlib#Filter_glob#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +let s:Help = s:prototype.Help + +" :nodoc: +function! s:prototype.Help(world) dict "{{{3 + call call(s:Help, [a:world], self) + call a:world.PushHelp(g:tlib#Filter_glob#seq, 'Any characters') + call a:world.PushHelp(g:tlib#Filter_glob#char, 'Single characters') +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(world, pattern) dict "{{{3 + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#seq, 'V'), '\\.\\{-}', 'g') + let pattern = substitute(a:pattern, tlib#rx#Escape(g:tlib#Filter_glob#char, 'V'), '\\.', 'g') + let a:world.filter[0] = reverse(split(pattern, '\s*|\s*')) + a:world.filter[0][1 : -1] +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(world, char) dict "{{{3 + " TLogVAR a:char, nr2char(a:char) + if a:char == char2nr(g:tlib#Filter_glob#seq) + let char = '\.\{-}' + elseif a:char == char2nr(g:tlib#Filter_glob#char) + let char = '\.' + else + let char = nr2char(a:char) + endif + let a:world.filter[0][0] .= char +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict "{{{3 + let filter = substitute(a:filter, '\\\.\\{-}', g:tlib#Filter_glob#seq, 'g') + let filter = substitute(filter, '\\\.', g:tlib#Filter_glob#char, 'g') + return filter +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Object.vim b/sources_non_forked/tlib/autoload/tlib/Object.vim new file mode 100644 index 00000000..21f38b24 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Object.vim @@ -0,0 +1,154 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 127 + +" :filedoc: +" Provides a prototype plus some OO-like methods. + +let s:id_counter = 0 +let s:prototype = {'_class': ['object'], '_super': [], '_id': 0} "{{{2 + +" :def: function! tlib#Object#New(?fields={}) +" This function creates a prototype that provides some kind of +" inheritance mechanism and a way to call parent/super methods. +" +" The usage demonstrated in the following example works best when every +" class/prototype is defined in a file of its own. +" +" The reason for why there is a dedicated constructor function is that +" this layout facilitates the use of templates and that methods are +" hidden from the user. Other solutions are possible. +" +" EXAMPLES: > +" let s:prototype = tlib#Object#New({ +" \ '_class': ['FooBar'], +" \ 'foo': 1, +" \ 'bar': 2, +" \ }) +" " Constructor +" function! FooBar(...) +" let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) +" return object +" endf +" function! s:prototype.babble() { +" echo "I think, therefore I am ". (self.foo * self.bar) ." months old." +" } +" +" < This could now be used like this: > +" let myfoo = FooBar({'foo': 3}) +" call myfoo.babble() +" => I think, therefore I am 6 months old. +" echo myfoo.IsA('FooBar') +" => 1 +" echo myfoo.IsA('object') +" => 1 +" echo myfoo.IsA('Foo') +" => 0 +" echo myfoo.RespondTo('babble') +" => 1 +" echo myfoo.RespondTo('speak') +" => 0 +function! tlib#Object#New(...) "{{{3 + return s:prototype.New(a:0 >= 1 ? a:1 : {}) +endf + + +function! s:prototype.New(...) dict "{{{3 + let object = deepcopy(self) + let s:id_counter += 1 + let object._id = s:id_counter + if a:0 >= 1 && !empty(a:1) + " call object.Extend(deepcopy(a:1)) + call object.Extend(a:1) + endif + return object +endf + + +function! s:prototype.Inherit(object) dict "{{{3 + let class = copy(self._class) + " TLogVAR class + let objid = self._id + for c in get(a:object, '_class', []) + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:object, 'keep') + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, a:object) + return self +endf + + +function! s:prototype.Extend(dictionary) dict "{{{3 + let super = copy(self) + let class = copy(self._class) + " TLogVAR class + let objid = self._id + let thisclass = get(a:dictionary, '_class', []) + for c in type(thisclass) == 3 ? thisclass : [thisclass] + " TLogVAR c + if index(class, c) == -1 + call add(class, c) + endif + endfor + call extend(self, a:dictionary) + let self._class = class + " TLogVAR self._class + let self._id = objid + " let self._super = [super] + self._super + call insert(self._super, super) + return self +endf + + +function! s:prototype.IsA(class) dict "{{{3 + return index(self._class, a:class) != -1 +endf + + +function! s:prototype.IsRelated(object) dict "{{{3 + return len(filter(a:object._class, 'self.IsA(v:val)')) > 1 +endf + + +function! s:prototype.RespondTo(name) dict "{{{3 + " return has_key(self, a:name) && type(self[a:name]) == 2 + return has_key(self, a:name) +endf + + +function! s:prototype.Super(method, arglist) dict "{{{3 + for o in self._super + " TLogVAR o + if o.RespondTo(a:method) + " let self._tmp_method = o[a:method] + " TLogVAR self._tmp_method + " return call(self._tmp_method, a:arglist, self) + return call(o[a:method], a:arglist, self) + endif + endfor + echoerr 'tlib#Object: Does not respond to '. a:method .': '. string(self) +endf + + +function! tlib#Object#Methods(object, ...) "{{{3 + TVarArg ['pattern', '\d\+'] + let o = items(a:object) + call filter(o, 'type(v:val[1]) == 2 && string(v:val[1]) =~ "^function(''\\d\\+'')"') + let acc = {} + for e in o + let id = matchstr(string(e[1]), pattern) + if !empty(id) + let acc[id] = e[0] + endif + endfor + return acc +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/Test.vim b/sources_non_forked/tlib/autoload/tlib/Test.vim new file mode 100644 index 00000000..4a4281e8 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/Test.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + +" :enddoc: + + +let s:prototype = tlib#Object#New({'_class': ['Test']}) "{{{2 +function! tlib#Test#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'Test.vim' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/TestChild.vim b/sources_non_forked/tlib/autoload/tlib/TestChild.vim new file mode 100644 index 00000000..16979a75 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/TestChild.vim @@ -0,0 +1,19 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 15 + +" :enddoc: + + +let s:prototype = tlib#Test#New({'_class': ['TestChild']}) "{{{2 +function! tlib#TestChild#New(...) "{{{3 + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object +endf + + +function! s:prototype.Dummy() dict "{{{3 + return 'TestChild.vim' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/World.vim b/sources_non_forked/tlib/autoload/tlib/World.vim new file mode 100644 index 00000000..0d0094ab --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/World.vim @@ -0,0 +1,1396 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1482 + + +" :filedoc: +" A prototype used by |tlib#input#List|. +" Inherits from |tlib#Object#New|. + + +" Size of the input list window (in percent) from the main size (of &lines). +" See |tlib#input#List()|. +TLet g:tlib_inputlist_pct = 50 + +" Max height for a horizontal list. +TLet g:tlib_inputlist_max_lines = -1 + +" Max width for a vertical list. +TLet g:tlib_inputlist_max_cols = -1 + +" Size of filename columns when listing filenames. +" See |tlib#input#List()|. +TLet g:tlib_inputlist_width_filename = '&columns / 3' +" TLet g:tlib_inputlist_width_filename = 25 + +" If true, |tlib#input#List()| will show some indicators about the +" status of a filename (e.g. buflisted(), bufloaded() etc.). +" This is disabled by default because vim checks also for the file on +" disk when doing this. +TLet g:tlib_inputlist_filename_indicators = 0 + +" If not null, display only a short info about the filter. +TLet g:tlib_inputlist_shortmessage = 0 + + + +" Known keys & values: +" scratch_split ... See |tlib#scratch#UseScratch()| +let s:prototype = tlib#Object#New({ + \ '_class': 'World', + \ 'name': 'world', + \ 'allow_suspend': 1, + \ 'base': [], + \ 'bufnr': -1, + \ 'buffer_local': 1, + \ 'cache_var': '', + \ 'display_format': '', + \ 'fileencoding': &fileencoding, + \ 'fmt_display': {}, + \ 'fmt_filter': {}, + \ 'fmt_options': {}, + \ 'filetype': '', + \ 'filter': [['']], + \ 'filter_format': '', + \ 'filter_options': '', + \ 'follow_cursor': '', + \ 'has_menu': 0, + \ 'help_extra': [], + \ 'index_table': [], + \ 'initial_filter': [['']], + \ 'initial_index': 1, + \ 'initial_display': 1, + \ 'initialized': 0, + \ 'key_handlers': [], + \ 'list': [], + \ 'matcher': {}, + \ 'next_agent': '', + \ 'next_eval': '', + \ 'next_state': '', + \ 'numeric_chars': g:tlib#input#numeric_chars, + \ 'offset': 1, + \ 'offset_horizontal': 0, + \ 'on_leave': [], + \ 'pick_last_item': tlib#var#Get('tlib#input#pick_last_item', 'bg'), + \ 'post_handlers': [], + \ 'query': '', + \ 'resize': 0, + \ 'resize_vertical': 0, + \ 'restore_from_cache': [], + \ 'filtered_items': [], + \ 'resume_state': '', + \ 'retrieve_eval': '', + \ 'return_agent': '', + \ 'rv': '', + \ 'scratch': '__InputList__', + \ 'scratch_filetype': 'tlibInputList', + \ 'scratch_hidden': g:tlib#scratch#hidden, + \ 'scratch_vertical': 0, + \ 'scratch_split': 1, + \ 'sel_idx': [], + \ 'show_empty': 0, + \ 'state': 'display', + \ 'state_handlers': [], + \ 'sticky': 0, + \ 'temp_lines': [], + \ 'temp_prompt': [], + \ 'timeout': 0, + \ 'timeout_resolution': 2, + \ 'tabpagenr': -1, + \ 'type': '', + \ 'win_id': g:tlib#win#null_id, + \ 'win_height': -1, + \ 'win_width': -1, + \ 'win_pct': 25, + \ }) + " \ 'handlers': [], + " \ 'filter_options': '\c', + +function! tlib#World#New(...) abort + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + call object.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'g', 'cnf')) + return object +endf + + +" :nodoc: +function! s:prototype.Set_display_format(value) dict abort "{{{3 + if a:value ==# 'filename' + call self.Set_highlight_filename() + let self.display_format = 'world.FormatFilename(%s)' + else + let self.display_format = a:value + endif +endf + + +" :nodoc: +function! s:prototype.DisplayFormat(list) dict abort "{{{3 + let display_format = self.display_format + if !empty(display_format) + if has_key(self, 'InitFormatName') + call self.InitFormatName() + endif + let cache = self.fmt_display + Tlibtrace 'tlib', display_format + return map(copy(a:list), 'self.FormatName(cache, display_format, v:val)') + else + return a:list + endif +endf + + +" :nodoc: +function! s:prototype.Set_highlight_filename() dict abort "{{{3 + let self.tlib_UseInputListScratch = 'call world.Highlight_filename()' +endf + + +if g:tlib#input#format_filename ==# 'r' + + " :nodoc: + function! s:prototype.Highlight_filename() dict abort "{{{3 + syntax match TLibDir /\s\+\zs.\{-}[\/]\ze[^\/]\+$/ + hi def link TLibDir Directory + syntax match TLibFilename /[^\/]\+$/ + hi def link TLibFilename Normal + endf + + " :nodoc: + function! s:prototype.FormatFilename(file) dict abort "{{{3 + if !has_key(self.fmt_options, 'maxlen') + let maxco = &columns - len(len(self.base)) - eval(g:tlib#input#filename_padding_r) + let maxfi = max(map(copy(self.base), 'strwidth(v:val)')) + let self.fmt_options.maxlen = min([maxco, maxfi]) + Tlibtrace 'tlib', maxco, maxfi, self.fmt_options.maxlen + endif + let max = self.fmt_options.maxlen + if len(a:file) > max + let filename = '...' . tlib#string#Strcharpart(a:file, len(a:file) - max + 3) + else + let filename = printf('% '. max .'s', a:file) + endif + return filename + endf + +else + + " :nodoc: + function! s:prototype.Highlight_filename() dict abort "{{{3 + " let self.width_filename = 1 + eval(g:tlib_inputlist_width_filename) + Tlibtrace 'tlib', self.base + let self.width_filename = min([ + \ get(self, 'width_filename', &columns), + \ empty(g:tlib#input#filename_max_width) ? &columns : eval(g:tlib#input#filename_max_width), + \ max(map(copy(self.base), 'strwidth(matchstr(v:val, "[^\\/]*$"))')) + \ ]) + " TLogVAR self.width_filename + " exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibDir /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \zs[^&<>*|]*$/ contained containedin=TLibMarker contains=TLibFilename' + exec 'syntax match TLibMarker /\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) \S.*$/ contains=TLibDir' + " exec 'syntax match TLibDir /\(|\|\[.\{-}\]\) \zs\(\(\a:\|\.\.\|\.\.\..\{-}\)\?[\/][^&<>*|]\{-}\)\?[^\/]\+$/ contained containedin=TLibMarker contains=TLibFilename' + " exec 'syntax match TLibMarker /\(|\|\[.\{-}\]\) \S.*$/ contains=TLibDir' + exec 'syntax match TLibFilename /[^\/]\+$/ contained containedin=TLibDir' + hi def link TLibMarker Special + hi def link TLibDir Directory + hi def link TLibFilename NonText + " :nodoc: + function! self.Highlighter(rx) dict abort + let rx = '/\c\%>'. (1 + self.width_filename) .'c \(|\|\[[^]]*\]\) .\{-}\zs'. escape(a:rx, '/') .'/' + exec 'match' self.matcher.highlight rx + endf + endf + + + " :nodoc: + function! s:prototype.UseFilenameIndicators() dict abort "{{{3 + return g:tlib_inputlist_filename_indicators || has_key(self, 'filename_indicators') + endf + + + " :nodoc: + function! s:prototype.InitFormatName() dict abort "{{{3 + if self.UseFilenameIndicators() + let self._buffers = {} + for bufnr in range(1, bufnr('$')) + let filename = fnamemodify(bufname(bufnr), ':p') + Tlibtrace 'tlib', filename + let bufdef = { + \ 'bufnr': bufnr, + \ } + " '&buflisted' + for opt in ['&modified', '&bufhidden'] + let bufdef[opt] = getbufvar(bufnr, opt) + endfor + let self._buffers[filename] = bufdef + endfor + endif + endf + + + " :nodoc: + function! s:prototype.FormatFilename(file) dict abort "{{{3 + Tlibtrace 'tlib', a:file + let width = self.width_filename + let split = match(a:file, '[/\\]\zs[^/\\]\+$') + if split == -1 + let fname = a:file + let dname = a:file + else + let fname = strpart(a:file, split) + " let dname = tlib#string#Strcharpart(a:file, 0, split - 1) + let dname = a:file + endif + if strwidth(fname) > width + let fname = tlib#string#Strcharpart(fname, 0, width - 3) .'...' + endif + let dnmax = &columns - max([width, strwidth(fname)]) - 8 - self.index_width - &foldcolumn + let use_indicators = self.UseFilenameIndicators() + Tlibtrace 'tlib', use_indicators + let marker = [] + if use_indicators + call insert(marker, '[') + if g:tlib_inputlist_filename_indicators + let bufdef = get(self._buffers, a:file, {}) + " let bnr = bufnr(a:file) + let bnr = get(bufdef, 'bufnr', -1) + Tlibtrace 'tlib', a:file, bnr, self.bufnr + if bnr != -1 + if bnr == self.bufnr + call add(marker, '%') + else + call add(marker, bnr) + endif + if get(bufdef, '&modified', 0) + call add(marker, '+') + endif + if get(bufdef, '&bufhidden', '') ==# 'hide' + call add(marker, 'h') + endif + " if !get(bufdef, '&buflisted', 1) + " call add(marker, 'u') + " endif + " echom "DBG" a:file string(get(self,'filename_indicators')) + endif + endif + if has_key(self, 'filename_indicators') && has_key(self.filename_indicators, a:file) + if len(marker) > 1 + call add(marker, '|') + endif + call add(marker, self.filename_indicators[a:file]) + endif + if len(marker) <= 1 + call add(marker, ' ') + endif + call add(marker, ']') + else + call add(marker, '|') + endif + let markers = join(marker, '') + if !empty(markers) + let dnmax -= len(markers) + endif + if strwidth(dname) > dnmax + let dname = '...'. tlib#string#Strcharpart(dname, len(dname) - dnmax) + endif + return printf('%-*s %s %s', + \ self.width_filename + len(fname) - strwidth(fname), + \ fname, markers, dname) + endf + +endif + + +" :nodoc: +function! s:prototype.GetSelectedItems(current) dict abort "{{{3 + Tlibtrace 'tlib', a:current + if stridx(self.type, 'i') != -1 + let rv = copy(self.sel_idx) + else + let rv = map(copy(self.sel_idx), 'self.GetBaseItem(v:val)') + endif + if !empty(a:current) + Tlibtrace 'tlib', a:current, rv, type(a:current) + if tlib#type#IsNumber(a:current) || tlib#type#IsString(a:current) + call s:InsertSelectedItems(rv, a:current) + elseif tlib#type#IsList(a:current) + for item in a:current + call s:InsertSelectedItems(rv, item) + endfor + elseif tlib#type#IsDictionary(a:current) + for [inum, item] in items(a:current) + call s:InsertSelectedItems(rv, item) + endfor + endif + endif + " TAssert empty(rv) || rv[0] == a:current + if stridx(self.type, 'i') != -1 + if !empty(self.index_table) + Tlibtrace 'tlib', rv, self.index_table + call map(rv, 'self.index_table[v:val - 1]') + Tlibtrace 'tlib', rv + endif + endif + return rv +endf + + +function! s:InsertSelectedItems(rv, current) abort "{{{3 + let ci = index(a:rv, a:current) + if ci != -1 + call remove(a:rv, ci) + endif + call insert(a:rv, a:current) +endf + + +" :nodoc: +function! s:prototype.SelectItemsByNames(mode, items) dict abort "{{{3 + for item in a:items + let bi = index(self.base, item) + 1 + Tlibtrace 'tlib', item, bi + if bi > 0 + let si = index(self.sel_idx, bi) + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode ==# 'toggle' + call remove(self.sel_idx, si) + endif + endif + endfor + return 1 +endf + + +" :nodoc: +function! s:prototype.SelectItem(mode, index) dict abort "{{{3 + Tlibtrace 'tlib', a:mode, a:index + let bi = self.GetBaseIdx(a:index) + " if self.RespondTo('MaySelectItem') + " if !self.MaySelectItem(bi) + " return 0 + " endif + " endif + Tlibtrace 'tlib', bi + let si = index(self.sel_idx, bi) + Tlibtrace 'tlib', self.sel_idx + Tlibtrace 'tlib', si + if si == -1 + call add(self.sel_idx, bi) + elseif a:mode ==# 'toggle' + call remove(self.sel_idx, si) + endif + return 1 +endf + + +" :nodoc: +function! s:prototype.FormatBaseFromData() abort dict "{{{3 + if has_key(self, 'format_data') && has_key(self, 'data') + let self.base = map(copy(self.data), 'call(self.format_data, [v:val], self)') + endif +endf + + +" :nodoc: +function! s:prototype.FormatArgs(format_string, arg) dict abort "{{{3 + let nargs = len(substitute(a:format_string, '%%\|[^%]', '', 'g')) + return [a:format_string] + repeat([string(a:arg)], nargs) +endf + + +" :nodoc: +function! s:prototype.GetRx(filter) dict abort "{{{3 + return '\('. join(filter(copy(a:filter), 'v:val[0] !=# "!"'), '\|') .'\)' +endf + + +" :nodoc: +function! s:prototype.GetRx0(...) dict abort "{{{3 + exec tlib#arg#Let(['negative']) + let rx0 = [] + for filter in self.filter + Tlibtrace 'tlib', filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + Tlibtrace 'tlib', rx + if !empty(rx) && (negative ? rx[0] == g:tlib#input#not : rx[0] != g:tlib#input#not) + call add(rx0, rx) + endif + endfor + let rx0s = join(rx0, '\|') + if empty(rx0s) + return '' + else + return self.FilterRxPrefix() .'\('. rx0s .'\)' + endif +endf + + +" :nodoc: +function! s:prototype.FormatName(cache, format, value) dict abort "{{{3 + Tlibtrace 'tlib', a:format, a:value + if has_key(a:cache, a:value) + return a:cache[a:value] + else + let world = self + let ftpl = self.FormatArgs(a:format, a:value) + let fn = call(function('printf'), ftpl) + let fmt = eval(fn) + Tlibtrace 'tlib', ftpl, fn, fmt + let a:cache[a:value] = fmt + return fmt + endif +endf + + +" :nodoc: +function! s:prototype.GetItem(idx) dict abort "{{{3 + return self.list[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.GetListIdx(baseidx) dict abort "{{{3 + " if empty(self.index_table) + let baseidx = a:baseidx + " else + " let baseidx = 0 + self.index_table[a:baseidx - 1] + " Tlibtrace 'tlib', a:baseidx, baseidx, self.index_table + " endif + let rv = index(self.table, baseidx) + Tlibtrace 'tlib', rv, self.table + return rv +endf + + +" :nodoc: +" The first index is 1. +function! s:prototype.GetBaseIdx(idx) dict abort "{{{3 + Tlibtrace 'tlib', a:idx, self.table, self.index_table + if !empty(self.table) && a:idx > 0 && a:idx <= len(self.table) + return self.table[a:idx - 1] + else + return 0 + endif +endf + + +" :nodoc: +function! s:prototype.GetBaseIdx0(idx) dict abort "{{{3 + let idx0 = self.GetBaseIdx(a:idx) - 1 + if idx0 < 0 + call tlib#notify#Echo('TLIB: Internal Error: GetBaseIdx0: idx0 < 0', 'WarningMsg') + endif + return idx0 +endf + + +" :nodoc: +function! s:prototype.GetBaseItem(idx) dict abort "{{{3 + return self.base[a:idx - 1] +endf + + +" :nodoc: +function! s:prototype.SetBaseItem(idx, item) dict abort "{{{3 + let self.base[a:idx - 1] = a:item +endf + + +" :nodoc: +function! s:prototype.GetLineIdx(lnum) dict abort "{{{3 + let line = getline(a:lnum) + let prefidx = substitute(matchstr(line, '^\d\+\ze[*:]'), '^0\+', '', '') + return prefidx +endf + + +" :nodoc: +function! s:prototype.SetPrefIdx() dict abort "{{{3 + " let pref = sort(range(1, self.llen), 'self.SortPrefs') + " let self.prefidx = get(pref, 0, self.initial_index) + let pref_idx = -1 + let pref_weight = -1 + Tlibtrace 'tlib', self.filter_pos, self.filter_neg + let t0 = localtime() + for idx in range(1, self.llen) + let item = self.GetItem(idx) + let weight = self.matcher.AssessName(self, item) + Tlibtrace 'tlib', item, weight + if weight > pref_weight + let pref_idx = idx + let pref_weight = weight + endif + endfor + Tlibtrace 'tlib', localtime() - t0 + Tlibtrace 'tlib', pref_idx + if pref_idx == -1 + let self.prefidx = self.initial_index + else + let self.prefidx = pref_idx + endif +endf + + +" " :nodoc: +" function! s:prototype.GetCurrentItem() dict abort "{{{3 +" let idx = self.prefidx +" Tlibtrace 'tlib', idx +" if stridx(self.type, 'i') != -1 +" return idx +" elseif !empty(self.list) +" if len(self.list) >= idx +" let idx1 = idx - 1 +" let rv = self.list[idx - 1] +" Tlibtrace 'tlib', idx, idx1, rv, self.list +" return rv +" endif +" else +" return '' +" endif +" endf + + +" :nodoc: +function! s:prototype.CurrentItem() dict abort "{{{3 + if stridx(self.type, 'i') != -1 + return self.GetBaseIdx(self.llen == 1 ? 1 : self.prefidx) + else + if self.llen == 1 + Tlibtrace 'tlib', self.llen + return self.list[0] + elseif self.prefidx > 0 + Tlibtrace 'tlib', self.prefidx + " return self.GetCurrentItem() + if len(self.list) >= self.prefidx + let rv = self.list[self.prefidx - 1] + Tlibtrace 'tlib', self.prefidx, len(self.list), rv + return rv + endif + else + return '' + endif + endif +endf + + +" :nodoc: +function! s:prototype.FilterRxPrefix() dict abort "{{{3 + return self.matcher.FilterRxPrefix() +endf + + +" :nodoc: +function! s:prototype.SetFilter() dict abort "{{{3 + " let mrx = '\V'. (a:0 >= 1 && a:1 ? '\C' : '') + let mrx = self.FilterRxPrefix() . self.filter_options + let self.filter_pos = [] + let self.filter_neg = [] + Tlibtrace 'tlib', mrx, self.filter + for filter in self.filter + Tlibtrace 'tlib', filter + let rx = join(reverse(filter(copy(filter), '!empty(v:val)')), '\|') + Tlibtrace 'tlib', rx + if !empty(rx) + if rx =~# '\u' + let mrx1 = mrx .'\C' + else + let mrx1 = mrx + endif + Tlibtrace 'tlib', rx + if rx[0] == g:tlib#input#not + if len(rx) > 1 + call add(self.filter_neg, mrx1 .'\('. rx[1:-1] .'\)') + endif + else + call add(self.filter_pos, mrx1 .'\('. rx .'\)') + endif + endif + endfor + Tlibtrace 'tlib', self.filter_pos, self.filter_neg +endf + + +" :nodoc: +function! s:prototype.IsValidFilter() dict abort "{{{3 + let last = self.FilterRxPrefix() .'\('. self.filter[0][0] .'\)' + Tlibtrace 'tlib', last + Tlibtrace 'tlib', last + try + let a = match('', last) + return 1 + catch + Tlibtrace 'tlib', v:exception + return 0 + endtry +endf + + +" :nodoc: +function! s:prototype.SetMatchMode(match_mode) dict abort "{{{3 + Tlibtrace 'tlib', a:match_mode + if !empty(a:match_mode) + unlet self.matcher + try + let self.matcher = tlib#Filter_{a:match_mode}#New() + call self.matcher.Init(self) + catch /^Vim\%((\a\+)\)\=:E117/ + throw 'tlib: Unknown mode for tlib#input#filter_mode: '. a:match_mode + endtry + endif +endf + + +" function! s:prototype.Match(text) dict abort "{{{3 +" return self.matcher.Match(self, text) +" endf + + +" :nodoc: +function! s:prototype.MatchBaseIdx(idx) dict abort "{{{3 + let text = self.GetBaseItem(a:idx) + if !empty(self.filter_format) + let text = self.FormatName(self.fmt_filter, self.filter_format, text) + endif + Tlibtrace 'tlib', text + " return self.Match(text) + return self.matcher.Match(self, text) +endf + + +" :nodoc: +function! s:prototype.BuildTableList() dict abort "{{{3 + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 + call self.SetFilter() + Tlibtrace 'tlib', self.filter_neg, self.filter_pos + let self.table = range(1, len(self.base)) + Tlibtrace 'tlib', self.filtered_items + let copy_base = 1 + if !empty(self.filtered_items) + let self.table = filter(self.table, 'index(self.filtered_items, v:val) != -1') + let copy_base = 0 + endif + if !empty(self.filter_pos) || !empty(self.filter_neg) + let self.table = filter(self.table, 'self.MatchBaseIdx(v:val)') + let copy_base = 0 + endif + if copy_base + let self.list = copy(self.base) + else + let self.list = map(copy(self.table), 'self.GetBaseItem(v:val)') + endif +endf + + +" :nodoc: +function! s:prototype.ReduceFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + let reduced = 0 + while !reduced + if self.filter[0] == [''] && len(self.filter) > 1 + call remove(self.filter, 0) + elseif empty(self.filter[0][0]) && len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + else + call self.matcher.ReduceFrontFilter(self) + endif + if self.IsValidFilter() + let reduced = 1 + endif + endwh +endf + + +" :nodoc: +" filter is either a string or a list of list of strings. +function! s:prototype.SetInitialFilter(filter) dict abort "{{{3 + " let self.initial_filter = [[''], [a:filter]] + Tlibtrace 'tlib', a:filter + if type(a:filter) == 3 + let self.initial_filter = deepcopy(a:filter) + else + let self.initial_filter = [[a:filter]] + endif +endf + + +" :nodoc: +function! s:prototype.PopFilter() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + if len(self.filter[0]) > 1 + call remove(self.filter[0], 0) + elseif len(self.filter) > 1 + call remove(self.filter, 0) + else + let self.filter[0] = [''] + endif +endf + + +" :nodoc: +function! s:prototype.FilterIsEmpty() dict abort "{{{3 + Tlibtrace 'tlib', self.filter + return self.filter == copy(self.initial_filter) +endf + + +" :nodoc: +function! s:prototype.DisplayFilter() dict abort "{{{3 + let filter1 = copy(self.filter) + call filter(filter1, 'v:val != [""]') + Tlibtrace 'tlib', self.matcher['_class'] + let rv = self.matcher.DisplayFilter(filter1) + let rv = self.CleanFilter(rv) + return rv +endf + + +" :nodoc: +function! s:prototype.SetFrontFilter(pattern) dict abort "{{{3 + call self.matcher.SetFrontFilter(self, a:pattern) +endf + + +" :nodoc: +function! s:prototype.PushFrontFilter(char) dict abort "{{{3 + call self.matcher.PushFrontFilter(self, a:char) +endf + + +" :nodoc: +function! s:prototype.CleanFilter(filter) dict abort "{{{3 + return self.matcher.CleanFilter(a:filter) +endf + + +" :nodoc: +function! s:prototype.UseScratch() dict abort "{{{3 + " if type(self.scratch) != 0 && get(self, 'buffer_local', 1) + " if self.scratch != fnamemodify(self.scratch, ':p') + " let self.scratch = tlib#file#Join([expand('%:p:h'), self.scratch]) + " Tlibtrace 'tlib', self.scratch + " endif + " " let self.scratch_hidden = 'wipe' + " endif + keepjumps keepalt let rv = tlib#scratch#UseScratch(self) + " if expand('%:t') == self.scratch + let b:tlib_world = self + " endif + return rv +endf + + +" :nodoc: +function! s:prototype.CloseScratch(...) dict abort "{{{3 + TVarArg ['reset_scratch', 0] + " TVarArg ['reset_scratch', 1] + Tlibtrace 'tlib', reset_scratch + if self.sticky + return 0 + else + let rv = tlib#scratch#CloseScratch(self, reset_scratch) + Tlibtrace 'tlib', rv + if rv + call self.SwitchWindow('win') + endif + return rv + endif +endf + + +" :nodoc: +function! s:prototype.Initialize() dict abort "{{{3 + let self.initialized = 1 + call self.SetOrigin(1) + call self.Reset(1) + if !empty(self.cache_var) && exists(self.cache_var) + for prop in self.restore_from_cache + exec 'let self[prop] = get('. self.cache_var .', prop, self[prop])' + endfor + exec 'unlet '. self.cache_var + endif +endf + + +" :nodoc: +function! s:prototype.Leave() dict abort "{{{3 + if !empty(self.cache_var) + exec 'let '. self.cache_var .' = self' + endif + for handler in self.on_leave + call call(handler, [self]) + endfor +endf + + +" :nodoc: +function! s:prototype.UseInputListScratch() dict abort "{{{3 + let scratch = self.UseScratch() + if !exists('b:tlib_list_init') + call tlib#autocmdgroup#Init() + autocmd TLib VimResized call feedkeys("\", 't') + " autocmd TLib WinLeave let b:tlib_world_event = 'WinLeave' | call feedkeys("\", 't') + let b:tlib_list_init = 1 + endif + if !exists('w:tlib_list_init') + Tlibtrace 'tlib', scratch + if has_key(self, 'index_next_syntax') + if type(self.index_next_syntax) == 1 + exec 'syntax match InputlListIndex /^\d\+:\s/ nextgroup='. self.index_next_syntax + elseif type(self.index_next_syntax) == 4 + for [n, nsyn] in items(self.index_next_syntax) + let fn = printf('%0'. world.index_width .'d', n) + exec 'syntax match InputlListIndex /^'. fn .':\s/ nextgroup='. nsyn + endfor + endif + else + syntax match InputlListIndex /^\d\+:\s/ + endif + call tlib#hook#Run('tlib_UseInputListScratch', self) + syntax match InputlListCursor /^\d\+\* .*$/ contains=InputlListIndex + syntax match InputlListSelected /^\d\+# .*$/ contains=InputlListIndex + hi def link InputlListIndex Constant + hi def link InputlListCursor Search + hi def link InputlListSelected IncSearch + setlocal nowrap + " hi def link InputlListIndex Special + " let b:tlibDisplayListMarks = {} + let b:tlibDisplayListMarks = [] + let b:tlibDisplayListWorld = self + let w:tlib_list_init = 1 + endif + return scratch +endf + + +" s:prototype.Reset(?initial=0) +" :nodoc: +function! s:prototype.Reset(...) dict abort "{{{3 + TVarArg ['initial', 0] + Tlibtrace 'tlib', initial + Tlibtrace 'tlib', initial, self.initial_filter + let self.state = 'display' + let self.offset = 1 + let self.filter = deepcopy(self.initial_filter) + let self.idx = '' + let self.prefidx = 0 + let self.initial_display = 1 + let self.fmt_display = {} + let self.fmt_filter = {} + call self.UseInputListScratch() + call self.ResetSelected() + call self.Retrieve(!initial) + call self.FormatBaseFromData() + return self +endf + + +" :nodoc: +function! s:prototype.ResetSelected() dict abort "{{{3 + let self.sel_idx = [] +endf + + +" :nodoc: +function! s:prototype.Retrieve(anyway) dict abort "{{{3 + Tlibtrace 'tlib', a:anyway, self.base + if (a:anyway || empty(self.base)) + let ra = self.retrieve_eval + Tlibtrace 'tlib', ra + if !empty(ra) + let back = self.SwitchWindow('win') + let world = self + let self.base = eval(ra) + Tlibtrace 'tlib', self.base + exec back + return 1 + endif + endif + return 0 +endf + + +function! s:FormatHelp(help) abort "{{{3 + Tlibtrace 'tlib', a:help + let max = [0, 0] + for item in a:help + Tlibtrace 'tlib', item + if type(item) == 3 + let itemlen = map(copy(item), 'strwidth(v:val)') + Tlibtrace 'tlib', itemlen + let max = map(range(2), 'max[v:val] >= itemlen[v:val] ? max[v:val] : itemlen[v:val]') + endif + unlet item + endfor + Tlibtrace 'tlib', max + let cols = float2nr((winwidth(0) - &foldcolumn - 1) / (max[0] + max[1] + 2)) + if cols < 1 + let cols = 1 + endif + let fmt = printf('%%%ds: %%-%ds', max[0], max[1]) + Tlibtrace 'tlib', cols, fmt + let help = [] + let idx = -1 + let maxidx = len(a:help) + while idx < maxidx + let push_item = 0 + let accum = [] + for i in range(cols) + let idx += 1 + if idx >= maxidx + break + endif + let item = a:help[idx] + if type(item) == 3 + call add(accum, item) + else + let push_item = 1 + break + endif + unlet item + endfor + if !empty(accum) + call add(help, s:FormatHelpItem(accum, fmt)) + endif + if push_item + call add(help, a:help[idx]) + endif + endwh + Tlibtrace 'tlib', help + return help +endf + + +function! s:FormatHelpItem(item, fmt) abort "{{{3 + let args = [join(repeat([a:fmt], len(a:item)), ' ')] + for item in a:item + Tlibtrace 'tlib', item + let args += item + endfor + Tlibtrace 'tlib', args + return call('printf', args) +endf + + +" :nodoc: +function! s:prototype.InitHelp() dict abort "{{{3 + return [] +endf + + +" :nodoc: +function! s:prototype.PushHelp(...) dict abort "{{{3 + Tlibtrace 'tlib', a:000 + if a:0 == 1 + if type(a:1) == 3 + let self.temp_lines += a:1 + else + call add(self.temp_lines, a:1) + endif + elseif a:0 == 2 + call add(self.temp_lines, a:000) + else + throw 'TLIB: PushHelp: Wrong number of arguments: '. string(a:000) + endif + Tlibtrace 'tlib', helpstring +endf + + +" :nodoc: +function! s:prototype.DisplayHelp() dict abort "{{{3 + let self.temp_lines = self.InitHelp() + call self.PushHelp('', self.key_mode == 'default' ? 'Abort' : 'Reset keymap') + call self.PushHelp('Enter, ', 'Pick the current item') + call self.PushHelp('Mouse', 'L: Pick item, R: Show menu') + call self.PushHelp('', 'Select an item') + call self.PushHelp(', ', 'Reduce filter') + call self.PushHelp('', 'Complete word') + call self.PushHelp(', ', 'Enter command') + + if self.key_mode == 'default' + call self.PushHelp('', 'Reset the display') + call self.PushHelp('Up/Down', 'Next/previous item') + call self.PushHelp('', 'Edit top filter string') + call self.PushHelp('Page Up/Down', 'Scroll') + call self.PushHelp('', 'Enter * Wildcard') + if self.allow_suspend + call self.PushHelp('', 'Suspend/Resume') + call self.PushHelp('', 'Switch to origin') + endif + if stridx(self.type, 'm') != -1 + call self.PushHelp('', '(Un)Select items') + call self.PushHelp('#', '(Un)Select the current item') + call self.PushHelp('', '(Un)Select all items') + call self.PushHelp('', '(Un)Restrict view to selection') + " \ ' ... Show only selected', + endif + endif + + Tlibtrace 'tlib', len(self.temp_lines) + call self.matcher.Help(self) + + Tlibtrace 'tlib', self.key_mode + for handler in values(self.key_map[self.key_mode]) + Tlibtrace 'tlib', handler + let key = get(handler, 'key_name', '') + Tlibtrace 'tlib', key + if !empty(key) + let desc = get(handler, 'help', '') + if empty(desc) + let desc = get(handler, 'agent', '') + endif + call self.PushHelp(key, desc) + endif + endfor + + if !has_key(self.key_map[self.key_mode], 'unknown_key') + call self.PushHelp('Letter', 'Filter the list') + endif + + if self.key_mode == 'default' && !empty(self.help_extra) + call self.PushHelp(self.help_extra) + endif + + Tlibtrace 'tlib', len(self.temp_lines) + call self.PushHelp([ + \ '', + \ 'Matches at word boundaries are prioritized.', + \ ]) + let self.temp_lines = s:FormatHelp(self.temp_lines) + call self.PrintLines() +endf + + +function! s:prototype.PrintLines() dict abort "{{{3 + let self.temp_prompt = ['Press any key to continue.', 'Question'] + call tlib#buffer#DeleteRange('1', '$') + call append(0, self.temp_lines) + call tlib#buffer#DeleteRange('$', '$') + 1 + call self.Resize(len(self.temp_lines), 0) + let self.temp_lines = [] +endf + + +" :nodoc: +function! s:prototype.Resize(hsize, vsize) dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, a:hsize, a:vsize + let world_resize = '' + let winpos = '' + let scratch_split = get(self, 'scratch_split', 1) + Tlibtrace 'tlib', scratch_split + if scratch_split > 0 + if self.scratch_vertical + if a:vsize + let world_resize = 'vert resize '. a:vsize + let winpos = tlib#fixes#Winpos() + " let w:winresize = {'v': a:vsize} + " setlocal winfixwidth + endif + else + if a:hsize + let world_resize = 'resize '. a:hsize + " let w:winresize = {'h': a:hsize} + " setlocal winfixheight + endif + endif + endif + if !empty(world_resize) + Tlibtrace 'tlib', world_resize, winpos + setlocal nowinfixheight + setlocal nowinfixwidth + exec world_resize + setlocal winfixheight + setlocal winfixwidth + if !empty(winpos) + exec winpos + endif + " redraw! + endif +endf + + +" :nodoc: +function! s:prototype.GetResize(size) dict abort "{{{3 + let resize0 = get(self, 'resize', 0) + let resize = empty(resize0) ? 0 : eval(resize0) + Tlibtrace 'tlib', resize0, resize + let resize = resize == 0 ? a:size : min([a:size, resize]) + " let min = self.scratch_vertical ? &cols : &lines + let min1 = (self.scratch_vertical ? self.win_width : self.win_height) * g:tlib_inputlist_pct + let min2 = (self.scratch_vertical ? &columns : &lines) * self.win_pct + let min3 = &previewheight + let min = max([min1, min2]) + let ns = [resize, (min / 100)] + let maxn = self.scratch_vertical ? g:tlib_inputlist_max_cols : g:tlib_inputlist_max_lines + if maxn > 0 + call add(ns, maxn) + endif + let resize = min(ns) + Tlibtrace 'tlib', resize, a:size, min, min1, min2 + return resize +endf + + +" function! s:prototype.DisplayList(?query=self.Query(), ?list=[]) +" :nodoc: +function! s:prototype.DisplayList(...) dict abort "{{{3 + Tlibtrace 'tlib', self.state + let query = a:0 >= 1 ? a:1 : self.Query() + let list = a:0 >= 2 ? a:2 : [] + Tlibtrace 'tlib', query, len(list) + call self.UseScratch() + Tlibtrace 'tlib', self.scratch + " TAssert IsNotEmpty(self.scratch) + if self.state == 'scroll' + call self.ScrollToOffset() + elseif self.state == 'help' + call self.DisplayHelp() + call self.SetStatusline(query) + elseif self.state == 'printlines' + call self.PrintLines() + call self.SetStatusline(query) + else + Tlibtrace 'tlib', query + " let ll = len(list) + let ll = self.llen + " let x = len(ll) + 1 + let x = self.index_width + 1 + Tlibtrace 'tlib', ll + if self.state =~ '\' + call self.Resize(self.GetResize(ll), eval(get(self, 'resize_vertical', 0))) + call tlib#normal#WithRegister('gg"tdG', 't') + let lines = copy(list) + let lines = map(lines, 'substitute(v:val, ''[[:cntrl:][:space:]]'', " ", "g")') + let w = winwidth(0) - &fdc + " let w = winwidth(0) - &fdc - 1 + let lines = map(lines, 'printf("%-'. w .'.'. w .'S", v:val)') + Tlibtrace 'tlib', lines + call append(0, lines) + call tlib#normal#WithRegister('G"tddgg', 't') + endif + Tlibtrace 'tlib', self.prefidx + let base_pref = self.GetBaseIdx(self.prefidx) + Tlibtrace 'tlib', base_pref + if self.state =~ '\' + call filter(b:tlibDisplayListMarks, 'index(self.sel_idx, v:val) == -1 && v:val != base_pref') + Tlibtrace 'tlib', b:tlibDisplayListMarks + call map(b:tlibDisplayListMarks, 'self.DisplayListMark(x, v:val, ":")') + " let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + " call add(b:tlibDisplayListMarks, self.prefidx) + " call self.DisplayListMark(x, self.GetBaseIdx(self.prefidx), '*') + endif + let b:tlibDisplayListMarks = map(copy(self.sel_idx), 'self.DisplayListMark(x, v:val, "#")') + call add(b:tlibDisplayListMarks, base_pref) + call self.DisplayListMark(x, base_pref, '*') + call self.SetOffset() + call self.SetStatusline(query) + Tlibtrace 'tlib', self.offset + call self.ScrollToOffset() + let rx0 = self.GetRx0() + Tlibtrace 'tlib', rx0 + if !empty(self.matcher.highlight) + if empty(rx0) + match none + elseif self.IsValidFilter() + if has_key(self, 'Highlighter') + call self.Highlighter(rx0) + else + exec 'match '. self.matcher.highlight .' /\c'. escape(rx0, '/') .'/' + endif + endif + endif + endif + redraw +endf + + +" :nodoc: +function! s:prototype.SetStatusline(query) dict abort "{{{3 + Tlibtrace 'tlib', a:query + if !empty(self.temp_prompt) + let echo = get(self.temp_prompt, 0, '') + let hl = get(self.temp_prompt, 1, 'Normal') + let self.temp_prompt = [] + else + let hl = 'Normal' + let query = a:query + let options = [self.matcher.name] + if self.sticky + call add(options, '#') + endif + if self.key_mode != 'default' + call add(options, 'map:'. self.key_mode) + endif + if !empty(self.filtered_items) + if g:tlib_inputlist_shortmessage + call add(options, 'R') + else + call add(options, 'restricted') + endif + endif + if !empty(options) + let sopts = printf('[%s]', join(options, ', ')) + " let echo = query . repeat(' ', &columns - len(sopts) - len(query) - 20) . sopts + let echo = query . ' ' . sopts + " let query .= '%%='. sopts .' ' + endif + Tlibtrace 'tlib', &l:statusline, query + " let &l:statusline = query + endif + echo + if hl != 'Normal' + exec 'echohl' hl + echo echo + echohl None + else + echo echo + endif +endf + + +" :nodoc: +function! s:prototype.Query() dict abort "{{{3 + let flt = self.DisplayFilter() + if g:tlib_inputlist_shortmessage + let query = 'Filter: '. flt + else + let query = self.query .' (filter: '. flt .'; press for help)' + endif + return query +endf + + +" :nodoc: +function! s:prototype.ScrollToOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.scratch_vertical, self.llen, winheight(0) + exec 'norm! '. self.offset .'zt' +endf + + +" :nodoc: +function! s:prototype.SetOffset() dict abort "{{{3 + Tlibtrace 'tlib', self.prefidx, self.offset + let listtop = len(self.list) - winheight(0) + 1 + if listtop < 1 + let listtop = 1 + endif + if self.prefidx > listtop + let self.offset = listtop + elseif self.prefidx > self.offset + winheight(0) - 1 + let listoff = self.prefidx - winheight(0) + 1 + let self.offset = min([listtop, listoff]) + " TLogVAR self.prefidx + " TLogVAR listtop, listoff, self.offset + elseif self.prefidx < self.offset + let self.offset = self.prefidx + endif + Tlibtrace 'tlib', self.offset +endf + + +" :nodoc: +function! s:prototype.ClearAllMarks() dict abort "{{{3 + let x = self.index_width + 1 + call map(range(1, line('$')), 'self.DisplayListMark(x, v:val, ":")') +endf + + +" :nodoc: +function! s:prototype.MarkCurrent(y) dict abort "{{{3 + let x = self.index_width + 1 + call self.DisplayListMark(x, a:y, '*') +endf + + +" :nodoc: +function! s:prototype.DisplayListMark(x, y, mark) dict abort "{{{3 + Tlibtrace 'tlib', a:y, a:mark + if a:x > 0 && a:y >= 0 + let sy = self.GetListIdx(a:y) + 1 + Tlibtrace 'tlib', sy + if sy >= 1 + call setpos('.', [0, sy, a:x, 0]) + exec 'norm! r'. a:mark + " exec 'norm! '. a:y .'gg'. a:x .'|r'. a:mark + endif + endif + return a:y +endf + + +" :nodoc: +function! s:prototype.SwitchWindow(where) dict abort "{{{3 + " if self.tabpagenr != tabpagenr() + " call tlib#tab#Set(self.tabpagenr) + " endif + " let wnr = get(self, a:where.'_wnr') + " Tlibtrace 'tlib', self, wnr + " return tlib#win#Set(wnr) + return tlib#win#SetById(self[a:where .'_id']) +endf + + +" :nodoc: +function! s:prototype.FollowCursor() dict abort "{{{3 + if !empty(self.follow_cursor) + let back = self.SwitchWindow('win') + Tlibtrace 'tlib', back + try + call call(self.follow_cursor, [self, [self.CurrentItem()]]) + finally + exec back + endtry + endif +endf + + +" :nodoc: +function! s:prototype.SetOrigin(...) dict abort "{{{3 + TVarArg ['winview', 0] + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, bufnr('%'), winnr() + let self.win_wnr = winnr() + let self.win_id = tlib#win#GetID() + let self.win_height = winheight(self.win_wnr) + let self.win_width = winwidth(self.win_wnr) + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.win_height, self.win_width, bufnr('%'), winnr() + let self.bufnr = bufnr('%') + let self.tabpagenr = tabpagenr() + let self.cursor = getpos('.') + if winview + let self.winview = tlib#win#GetLayout() + endif + Tlibtrace 'tlib', 'SetOrigin', self.win_id, self.bufnr, get(self,'winview','') + return self +endf + + +" :nodoc: +function! s:prototype.RestoreWindow(...) dict abort "{{{3 + TVarArg ['winview', 0] + if winview + Tlibtrace 'tlib', winview + call tlib#win#SetLayout(self.winview) + endif + call tlib#win#GotoID(self.win_id) +endf + + +" :nodoc: +function! s:prototype.RestoreOrigin(...) dict abort "{{{3 + call call(self.RestoreWindow, a:000) + if bufnr('%') != self.bufnr + exec 'buffer! '. self.bufnr + call setpos('.', self.cursor) + endif +endf + + +function! s:prototype.Suspend() dict abort "{{{3 + call tlib#agent#Suspend(self, self.rv) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/agent.vim b/sources_non_forked/tlib/autoload/tlib/agent.vim new file mode 100644 index 00000000..96f75274 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/agent.vim @@ -0,0 +1,716 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 362 + +" :filedoc: +" Various agents for use as key handlers in tlib#input#List() + +" Number of items to move when pressing in the input list window. +TLet g:tlib_scroll_lines = 10 + + +" General {{{1 + +function! tlib#agent#Exit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if a:world.key_mode ==# 'default' + call a:world.CloseScratch() + let a:world.state = 'exit empty escape' + let a:world.list = [] + " let a:world.base = [] + call a:world.ResetSelected() + else + let a:world.key_mode = 'default' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#CopyItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let @* = join(a:selected, "\n") + let a:world.state = 'redisplay' + return a:world +endf + + + +" InputList related {{{1 + +function! tlib#agent#PageUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset -= (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#PageDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset += (winheight(0) / 2) + let a:world.state = 'scroll' + return a:world +endf + + +function! tlib#agent#Home(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.prefidx = 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#End(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.prefidx = len(a:world.list) + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Up(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines + let a:world.idx = '' + if a:world.prefidx > lines + let a:world.prefidx -= lines + else + let a:world.prefidx = len(a:world.list) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Down(world, selected, ...) "{{{3 + TVarArg ['lines', 1] + Tlibtrace 'tlib', a:selected, lines + let a:world.idx = '' + if a:world.prefidx <= (len(a:world.list) - lines) + let a:world.prefidx += lines + else + let a:world.prefidx = 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#UpN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Up(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#DownN(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Down(a:world, a:selected, g:tlib_scroll_lines) +endf + + +function! tlib#agent#ShiftLeft(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset_horizontal -= (winwidth(0) / 2) + if a:world.offset_horizontal < 0 + let a:world.offset_horizontal = 0 + endif + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#ShiftRight(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.offset_horizontal += (winwidth(0) / 2) + let a:world.state = 'display shift' + return a:world +endf + + +function! tlib#agent#Reset(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#ToggleRestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if empty(a:world.filtered_items) + return tlib#agent#RestrictView(a:world, a:selected) + else + return tlib#agent#UnrestrictView(a:world, a:selected) + endif +endf + + +function! tlib#agent#RestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let filtered_items = map(copy(a:selected), 'index(a:world.base, v:val) + 1') + Tlibtrace 'tlib', 1, filtered_items + let filtered_items = filter(filtered_items, 'v:val > 0') + Tlibtrace 'tlib', 2, filtered_items + if !empty(filtered_items) + let a:world.filtered_items = filtered_items + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#UnrestrictView(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.filtered_items = [] + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Input(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + let flt1 = input('Filter: ', flt0) + echo + if flt1 != flt0 + if empty(flt1) + call getchar(0) + else + call a:world.SetFrontFilter(flt1) + endif + endif + let a:world.state = 'display' + return a:world +endf + + +" Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the +" original position in the parent window. +function! tlib#agent#SuspendToParentWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let world = a:world + let wid = world.win_id + Tlibtrace 'tlib', wid + if wid != -1 + let world = tlib#agent#Suspend(world, a:selected) + if world.state =~# '\' + call world.SwitchWindow('win') + " let pos = world.cursor + " Tlibtrace 'tlib', pos + " if !empty(pos) + " call setpos('.', pos) + " endif + return world + endif + endif + let world.state = 'redisplay' + return world +endf + + +" Suspend lets you temporarily leave the input loop of +" |tlib#input#List|. You can resume editing the list by pressing , +" . , or in the suspended window. +" and will immediatly select the item under the cursor. +" < will select the item but the window will remain opened. +function! tlib#agent#Suspend(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if a:world.allow_suspend + " TAssert IsNotEmpty(a:world.scratch) + " TLogDBG bufnr('%') + let br = tlib#buffer#Set(a:world.scratch) + Tlibtrace 'tlib', br, a:world.bufnr, a:world.scratch + if bufnr('%') != a:world.scratch + echohl WarningMsg + echom "tlib#agent#Suspend: Internal error: Not a scratch buffer:" bufname('%') + echohl NONE + endif + Tlibtrace 'tlib', bufnr('%'), bufname('%'), a:world.scratch + call tlib#autocmdgroup#Init() + exec 'autocmd TLib BufEnter call tlib#input#Resume("world", 0, '. a:world.scratch .')' + let b:tlib_world = a:world + exec br + let a:world.state = 'exit suspend' + else + echom 'Suspend disabled' + let a:world.state = 'redisplay' + endif + return a:world +endf + + +function! tlib#agent#Help(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'help' + return a:world +endf + + +function! tlib#agent#OR(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + call insert(a:world.filter[0], '') + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#AND(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + call insert(a:world.filter, ['']) + endif + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#ReduceFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.ReduceFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#PopFilter(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.PopFilter() + let a:world.offset = 1 + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Debug(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + " echo string(world.state) + echo string(a:world.filter) + echo string(a:world.idx) + echo string(a:world.prefidx) + echo string(a:world.sel_idx) + call getchar() + let a:world.state = 'display' + return a:world +endf + + +function! tlib#agent#Select(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + " let a:world.state = 'display keepcursor' + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectUp(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx > 1 + let a:world.prefidx -= 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectDown(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.SelectItem('toggle', a:world.prefidx) + if a:world.prefidx < len(a:world.list) + let a:world.prefidx += 1 + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#SelectAll(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let listrange = range(1, len(a:world.list)) + let mode = empty(filter(copy(listrange), 'index(a:world.sel_idx, a:world.GetBaseIdx(v:val)) == -1')) + \ ? 'toggle' : 'set' + for i in listrange + call a:world.SelectItem(mode, i) + endfor + let a:world.state = 'display keepcursor' + return a:world +endf + + +function! tlib#agent#ToggleStickyList(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.sticky = !a:world.sticky + let a:world.state = 'display keepcursor' + return a:world +endf + + + +" EditList related {{{1 + +function! tlib#agent#EditItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let lidx = a:world.prefidx + Tlibtrace 'tlib', lidx + let bidx = a:world.GetBaseIdx(lidx) + Tlibtrace 'tlib', bidx + let item = a:world.GetBaseItem(bidx) + let item = input(lidx .'@'. bidx .': ', item) + if item != '' + call a:world.SetBaseItem(bidx, item) + endif + let a:world.state = 'display' + return a:world +endf + + +" Insert a new item below the current one. +function! tlib#agent#NewItem(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let basepi = a:world.GetBaseIdx(a:world.prefidx) + let item = input('New item: ') + call insert(a:world.base, item, basepi) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#DeleteItems(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let remove = copy(a:world.sel_idx) + let basepi = a:world.GetBaseIdx(a:world.prefidx) + if index(remove, basepi) == -1 + call add(remove, basepi) + endif + " call map(remove, 'a:world.GetBaseIdx(v:val)') + for idx in reverse(sort(remove)) + call remove(a:world.base, idx - 1) + endfor + let a:world.state = 'display' + call a:world.ResetSelected() + " let a:world.state = 'reset' + return a:world +endf + + +function! tlib#agent#Cut(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let world = tlib#agent#Copy(a:world, a:selected) + return tlib#agent#DeleteItems(world, a:selected) +endf + + +function! tlib#agent#Copy(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.clipboard = [] + let bidxs = copy(a:world.sel_idx) + call add(bidxs, a:world.GetBaseIdx(a:world.prefidx)) + for bidx in sort(bidxs) + call add(a:world.clipboard, a:world.GetBaseItem(bidx)) + endfor + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Paste(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if has_key(a:world, 'clipboard') + for e in reverse(copy(a:world.clipboard)) + call insert(a:world.base, e, a:world.prefidx) + endfor + endif + let a:world.state = 'display' + call a:world.ResetSelected() + return a:world +endf + + +function! tlib#agent#EditReturnValue(world, rv) "{{{3 + Tlibtrace 'tlib', a:rv + return [a:world.state !~ '\', a:world.base] +endf + + + +" Files related {{{1 + +function! tlib#agent#ViewFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + Tlibtrace 'tlib', back + for filename in a:selected + call tlib#file#Edit(filename) + endfor + call a:world.SetOrigin(1) + silent! exec back + let a:world.state = 'display' + endif + return a:world +endf + + +function! tlib#agent#EditFile(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + return tlib#agent#Exit(tlib#agent#ViewFile(a:world, a:selected), a:selected) +endf + + +function! tlib#agent#EditFileInSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('split', 'sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInVSplit(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + let winpos = tlib#fixes#Winpos() + call tlib#file#With('vertical split', 'vertical sbuffer', a:selected, a:world, 1) + if !empty(winpos) + exec winpos + endif + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInTab(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('tabedit', 'tab sbuffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#EditFileInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + call a:world.CloseScratch() + call tlib#file#With('hide edit', 'hide buffer', a:selected, a:world, 1) + call a:world.SetOrigin(1) + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#ToggleScrollbind(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.scrollbind = get(a:world, 'scrollbind') ? 0 : 1 + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ShowInfo(world, selected) + Tlibtrace 'tlib', a:selected + let lines = [] + for f in a:selected + if filereadable(f) + let desc = [getfperm(f), strftime('%c', getftime(f)), getfsize(f) .' bytes', getftype(f)] + call add(lines, fnamemodify(f, ':p')) + call add(lines, ' '. join(desc, '; ')) + endif + endfor + let a:world.temp_lines = lines + let a:world.state = 'printlines' + return a:world +endf + + + +" Buffer related {{{1 + +function! tlib#agent#ViewBufferInWindow(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let back = a:world.SwitchWindow('win') + Tlibtrace 'tlib', back + for bufname in a:selected + let cmd = &modified && !&hidden ? 'sbuffer' : 'buffer' + exec cmd fnameescape(bufname) + endfor + " exec back + endif + return tlib#agent#Exit(a:world, a:selected) +endf + + +function! tlib#agent#PreviewLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let l = a:selected[0] + " let ww = winnr() + let wid = tlib#win#GetID() + call tlib#agent#SuspendToParentWindow(a:world, a:selected) + call tlib#buffer#ViewLine(l, 1) + call tlib#win#GotoID(wid) + " exec ww .'wincmd w' + let a:world.state = 'redisplay' + return a:world +endf + + +" If not called from the scratch, we assume/guess that we don't have to +" suspend the input-evaluation loop. +function! tlib#agent#GotoLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let l = a:selected[0] + if a:world.win_id != tlib#win#GetID() + let world = tlib#agent#Suspend(a:world, a:selected) + call tlib#win#GotoID(a:world.win_id) + endif + call tlib#buffer#ViewLine(l, 1) + + endif + return a:world +endf + + +function! tlib#agent#DoAtLine(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:selected) + let cmd = input('Command: ', '', 'command') + if !empty(cmd) + call a:world.SwitchWindow('win') + " let pos = getpos('.') + let view = winsaveview() + for l in a:selected + call tlib#buffer#ViewLine(l, '') + exec cmd + endfor + " call setpos('.', pos) + call winrestview(view) + endif + endif + call a:world.ResetSelected() + let a:world.state = 'exit' + return a:world +endf + + +function! tlib#agent#Wildcard(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + if !empty(a:world.filter[0]) + let rx_type = a:world.matcher.FilterRxPrefix() + let flt0 = a:world.CleanFilter(a:world.filter[0][0]) + if rx_type == '\V' + let flt0 .= '\.\{-}' + else + let flt0 .= '.\{-}' + endif + call a:world.SetFrontFilter(flt0) + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#Null(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#agent#ExecAgentByName(world, selected) "{{{3 + Tlibtrace 'tlib', a:selected + let s:agent_names_world = a:world + let agent_names = {'Help': 'tlib#agent#Help'} + for def in values(a:world.key_map[a:world.key_mode]) + if has_key(def, 'help') && !empty(def.help) && has_key(def, 'agent') && !empty(def.agent) + let agent_names[def.help] = def.agent + endif + endfor + let s:agent_names = sort(keys(agent_names)) + let command = input('Command: ', '', 'customlist,tlib#agent#CompleteAgentNames') + Tlibtrace 'tlib', command + if !has_key(agent_names, command) + Tlibtrace 'tlib', command + silent! let matches = filter(keys(agent_names), 'v:val =~ command') + Tlibtrace 'tlib', matches + if len(matches) == 1 + let command = matches[0] + endif + endif + if has_key(agent_names, command) + let agent = agent_names[command] + return call(agent, [a:world, a:selected]) + else + if !empty(command) + echohl WarningMsg + echom "Unknown command:" command + echohl NONE + sleep 1 + endif + let a:world.state = 'display' + return a:world + endif +endf + + +function! tlib#agent#CompleteAgentNames(ArgLead, CmdLine, CursorPos) + let arglead = tolower(a:Arglead) + return filter(copy(s:agent_names), 'stridx(tolower(v:val), arglead) != -1') +endf + + +function! tlib#agent#Complete(world, selected) abort "{{{3 + Tlibtrace 'tlib', a:selected + let rxprefix = a:world.matcher.FilterRxPrefix() + let flt = a:world.filter[0][0] + Tlibtrace 'tlib', flt + let fltrx = rxprefix . flt . '\m[^[:space:][:cntrl:][:punct:]<>*+?&~{}()\[\]\\/]\+' + let fltrx0 = '\m^' . fltrx + Tlibtrace 'tlib', fltrx, fltrx0 + let words = {} + for item in a:world.list + let parts = split(item, '\ze'. fltrx) + Tlibtrace 'tlib', item, parts + for part in parts + let word = matchstr(part, fltrx0) + Tlibtrace 'tlib', part, word + if !empty(word) + let words[word] = 1 + endif + endfor + endfor + Tlibtrace 'tlib', keys(words) + let completions = keys(words) + " let completions = filter(keys(words), 'matchstr(v:val, fltrx0)') + let completions = sort(completions, 's:SortCompletions') + let completions = tlib#list#Uniq(completions) + Tlibtrace 'tlib', 0, completions + while len(completions) > 1 + let nchar = strwidth(completions[0]) - 1 + let completions = map(completions, 'tlib#string#Strcharpart(v:val, 0, nchar)') + Tlibtrace 'tlib', 'reduce', completions + let completions = tlib#list#Uniq(completions) + Tlibtrace 'tlib', 'unique', len(completions), completions + endwh + Tlibtrace 'tlib', 9, completions + if empty(completions) + let a:world.state = 'redisplay update' + else + let a:world.filter[0][0] = completions[0] + let a:world.state = 'display update' + endif + return a:world +endf + + +function! s:SortCompletions(a, b) abort "{{{3 + let i1 = strwidth(a:a) + let i2 = strwidth(a:b) + return i2 - i1 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/arg.vim b/sources_non_forked/tlib/autoload/tlib/arg.vim new file mode 100644 index 00000000..498e6c73 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/arg.vim @@ -0,0 +1,342 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-09-28. +" @Revision: 273 + + +" :def: function! tlib#arg#Get(n, var, ?default="", ?test='') +" Set a positional argument from a variable argument list. +" See tlib#string#RemoveBackslashes() for an example. +function! tlib#arg#Get(n, var, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let atest = a:0 >= 2 ? a:2 : '' + " TLogVAR default, atest + if !empty(atest) + let atest = ' && (a:'. a:n .' '. atest .')' + endif + let test = printf('a:0 >= %d', a:n) . atest + return printf('let %s = %s ? a:%d : %s', a:var, test, a:n, string(default)) +endf + + +" :def: function! tlib#arg#Let(list, ?default='') +" Set a positional arguments from a variable argument list. +" See tlib#input#List() for an example. +function! tlib#arg#Let(list, ...) "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let list = map(copy(a:list), 'type(v:val) == 3 ? v:val : [v:val, default]') + let args = map(range(1, len(list)), 'call("tlib#arg#Get", [v:val] + list[v:val - 1])') + return join(args, ' | ') +endf + + +" :def: function! tlib#arg#StringAsKeyArgs(string, ?keys=[], ?evaluate=0, ?sep=':', ?booleans=0) +function! tlib#arg#StringAsKeyArgs(string, ...) "{{{1 + TVarArg ['keys', {}], ['evaluate', 0], ['sep', ':'], ['booleans', 0] + let keyargs = {} + let args = split(a:string, '\\\@= 0 + let keyargs['__posargs__'] = range(0, pos) + endif + return keyargs +endf + + +function! tlib#arg#StringAsKeyArgsEqual(string) "{{{1 + return tlib#arg#StringAsKeyArgs(a:string, [], 0, '=', 1) +endf + + +" :display: tlib#arg#GetOpts(args, ?def={}) +" Convert a list of strings of command-line arguments into a dictonary. +" +" The main use case is to pass [], i.e. the command-line +" arguments of a command as list, from a command definition to this +" function. +" +" Example: +" ['-h'] +" => If def contains a 'help' key, invoke |:help| on its value. +" +" ['-ab', '--foo', '--bar=BAR', 'bla', bla'] +" => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} +" +" ['-ab', '--', '--foo', '--bar=BAR'] +" => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} +function! tlib#arg#GetOpts(args, ...) abort "{{{3 + if type(a:args) == 4 + reutrn a:args + else + let throw = a:0 == 0 + TVarArg ['def', {}] + " TLogVAR def + let opts = {'__exit__': 0} + for [key, vdef] in items(get(def, 'values', {})) + if has_key(vdef, 'default') + let opts[key] = vdef.default + endif + endfor + let idx = 0 + for o in a:args + let [break, idx] = s:SetOpt(def, opts, idx, o) + if break == 1 + break + elseif break == 2 + if throw + throw 'tlib#arg#GetOpts: Show help' + else + let opts.__exit__ = 5 + endif + endif + endfor + let opts.__rest__ = a:args[idx : -1] + return opts + endif +endf + + +function! s:GetValueType(def) abort "{{{3 + return get(a:def, 'type', type(get(a:def, 'default', ''))) +endf + + +function! s:SetOpt(def, opts, idx, opt) abort "{{{3 + " TLogVAR a:def + let idx = a:idx + 1 + let break = 0 + let long = get(a:def, 'long', 1) + let short = get(a:def, 'short', 1) + if (short && a:opt =~# '^-[?h]$') || (long && a:opt ==# '--help') + if has_key(a:def, 'help') + exec 'help' a:def.help + else + " TLogVAR a:def + let values = get(a:def, 'values', {}) + let flags = get(a:def, 'flags', {}) + if empty(values) && empty(flags) + echom 'No help' + else + if !empty(values) + echom 'Options:' + for [key, vdef] in sort(items(values)) + let opt = key + let default = get(vdef, 'default', '') + let type = s:GetValueType(vdef) + if default =~ '^-\?\d\+\%(\.\d\+\)$' + if type == -1 || type == 6 + let opt .= ' (flag)' + elseif type == 1 + let opt .= '=INT' + else + let opt .= '=INT or maybe BOOL' + endif + elseif type(default) == 1 + let opt .= '=STRING' + elseif type(default) == 3 + let opt .= '=COMMA-LIST' + endif + echom printf(' --%20s (default: %s)', opt, string(default)) + endfor + endif + if !empty(flags) + echom 'Short flags:' + for [sflag, lflag] in sort(items(flags)) + echom printf(' -%s -> %s', sflag, lflag) + endfor + endif + endif + endif + let break = 2 + elseif long && a:opt =~# '^--\%(no-\)\?debug$' + if has_key(a:def, 'trace') + let mod = a:opt =~# '--no-' ? '-' : '+' + exec 'Tlibtraceset' mod . a:def.trace + endif + elseif long && a:opt =~# '^--no-.\+' + let key = matchstr(a:opt, '^--no-\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 0) + elseif long && a:opt =~# '^--\w\+$' + let key = matchstr(a:opt, '^--\zs.\+$') + let a:opts[key] = s:Validate(a:def, key, 1) + elseif long && a:opt =~# '^--\w\+=' + let ml = matchlist(a:opt, '^--\(\w\+\)=\(.*\)$') + if empty(ml) + throw 'tlib#arg#GetOpts: Cannot parse: '. a:opt + else + let values = get(a:def, 'values', {}) + if has_key(values, ml[1]) + let vdef = values[ml[1]] + let type = s:GetValueType(vdef) + if type == -1 + let opt_value = !!str2nr(ml[2]) + elseif type == 0 + let opt_value = str2nr(ml[2]) + elseif type == 1 + let opt_value = ml[2] + elseif type == 2 + let opt_value = function(ml[2]) + elseif type == 3 + let opt_value = tlib#string#SplitCommaList(ml[2]) + elseif type == 4 + throw 'tlib#arg#GetOpts: Unsupported type conversion for '. ml[1] + elseif type == 5 + let opt_value = str2float(ml[2]) + endif + else + let opt_value = ml[2] + endif + let a:opts[ml[1]] = s:Validate(a:def, ml[1], opt_value) + unlet opt_value + endif + elseif short && a:opt =~# '^-\w=' + let flagdefs = get(a:def, 'flags', {}) + let flag = matchstr(a:opt, '^-\zs\w') + let rest = matchstr(a:opt, '^-\w\zs.*$') + call s:SetFlag(a:def, a:opts, idx, flag, rest, flagdefs) + elseif short && a:opt =~# '^-\w\+$' + let flagdefs = get(a:def, 'flags', {}) + for flag in split(substitute(a:opt, '^-', '', ''), '\zs') + call s:SetFlag(a:def, a:opts, idx, flag, '', flagdefs) + endfor + else + let break = 1 + if a:opt !=# '--' + let idx -= 1 + endif + endif + return [break, idx] +endf + + +function! s:SetFlag(def, opts, idx, flag, rest, flagdefs) abort "{{{3 + " TLogVAR a:def + if has_key(a:flagdefs, a:flag) + call s:SetOpt(a:def, a:opts, a:idx, a:flagdefs[a:flag] . a:rest) + else + let a:opts[a:flag] = s:Validate(a:def, a:flag, 1) + endif +endf + + +function! s:Validate(def, name, value) abort "{{{3 + let values = get(a:def, 'values', {}) + if has_key(values, a:name) + let vdef = values[a:name] + if has_key(vdef, 'validate') + if !call(vdef.validate, [a:value]) + throw printf('tlib#arg: %s has invalid value: %s', string(a:name), string(a:value)) + endif + endif + endif + return a:value +endf + + +":nodoc: +function! tlib#arg#CComplete(def, ArgLead) abort "{{{3 + let values = get(a:def, 'values', {}) + let opt = matchstr(a:ArgLead, '^--\zs\w\+\ze=') + if has_key(values, opt) + let words = [] + let vals = values[opt] + let complete_customlist = get(vals, 'complete_customlist', '') + if !empty(complete_customlist) + let words = eval(complete_customlist) + " else + " let complete = get(vals, 'complete', '') + " if !empty(complete) + " endif + endif + if !empty(words) + let prefix = matchstr(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*') + let lead = substitute(a:ArgLead, '^--\w\+=\%([^,]\+,\s*\)*', '', '') + " TLogVAR a:ArgLead, lead + if !empty(lead) + let nchar = len(lead) + call filter(words, 'tlib#string#Strcharpart(v:val, 0, nchar) ==# lead') + endif + let words = map(words, 'prefix . v:val') + return sort(words) + endif + endif + let cs = {'-h': 1, '--help': 1} + for [name, vdef] in items(values) + let type = s:GetValueType(vdef) + if type >= 0 + let name .= '=' + else + let cs['--no-'. name] = 1 + endif + let cs['--'. name] = 1 + endfor + for [name, subst] in items(get(a:def, 'flags', {})) + let ldef = get(values, substitute(subst, '^--', '', ''), {}) + let type = s:GetValueType(ldef) + if type >= 0 + let name .= '=' + endif + let cs['-'. name] = 1 + endfor + if has_key(a:def, 'trace') + let cs['--debug'] = 1 + endif + let nchar = len(a:ArgLead) + if nchar > 0 + call filter(cs, 'tlib#string#Strcharpart(v:key, 0, nchar) ==# a:ArgLead') + endif + return sort(keys(cs)) +endf + + + +""" Command line {{{1 + +" :def: function! tlib#arg#Ex(arg, ?chars='%#! ') +" Escape some characters in a string. +" +" Use |fnamescape()| if available. +" +" EXAMPLES: > +" exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +function! tlib#arg#Ex(arg, ...) "{{{3 + if exists('*fnameescape') && a:0 == 0 + return fnameescape(a:arg) + else + " let chars = '%# \' + let chars = '%#! ' + if a:0 >= 1 + let chars .= a:1 + endif + return escape(a:arg, chars) + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/assert.vim b/sources_non_forked/tlib/autoload/tlib/assert.vim new file mode 100644 index 00000000..3d58f59d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/assert.vim @@ -0,0 +1,44 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-02-22 +" @Revision: 42 + + +" Enable tracing via |:Tlibassert|. +function! tlib#assert#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibassert call tlib#assert#Assert(expand(''), , []) +endf + + +" Disable tracing via |:Tlibassert|. +function! tlib#assert#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibassert : +endf + + +function! tlib#assert#Assert(caller, check, vals) abort "{{{3 + for val in a:vals + " TLogVAR val + if type(val) == 3 + call tlib#assert#Assert(a:caller, a:check, val) + elseif !val + throw 'Tlibassert: '. tlib#trace#Backtrace(a:caller) .': '. a:check + endif + endfor +endf + + +function! tlib#assert#Map(vals, expr) abort "{{{3 + return tlib#assert#All(map(a:vals, a:expr)) +endf + + +function! tlib#assert#All(vals) abort "{{{3 + " TLogVAR a:vals, empty(filter(a:vals, '!v:val')) + return empty(filter(a:vals, '!v:val')) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim b/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim new file mode 100644 index 00000000..84395248 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/autocmdgroup.vim @@ -0,0 +1,14 @@ +" autocmdgroup.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 7 + +augroup TLib + autocmd! +augroup END + + +function! tlib#autocmdgroup#Init() "{{{3 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/balloon.vim b/sources_non_forked/tlib/autoload/tlib/balloon.vim new file mode 100644 index 00000000..69675239 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/balloon.vim @@ -0,0 +1,73 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-08-30. +" @Last Change: 2015-11-23. +" @Revision: 48 + + +function! tlib#balloon#Register(expr) "{{{3 + if !has('balloon_eval') + return + endif + if !exists('b:tlib_balloons') + let b:tlib_balloons = [] + endif + if !&ballooneval + setlocal ballooneval + endif + if &balloonexpr != 'tlib#balloon#Expr()' + if !empty(&balloonexpr) + call add(b:tlib_balloons, &balloonexpr) + endif + setlocal ballooneval balloonexpr=tlib#balloon#Expr() + endif + if index(b:tlib_balloons, a:expr) == -1 + call add(b:tlib_balloons, a:expr) + endif +endf + + +function! tlib#balloon#Remove(expr) "{{{3 + if exists('b:tlib_balloons') + call filter(b:tlib_balloons, 'v:val != a:expr') + if empty(b:tlib_balloons) + setlocal ballooneval& + setlocal balloonexpr& + unlet b:tlib_balloons + endif + endif +endf + + +function! tlib#balloon#Expr() "{{{3 + " TLogVAR exists('b:tlib_balloons') + if !exists('b:tlib_balloons') + return '' + endif + let text = map(copy(b:tlib_balloons), 'eval(v:val)') + " TLogVAR b:tlib_balloons, text + call filter(text, '!empty(v:val)') + if has('balloon_multiline') + return join(text, "\n----------------------------------\n") + else + return get(text, 0, '') + endif +endf + + +function! tlib#balloon#Expand(expr) abort "{{{3 + if v:beval_bufnr != bufnr('%') + " TLogVAR v:beval_bufnr, bufnr('%') + return '' + endif + let win = winsaveview() + try + call setpos('.', [v:beval_bufnr, v:beval_lnum, v:beval_col, 0]) + return expand(a:expr) + finally + call winrestview(win) + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/bitwise.vim b/sources_non_forked/tlib/autoload/tlib/bitwise.vim new file mode 100644 index 00000000..54a4258d --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/bitwise.vim @@ -0,0 +1,141 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 124 + + +function! tlib#bitwise#Num2Bits(num) "{{{3 + if type(a:num) <= 1 || type(a:num) == 5 + let bits = reverse(tlib#number#ConvertBase(a:num, 2, 'list')) + elseif type(a:num) == 3 + let bits = copy(a:num) + else + throw "tlib#bitwise#Num2Bits: Must be number of list: ". string(a:num) + endif + return bits +endf + + +function! tlib#bitwise#Bits2Num(bits, ...) "{{{3 + let base = a:0 >= 1 ? a:1 : 10 + " TLogVAR a:bits + let num = 0.0 + for i in range(len(a:bits)) + if get(a:bits, i, 0) + let num += pow(2, i) + endif + endfor + " TLogVAR num + if base == 10 + if type(base) == 5 + return num + else + return float2nr(num) + endif + else + return tlib#number#ConvertBase(num, base) + endif +endf + + +function! tlib#bitwise#AND(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) && get(bits2, v:val)') +endf + + +function! tlib#bitwise#OR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) || get(bits2, v:val)') +endf + + +function! tlib#bitwise#XOR(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + return s:BitwiseComparison(a:num1, a:num2, rtype, + \ 'get(bits1, v:val) ? !get(bits2, v:val) : get(bits2, v:val)') +endf + + +function! s:BitwiseComparison(num1, num2, rtype, expr) "{{{3 + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits = map(range, a:expr) + if a:rtype == 'num' || (a:rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#ShiftRight(bits, n) "{{{3 + let bits = a:bits[a:n : -1] + if empty(bits) + let bits = [0] + endif + return bits +endf + + +function! tlib#bitwise#ShiftLeft(bits, n) "{{{3 + let bits = repeat([0], a:n) + a:bits + return bits +endf + + +function! tlib#bitwise#Add(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + " TLogVAR bits1, bits2, range + let carry = 0 + let bits = [] + for i in range + let sum = get(bits1, i) + get(bits2, i) + carry + if sum == 3 + let bit = 1 + let carry = 1 + elseif sum == 2 + let bit = 0 + let carry = 1 + elseif sum == 1 + let bit = 1 + let carry = 0 + elseif sum == 0 + let bit = 0 + let carry = 0 + endif + call add(bits, bit) + " TLogVAR i, bits, bit + endfor + if carry == 1 + call add(bits, carry) + endif + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + + +function! tlib#bitwise#Sub(num1, num2, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'num' + let bits1 = tlib#bitwise#Num2Bits(a:num1) + let bits2 = tlib#bitwise#Num2Bits(a:num2) + let range = range(max([len(bits1), len(bits2)])) + let bits2 = map(range, '!get(bits2, v:val)') + let bits2 = tlib#bitwise#Add(bits2, [1], 'bits') + let bits3 = tlib#bitwise#Add(bits1, bits2, 'bits') + let bits = bits3[0 : -2] + if rtype == 'num' || (rtype == 'auto' && type(a:num1) <= 1) + return tlib#bitwise#Bits2Num(bits) + else + return bits + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/buffer.vim b/sources_non_forked/tlib/autoload/tlib/buffer.vim new file mode 100644 index 00000000..1cbcdb74 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/buffer.vim @@ -0,0 +1,401 @@ +" buffer.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2017-09-28. +" @Revision: 12.1.352 + + +" Where to display the line when using |tlib#buffer#ViewLine|. +" For possible values for position see |scroll-cursor|. +TLet g:tlib_viewline_position = 'zz' + + +let s:bmru = [] + + +function! tlib#buffer#EnableMRU() abort "{{{3 + call tlib#autocmdgroup#Init() + autocmd TLib BufEnter * call s:BMRU_Push(bufnr('%')) +endf + + +function! tlib#buffer#DisableMRU() abort "{{{3 + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter +endf + + +function! s:BMRU_Push(bnr) abort "{{{3 + let i = index(s:bmru, a:bnr) + if i >= 0 + call remove(s:bmru, i) + endif + call insert(s:bmru, a:bnr) +endf + + +function! s:CompareBuffernameByBasename(a, b) abort "{{{3 + let rx = '"\zs.\{-}\ze" \+\S\+ \+\d\+$' + let an = matchstr(a:a, rx) + let an = fnamemodify(an, ':t') + let bn = matchstr(a:b, rx) + let bn = fnamemodify(bn, ':t') + let rv = an == bn ? 0 : an > bn ? 1 : -1 + return rv +endf + + +function! s:CompareBufferNrByMRU(a, b) abort "{{{3 + let an = matchstr(a:a, '\s*\zs\d\+\ze') + let bn = matchstr(a:b, '\s*\zs\d\+\ze') + let ai = index(s:bmru, 0 + an) + if ai == -1 + return 1 + else + let bi = index(s:bmru, 0 + bn) + if bi == -1 + return -1 + else + return ai == bi ? 0 : ai > bi ? 1 : -1 + endif + endif +endf + + +" Set the buffer to buffer and return a command as string that can be +" evaluated by |:execute| in order to restore the original view. +function! tlib#buffer#Set(buffer) abort "{{{3 + let lazyredraw = &lazyredraw + set lazyredraw + try + let cb = bufnr('%') + let sn = bufnr(a:buffer) + if sn != cb + let ws = bufwinnr(sn) + if ws != -1 + let wb = bufwinnr('%') + exec ws.'wincmd w' + return wb.'wincmd w' + else + silent exec 'sbuffer! '. sn + return 'wincmd c' + endif + else + return '' + endif + finally + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#Eval(buffer, code) abort +" Evaluate CODE in BUFFER. +" +" EXAMPLES: > +" call tlib#buffer#Eval('foo.txt', 'echo b:bar') +function! tlib#buffer#Eval(buffer, code) abort "{{{3 + " let cb = bufnr('%') + " let wb = bufwinnr('%') + " " TLogVAR cb + " let sn = bufnr(a:buffer) + " let sb = sn != cb + let lazyredraw = &lazyredraw + set lazyredraw + let restore = tlib#buffer#Set(a:buffer) + try + exec a:code + " if sb + " let ws = bufwinnr(sn) + " if ws != -1 + " try + " exec ws.'wincmd w' + " exec a:code + " finally + " exec wb.'wincmd w' + " endtry + " else + " try + " silent exec 'sbuffer! '. sn + " exec a:code + " finally + " wincmd c + " endtry + " endif + " else + " exec a:code + " endif + finally + exec restore + let &lazyredraw = lazyredraw + endtry +endf + + +" :def: function! tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') abort +" Possible values for the "order" argument: +" bufnr :: Default behaviour +" mru :: Sort buffers according to most recent use +" basename :: Sort by the file's basename (last component) +" +" NOTE: MRU order works on second invocation only. If you want to always +" use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. +function! tlib#buffer#GetList(...) abort + TVarArg ['show_hidden', 0], ['show_number', 0], ['order', ''] + " TLogVAR show_hidden, show_number, order + let ls_bang = show_hidden ? '!' : '' + redir => bfs + exec 'silent ls'. ls_bang + redir END + let buffer_list = split(bfs, '\n') + if order ==# 'mru' + if empty(s:bmru) + call tlib#buffer#EnableMRU() + echom 'tlib: Installed Buffer MRU logger; disable with: call tlib#buffer#DisableMRU()' + else + call sort(buffer_list, function('s:CompareBufferNrByMRU')) + endif + elseif order ==# 'basename' + call sort(buffer_list, function('s:CompareBuffernameByBasename')) + endif + let buffer_nr = map(copy(buffer_list), 'str2nr(matchstr(v:val, ''\s*\zs\d\+\ze''))') + " TLogVAR buffer_list, buffer_nr + if show_number + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+.\{-}\ze\s\+\S\+ \d\+\s*$'')') + else + call map(buffer_list, 'matchstr(v:val, ''^\s*\d\+\zs.\{-}\ze\s\+\S\+ \d\+\s*$'')') + endif + " TLogVAR buffer_list + " call map(buffer_list, 'matchstr(v:val, ''^.\{-}\ze\s\+line \d\+\s*$'')') + " TLogVAR buffer_list + call map(buffer_list, 'matchstr(v:val, ''^[^"]\+''). printf("%-20s %s", fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":t"), fnamemodify(matchstr(v:val, ''"\zs.\{-}\ze"$''), ":h"))') + " TLogVAR buffer_list + return [buffer_nr, buffer_list] +endf + + +" :def: function! tlib#buffer#ViewLine(line, ?position='z') abort +" line is either a number or a string that begins with a number. +" For possible values for position see |scroll-cursor|. +" See also |g:tlib_viewline_position|. +function! tlib#buffer#ViewLine(line, ...) abort "{{{3 + if a:line + TVarArg 'pos' + let ln = matchstr(a:line, '^\d\+') + let lt = matchstr(a:line, '^\d\+: \zs.*') + " TLogVAR pos, ln, lt + exec ln + if empty(pos) + let pos = tlib#var#Get('tlib_viewline_position', 'wbg') + endif + " TLogVAR pos + if !empty(pos) + exec 'norm! '. pos + endif + call tlib#buffer#HighlightLine(ln) + " let @/ = '\%'. ln .'l.*' + endif +endf + + +function! s:UndoHighlightLine() abort "{{{3 + 2match none + autocmd! TLib CursorMoved,CursorMovedI + autocmd! TLib CursorHold,CursorHoldI + autocmd! TLib InsertEnter,InsertChange,InsertLeave + autocmd! TLib BufLeave,BufWinLeave,WinLeave,BufHidden +endf + + +function! tlib#buffer#HighlightLine(...) abort "{{{3 + TVarArg ['line', line('.')] + " exec '2match MatchParen /^\%'. a:line .'l.*/' + exec '2match Search /^\%'. line .'l.*/' + call tlib#autocmdgroup#Init() + exec 'autocmd TLib CursorMoved,CursorMovedI if line(".") != '. line .' | call s:UndoHighlightLine() | endif' + autocmd TLib CursorHold,CursorHoldI call s:UndoHighlightLine() + autocmd TLib InsertEnter call s:UndoHighlightLine() + " autocmd TLib BufLeave,BufWinLeave,WinLeave,BufHidden call s:UndoHighlightLine() +endf + + +" Delete the lines in the current buffer. Wrapper for |:delete|. +function! tlib#buffer#DeleteRange(line1, line2) abort "{{{3 + let r = @t + try + exec a:line1.','.a:line2.'delete t' + finally + let @t = r + endtry +endf + + +" Replace a range of lines. +function! tlib#buffer#ReplaceRange(line1, line2, lines) abort + call tlib#buffer#DeleteRange(a:line1, a:line2) + call append(a:line1 - 1, a:lines) +endf + + +" Initialize some scratch area at the bottom of the current buffer. +function! tlib#buffer#ScratchStart() abort "{{{3 + norm! Go + let b:tlib_inbuffer_scratch = line('$') + return b:tlib_inbuffer_scratch +endf + + +" Remove the in-buffer scratch area. +function! tlib#buffer#ScratchEnd() abort "{{{3 + if !exists('b:tlib_inbuffer_scratch') + echoerr 'tlib: In-buffer scratch not initalized' + endif + call tlib#buffer#DeleteRange(b:tlib_inbuffer_scratch, line('$')) + unlet b:tlib_inbuffer_scratch +endf + + +" Run exec on all buffers via bufdo and return to the original buffer. +function! tlib#buffer#BufDo(exec) abort "{{{3 + let bn = bufnr('%') + exec 'bufdo '. a:exec + exec 'buffer! '. bn +endf + + +" :def: function! tlib#buffer#InsertText(text, keyargs) abort +" Keyargs: +" 'shift': 0|N +" 'col': col('.')|N +" 'lineno': line('.')|N +" 'indent': 0|1 +" 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) +" Insert text (a string) in the buffer. +function! tlib#buffer#InsertText(text, ...) abort "{{{3 + TVarArg ['keyargs', {}] + " TLogVAR a:text, keyargs + let keyargs = extend({ + \ 'shift': 0, 'col': col('.'), 'lineno': line('.'), 'pos': 'e', 'indent': 0 + \ }, keyargs) + " TLogVAR keyargs + let grow = 0 + let post_del_last_line = line('$') == 1 + let line = getline(keyargs.lineno) + if keyargs.col + keyargs.shift > 0 + let pre = line[0 : (keyargs.col - 1 + keyargs.shift)] + let post = line[(keyargs.col + keyargs.shift): -1] + else + let pre = '' + let post = line + endif + " TLogVAR keyargs.lineno, line, pre, post + let text0 = pre . a:text . post + let text = split(text0, '\n', 1) + " TLogVAR text + let icol = len(pre) + " exec 'norm! '. keyargs.lineno .'G' + call cursor(keyargs.lineno, keyargs.col) + if keyargs.indent && keyargs.col > 1 + if &formatoptions =~# '[or]' + " FIXME: Is the simple version sufficient? + " VERSION 1 + " " This doesn't work because it's not guaranteed that the + " " cursor is set. + " let cline = getline('.') + " norm! a + " "norm! o + " " TAssertExec redraw | sleep 3 + " let idt = tlib#string#Strcharpart(getline('.'), 0, keyargs.col('.') + keyargs.shift) + " " TLogVAR idt + " let idtl = len(idt) + " -1,.delete + " " TAssertExec redraw | sleep 3 + " call append(keyargs.lineno - 1, cline) + " call cursor(keyargs.lineno, keyargs.col) + " " TAssertExec redraw | sleep 3 + " if idtl == 0 && icol != 0 + " let idt = matchstr(pre, '^\s\+') + " let idtl = len(idt) + " endif + " VERSION 2 + let idt = matchstr(pre, '^\s\+') + let idtl = len(idt) + else + let [m_0, idt, iline; rest] = matchlist(pre, '^\(\s*\)\(.*\)$') + let idtl = len(idt) + endif + if idtl < icol + let idt .= repeat(' ', icol - idtl) + endif + " TLogVAR idt + let idtl1 = len(idt) + for i in range(1, len(text) - 1) + let text[i] = idt . text[i] + let grow += idtl1 + endfor + endif + " TLogVAR text + " exec 'norm! '. keyargs.lineno .'Gdd' + call tlib#normal#WithRegister('"tdd', 't') + call append(keyargs.lineno - 1, text) + if post_del_last_line + call tlib#buffer#KeepCursorPosition('$delete') + endif + let tlen = len(text) + let posshift = matchstr(keyargs.pos, '\d\+') + " TLogVAR keyargs.pos + if keyargs.pos =~# '^e' + exec keyargs.lineno + tlen - 1 + exec 'norm! 0'. (len(text[-1]) - len(post) + posshift - 1) .'l' + elseif keyargs.pos =~# '^s' + " TLogVAR keyargs.lineno, pre, posshift + exec keyargs.lineno + exec 'norm! '. len(pre) .'|' + if !empty(posshift) + exec 'norm! '. posshift .'h' + endif + endif + " TLogDBG getline(keyargs.lineno) + " TLogDBG string(getline(1, '$')) + return grow +endf + + +function! tlib#buffer#InsertText0(text, ...) abort "{{{3 + TVarArg ['keyargs', {}] + let mode = get(keyargs, 'mode', 'i') + " TLogVAR mode + if !has_key(keyargs, 'shift') + let col = col('.') + " if mode =~ 'i' + " let col += 1 + " endif + let keyargs.shift = col >= col('$') ? 0 : -1 + " let keyargs.shift = col('.') >= col('$') ? 0 : -1 + " TLogVAR col + " TLogDBG col('.') .'-'. col('$') .': '. string(getline('.')) + endif + " TLogVAR keyargs.shift + return tlib#buffer#InsertText(a:text, keyargs) +endf + + +function! tlib#buffer#CurrentByte() abort "{{{3 + return line2byte(line('.')) + col('.') +endf + + +" Evaluate cmd while maintaining the cursor position and jump registers. +function! tlib#buffer#KeepCursorPosition(cmd) abort "{{{3 + " let pos = getpos('.') + let view = winsaveview() + try + keepjumps exec a:cmd + finally + " call setpos('.', pos) + call winrestview(view) + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/cache.vim b/sources_non_forked/tlib/autoload/tlib/cache.vim new file mode 100644 index 00000000..5363ebd0 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/cache.vim @@ -0,0 +1,464 @@ +" cache.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2019-01-02. +" @Revision: 125.1.243 + + +" The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. +" You might want to delete old files from this directory from time to +" time with a command like: > +" find ~/vimfiles/cache/ -atime +31 -type f -print -delete +TLet g:tlib_cache = '' + +" |tlib#cache#Purge()|: Remove cache files older than N days. +TLet g:tlib#cache#purge_days = 31 + +" Purge the cache every N days. Disable automatic purging by setting +" this value to a negative value. +TLet g:tlib#cache#purge_every_days = 31 + +" The encoding used for the purge-cache script. +" Default: 'enc' +TLet g:tlib#cache#script_encoding = &enc + +" Whether to run the directory removal script: +" 0 ... No +" 1 ... Query user +" 2 ... Yes +TLet g:tlib#cache#run_script = 1 + +" Verbosity level: +" 0 ... Be quiet +" 1 ... Display informative message +" 2 ... Display detailed messages +TLet g:tlib#cache#verbosity = 1 + +" A list of regexps that are matched against partial filenames of the +" cached files. If a regexp matches, the file won't be removed by +" |tlib#cache#Purge()|. +TLet g:tlib#cache#dont_purge = ['[\/]\.last_purge$'] + +" If the cache filename is longer than N characters, use +" |pathshorten()|. +TLet g:tlib#cache#max_filename = 200 + +TLet g:tlib#cache#use_json = 0 + +TLet g:tlib#cache#use_encoding = '' + + +let s:cache = {} + + +" :display: tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) +" The default cache directory. +function! tlib#cache#Dir(...) "{{{3 + TVarArg ['mode', 'bg'], ['ensure_dir', 1] + let dir = tlib#var#Get('tlib_cache', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'cache']) + endif + if ensure_dir + call tlib#dir#Ensure(dir) + endif + return dir +endf + + +" :display: tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#cache#Filename()|. +function! tlib#cache#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#cache#Filename'), [a:type, file] + a:000) +endf + + +" :def: function! tlib#cache#Filename(type, ?file=%, ?mkdir=0, ?dir='') +function! tlib#cache#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let dir0 = a:0 >= 3 && !empty(a:3) ? a:3 : tlib#cache#Dir() + let dir = dir0 + if a:0 >= 1 && !empty(a:1) + let file = a:1 + else + if empty(expand('%:t')) + return '' + endif + let file = expand('%:p') + let file = tlib#file#Relative(file, tlib#file#Join([dir, '..'])) + endif + " TLogVAR file, dir + let mkdir = a:0 >= 2 ? a:2 : 0 + let file = substitute(file, '\.\.\|[:&<>]\|//\+\|\\\\\+', '_', 'g') + let dirs = [dir, a:type] + let dirf = fnamemodify(file, ':h') + if dirf != '.' + call add(dirs, dirf) + endif + let dir = tlib#file#Join(dirs) + " TLogVAR dir + let dir = tlib#dir#PlainName(dir) + " TLogVAR dir + let file = fnamemodify(file, ':t') + " TLogVAR file, dir, mkdir + let cache_file = tlib#file#Join([dir, file]) + if len(cache_file) > g:tlib#cache#max_filename + " echom "DBG long filename" cache_file + " echom "DBG long filename" dir + if v:version >= 704 + let shortfilename = sha256(file) + else + let shortfilename = tlib#hash#Adler32(file) + endif + " let cache_file = tlib#cache#Filename(a:type, shortfilename, mkdir, dir0) + let cache_file = tlib#file#Join([dir, shortfilename]) + else + if mkdir && !isdirectory(dir) + try + call mkdir(dir, 'p') + catch /^Vim\%((\a\+)\)\=:E739:/ + if filereadable(dir) && !isdirectory(dir) + echoerr 'TLib: Cannot create directory for cache file because a file with the same name exists (please delete it):' dir + " call delete(dir) + " call mkdir(dir, 'p') + endif + endtry + endif + endif + " TLogVAR cache_file + return cache_file +endf + + +let s:timestamps = {} + + +function! s:SetTimestamp(cfile, type) "{{{3 + if !has_key(s:timestamps, a:cfile) + let s:timestamps[a:cfile] = {} + endif + let s:timestamps[a:cfile].atime = getftime(a:cfile) + let s:timestamps[a:cfile][a:type] = s:timestamps[a:cfile].atime +endf + + +function! s:PutValue(cfile, value) abort "{{{3 + let s:cache[a:cfile] = {'mtime': localtime(), 'data': a:value} +endf + + +function! s:GetValue(cfile, default) abort "{{{3 + return get(get(s:cache, a:cfile, {}), 'data', a:default) +endf + + +function! s:GetCacheTime(cfile) abort "{{{3 + let not_found = !has_key(s:cache, a:cfile) + let cftime = not_found ? -1 : s:cache[a:cfile].mtime + return cftime +endf + + +function! tlib#cache#Save(cfile, value, ...) "{{{3 + TVarArg ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile, localtime() + call s:PutValue(a:cfile, a:value) + elseif !empty(a:cfile) + " TLogVAR a:value + let cfile = a:cfile + if g:tlib#cache#use_json && exists('*json_encode') + try + let value = json_encode(a:value) + let cfile .= '.json' + catch + echoerr v:exception + let value = string(a:value) + endtry + else + let value = string(a:value) + endif + Tlibtrace 'tlib', cfile, value + call writefile([value], cfile, 'b') + call s:SetTimestamp(a:cfile, 'write') + endif +endf + + +function! tlib#cache#MTime(cfile) "{{{3 + let mtime = {'mtime': getftime(a:cfile)} + let mtime = extend(mtime, get(s:timestamps, a:cfile, {})) + return mtime +endf + + +function! tlib#cache#Get(cfile, ...) "{{{3 + TVarArg ['default', {}], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + " TLogVAR in_memory, a:cfile + return s:GetValue(a:cfile, default) + else + call tlib#cache#MaybePurge() + if !empty(a:cfile) + let jsonfile = a:cfile .'.json' + let use_json = g:tlib#cache#use_json && exists('*json_decode') && exists('v:none') && filereadable(jsonfile) + if use_json + let use_json = 1 + let cfile = jsonfile + else + let cfile = a:cfile + endif + let mt = s:GetCacheTime(cfile) + let ft = getftime(cfile) + if mt != -1 && mt >= ft + return s:GetValue(cfile, default) + elseif ft != -1 + call s:SetTimestamp(cfile, 'read') + let val = join(readfile(cfile, 'b'), '\n') + try + if use_json + " NOTE: Copy result of json_decode() in order to + " avoid "E741: value is locked" error in vim8. + let value = json_decode(val) + if value is v:none + let value = default + else + let value = copy(value) + endif + else + let value = eval(val) + endif + call s:PutValue(cfile, value) + return value + catch + echohl ErrorMsg + echom v:exception + echom 'tlib#cache#Get: Invalid value in:' cfile + echom 'Value:' string(val) + echom 'Please review the file and delete it if necessary' + echom 'Will use default value:' string(default) + echohl NONE + if g:tlib#debug + let @* = string(val) + endif + " call s:PutValue(cfile, default) + return default + endtry + endif + endif + return default + endif +endf + + +" :display: tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) +" Get a cached value from cfile. If it is outdated (compared to ftime) +" or does not exist, create it calling a generator function. +function! tlib#cache#Value(cfile, generator, ftime, ...) "{{{3 + TVarArg ['args', []], ['options', {}] + let in_memory = get(options, 'in_memory', 0) + if in_memory + let cftime = s:GetCacheTime(a:cfile) + else + let cftime = getftime(a:cfile) + endif + let ftime = a:ftime + " TLogVAR in_memory, cftime + if cftime == -1 || ftime == -1 || (ftime != 0 && cftime < ftime) + " TLogVAR a:generator, args + let val = call(a:generator, args) + " TLogVAR val + let cval = {'val': val} + " TLogVAR cval + call tlib#cache#Save(a:cfile, cval, options) + return val + else + let val = tlib#cache#Get(a:cfile, {}, options) + if !has_key(val, 'val') + throw 'tlib#cache#Value: Internal error: '. a:cfile + else + return val.val + endif + endif +endf + + +function! tlib#cache#ValueFromName(type, name, ...) abort "{{{3 + let cfile = tlib#cache#Filename(a:type, tlib#url#Encode(a:name), 1) + return call(function('tlib#cache#Value'), [cfile] + a:000) +endf + + +" Call |tlib#cache#Purge()| if the last purge was done before +" |g:tlib#cache#purge_every_days|. +function! tlib#cache#MaybePurge() "{{{3 + if g:tlib#cache#purge_every_days < 0 + return + endif + let dir = tlib#cache#Dir('g') + let last_purge = tlib#file#Join([dir, '.last_purge']) + let last_purge_exists = filereadable(last_purge) + if last_purge_exists + let threshold = localtime() - g:tlib#cache#purge_every_days * g:tlib#date#dayshift + let should_purge = getftime(last_purge) < threshold + else + let should_purge = 0 " should ignore empty dirs, like the tmru one: !empty(glob(tlib#file#Join([dir, '**']))) + endif + if should_purge + if last_purge_exists + let yn = 'y' + else + let txt = "TLib: The cache directory '". dir ."' should be purged of old files.\nDelete files older than ". g:tlib#cache#purge_days ." days now?" + let yn = tlib#input#Dialog(txt, ['yes', 'no'], 'no') + endif + if yn =~ '^y\%[es]$' + call tlib#cache#Purge() + else + let g:tlib#cache#purge_every_days = -1 + if !last_purge_exists + call s:PurgeTimestamp(dir) + endif + echohl WarningMsg + echom "TLib: Please run :call tlib#cache#Purge() to clean up ". dir + echohl NONE + endif + elseif !last_purge_exists + call s:PurgeTimestamp(dir) + endif +endf + + +" Delete old files. +function! tlib#cache#Purge() "{{{3 + let threshold = localtime() - g:tlib#cache#purge_days * g:tlib#date#dayshift + let dir = tlib#cache#Dir('g') + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + echom "TLib: Delete files older than ". g:tlib#cache#purge_days ." days from ". dir + echohl NONE + endif + let files = tlib#cache#ListFilesInCache() + let deldir = [] + let newer = [] + let msg = [] + let more = &more + set nomore + try + for file in files + if isdirectory(file) + if empty(filter(copy(newer), 'tlib#string#Strcharpart(v:val, 0, len(file)) ==# file')) + call add(deldir, file) + endif + else + if getftime(file) < threshold + call s:Delete(msg, file, '') + else + call add(newer, file) + endif + endif + endfor + finally + let &more = more + endtry + if !empty(msg) && g:tlib#cache#verbosity >= 1 + echo join(msg, "\n") + endif + if !empty(deldir) + let deldir = filter(reverse(sort(deldir)), 's:Delete(msg, v:val, "d")') + if !empty(deldir) + if &shell =~ 'sh\(\.exe\)\?$' + let scriptfile = 'deldir.sh' + let rmdir = 'rm -rf %s' + else + let scriptfile = 'deldir.bat' + let rmdir = 'rmdir /S /Q %s' + endif + let enc = g:tlib#cache#script_encoding + if has('multi_byte') && enc != &enc + call map(deldir, 'iconv(v:val, &enc, enc)') + endif + let scriptfile = tlib#file#Join([dir, scriptfile]) + if filereadable(scriptfile) + let script = readfile(scriptfile) + else + let script = [] + endif + let script += map(copy(deldir), 'printf(rmdir, shellescape(v:val, 1))') + let script = tlib#list#Uniq(script) + call writefile(script, scriptfile) + call inputsave() + if g:tlib#cache#run_script == 0 + if g:tlib#cache#verbosity >= 1 + echohl WarningMsg + if g:tlib#cache#verbosity >= 2 + echom "TLib: Purged cache. Need to run script to delete directories" + endif + echom "TLib: Please review and execute: ". scriptfile + echohl NONE + endif + else + try + let yn = g:tlib#cache#run_script == 2 ? 'y' : tlib#input#Dialog("TLib: About to delete directories by means of a shell script.\nDirectory removal script: ". scriptfile ."\nRun script to delete directories now?", ['yes', 'no', 'edit'], 'no') + if yn =~ '^y\%[es]$' + exec 'silent cd '. fnameescape(dir) + exec '! ' &shell shellescape(scriptfile, 1) + exec 'silent cd -' + call delete(scriptfile) + elseif yn =~ '^e\%[dit]$' + exec 'edit '. fnameescape(scriptfile) + endif + finally + call inputrestore() + endtry + endif + endif + endif + call s:PurgeTimestamp(dir) +endf + + +function! s:Delete(msg, file, flags) abort "{{{3 + let rv = delete(a:file, a:flags) + if !rv && g:tlib#cache#verbosity >= 2 + call add(a:msg, "TLib#cache: Delete ". file) + endif + return rv +endf + + +function! s:PurgeTimestamp(dir) "{{{3 + let last_purge = tlib#file#Join([a:dir, '.last_purge']) + " TLogVAR last_purge + call writefile([" "], last_purge) +endf + +function! tlib#cache#ListFilesInCache(...) "{{{3 + let dir = a:0 >= 1 ? a:1 : tlib#cache#Dir('g') + if v:version > 702 || (v:version == 702 && has('patch51')) + let filess = glob(tlib#file#Join([dir, '**']), 1) + else + let filess = glob(tlib#file#Join([dir, '**'])) + endif + let files = reverse(split(filess, '\n')) + let pos0 = len(tlib#dir#CanonicName(dir)) + call filter(files, 's:ShouldPurge(tlib#string#Strcharpart(v:val, pos0))') + return files +endf + + +function! s:ShouldPurge(partial_filename) "{{{3 + " TLogVAR a:partial_filename + for rx in g:tlib#cache#dont_purge + if a:partial_filename =~ rx + " TLogVAR a:partial_filename, rx + return 0 + endif + endfor + return 1 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/char.vim b/sources_non_forked/tlib/autoload/tlib/char.vim new file mode 100644 index 00000000..d3d2cb6f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/char.vim @@ -0,0 +1,59 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 38 + + +" :def: function! tlib#char#Get(?timeout=0) +" Get a character. +" +" EXAMPLES: > +" echo tlib#char#Get() +" echo tlib#char#Get(5) +function! tlib#char#Get(...) "{{{3 + TVarArg ['timeout', 0], ['resolution', 0], ['getmod', 0] + let char = -1 + let mode = 0 + if timeout == 0 || !has('reltime') + let char = getchar() + else + let char = tlib#char#GetWithTimeout(timeout, resolution) + endif + if getmod + if char != -1 + let mode = getcharmod() + endif + return [char, mode] + else + return char + endif +endf + + +function! tlib#char#IsAvailable() "{{{3 + let ch = getchar(1) + return type(ch) == 0 && ch != 0 +endf + + +function! tlib#char#GetWithTimeout(timeout, ...) "{{{3 + TVarArg ['resolution', 2] + " TLogVAR a:timeout, resolution + let start = tlib#time#MSecs() + while 1 + let c = getchar(0) + if type(c) != 0 || c != 0 + return c + else + let now = tlib#time#MSecs() + let diff = tlib#time#DiffMSecs(now, start, resolution) + " TLogVAR diff + if diff > a:timeout + return -1 + endif + endif + endwh + return -1 +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/cmd.vim b/sources_non_forked/tlib/autoload/tlib/cmd.vim new file mode 100644 index 00000000..f65a2372 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/cmd.vim @@ -0,0 +1,117 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 58 + + +let g:tlib#cmd#last_output = [] + + +function! tlib#cmd#OutputAsList(command) "{{{3 + " TLogVAR a:command + if exists('s:redir_lines') + redir END + let cache = s:redir_lines + endif + let s:redir_lines = '' + redir =>> s:redir_lines + silent! exec a:command + redir END + let g:tlib#cmd#last_output = split(s:redir_lines, '\n') + unlet s:redir_lines + if exists('cache') + let s:redir_lines = cache + redir =>> s:redir_lines + endif + return g:tlib#cmd#last_output +endf + + +" See |:TBrowseOutput|. +function! tlib#cmd#BrowseOutput(command) "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#DefaultBrowseOutput", a:command) +endf + +" :def: function! tlib#cmd#BrowseOutputWithCallback(callback, command) +" Execute COMMAND and present its output in a |tlib#input#List()|; +" when a line is selected, execute the function named as the CALLBACK +" and pass in that line as an argument. +" +" The CALLBACK function gives you an opportunity to massage the COMMAND output +" and possibly act on it in a meaningful way. For example, if COMMAND listed +" all URIs found in the current buffer, CALLBACK could validate and then open +" the selected URI in the system's default browser. +" +" This function is meant to be a tool to help compose the implementations of +" powerful commands that use |tlib#input#List()| as a common interface. See +" |TBrowseScriptnames| as an example. +" +" EXAMPLES: > +" call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +function! tlib#cmd#BrowseOutputWithCallback(callback, command) "{{{3 + let list = tlib#cmd#OutputAsList(a:command) + let cmds = tlib#input#List('m', 'Output of: '. a:command, list) + if !empty(cmds) + for cmd in cmds + let Callback = function(a:callback) + call call(Callback, [cmd]) + endfor + endif +endf + +function! tlib#cmd#DefaultBrowseOutput(cmd) "{{{3 + call feedkeys(':'. a:cmd) +endf + +function! tlib#cmd#ParseScriptname(line) "{{{3 + " let parsedValue = substitute(a:line, '^.\{-}\/', '/', '') + let parsedValue = matchstr(a:line, '^\s*\d\+:\s*\zs.*$') + exe 'drop '. fnameescape(parsedValue) +endf + + +function! tlib#cmd#TBrowseScriptnames() abort "{{{3 + call tlib#cmd#BrowseOutputWithCallback("tlib#cmd#ParseScriptname", "scriptnames") +endf + + +" :def: function! tlib#cmd#UseVertical(?rx='') +" Look at the history whether the command was called with vertical. If +" an rx is provided check first if the last entry in the history matches +" this rx. +function! tlib#cmd#UseVertical(...) "{{{3 + TVarArg ['rx'] + let h0 = histget(':') + let rx0 = '\C\\s\+' + if !empty(rx) + let rx0 .= '.\{-}'.rx + endif + " TLogVAR h0, rx0 + return h0 =~ rx0 +endf + + +" Print the time in seconds or milliseconds (if your version of VIM +" has |+reltime|) a command takes. +function! tlib#cmd#Time(cmd) "{{{3 + if has('reltime') + let start = tlib#time#Now() + exec a:cmd + let end = tlib#time#Now() + let diff = string(tlib#time#Diff(end, start)) .'ms' + else + let start = localtime() + exec a:cmd + let diff = (localtime() - start) .'s' + endif + echom 'Time: '. diff .': '. a:cmd +endf + + +function! tlib#cmd#Capture(cmd) "{{{3 + redir => s + silent exec a:cmd + redir END + return s +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/comments.vim b/sources_non_forked/tlib/autoload/tlib/comments.vim new file mode 100644 index 00000000..879cde17 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/comments.vim @@ -0,0 +1,26 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 25 + + +" function! tlib#comments#Comments(?rx='') +function! tlib#comments#Comments(...) + TVarArg ['rx', ''] + let comments = {} + let co = &comments + while !empty(co) + " TLogVAR co + let [m_0, m_key, m_val, m_val1, co0, co; rest] = matchlist(co, '^\([^:]*\):\(\(\\.\|[^,]*\)\+\)\(,\(.*\)$\|$\)') + " TLogVAR m_key, m_val, co + if empty(m_key) + let m_key = ':' + endif + if empty(rx) || m_key =~ rx + let comments[m_key] = m_val + endif + endwh + return comments +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/date.vim b/sources_non_forked/tlib/autoload/tlib/date.vim new file mode 100644 index 00000000..1b7559c8 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/date.vim @@ -0,0 +1,195 @@ +" date.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-03-25. +" @Last Change: 2017-09-06. +" @Revision: 44.0.34 + + +if !exists('g:tlib#date#ShortDatePrefix') | let g:tlib#date#ShortDatePrefix = '20' | endif "{{{2 +if !exists('g:tlib#date#TimeZoneShift') | let g:tlib#date#TimeZoneShift = 0 | endif "{{{2 + +let g:tlib#date#dayshift = 60 * 60 * 24 +" let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\%(\s\+\(\(\d\d\):\(\d\d\)\)\)\?\>' +let g:tlib#date#date_rx = '\<\(\d\{4}\)-\(\d\d\)-\(\d\d\)\>' +let g:tlib#date#date_format = '%Y-%m-%d' + + +function! tlib#date#IsDate(text) abort "{{{3 + return a:text =~# '^'. g:tlib#date#date_rx .'$' && + \ !empty(tlib#date#Parse(a:text, 0, 1)) +endf + + +function! tlib#date#Format(...) abort "{{{3 + let secs1970 = a:0 >= 1 ? a:1 : localtime() + return strftime(g:tlib#date#date_format, secs1970) +endf + + +" :display: tlib#date#DiffInDays(date1, ?date2=localtime(), ?allow_zero=0) +function! tlib#date#DiffInDays(date, ...) + let allow_zero = a:0 >= 2 ? a:2 : 0 + let s0 = tlib#date#SecondsSince1970(a:date, 0, allow_zero) + let s1 = a:0 >= 1 ? tlib#date#SecondsSince1970(a:1, 0, allow_zero) : localtime() + let dd = (s0 - s1) / g:tlib#date#dayshift + " TLogVAR dd + return dd +endf + + +" :display: tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 +function! tlib#date#Parse(date, ...) "{{{3 + let min = a:0 >= 1 && a:1 ? 0 : 1 + let silent = a:0 >= 2 ? a:2 : 0 + Tlibtype 'tlib', a:date, min, silent + let m = matchlist(a:date, '^\(\d\{2}\|\d\{4}\)-\(\d\{1,2}\)-\(\d\{1,2}\)$') + Tlibtype 'tlib', m + let year = '' + let month = '' + let days = '' + if !empty(m) + let year = m[1] + let month = m[2] + let days = m[3] + else + let m = matchlist(a:date, '^\(\d\+\)/\(\d\{1,2}\)/\(\d\{1,2}\)$') + if !empty(m) + let year = m[1] + let month = m[3] + let days = m[2] + else + let m = matchlist(a:date, '^\(\d\{1,2}\)\.\s*\(\d\{1,2}\)\.\s*\(\d\d\{2}\|\d\{4}\)$') + if !empty(m) + let year = m[3] + let month = m[2] + let days = m[1] + endif + endif + endif + Tlibtype 'tlib', year, month, days + if empty(m) || year == '' || month == '' || days == '' || + \ month < min || month > 12 || days < min || days > 31 + if !silent + echoerr 'TLib: Invalid date: '. a:date + endif + return [] + endif + if strlen(year) == 2 + let year = g:tlib#date#ShortDatePrefix . year + Tlibtype 'tlib', year + endif + return [0 + year, 0 + month, 0 + days] +endf + + +" tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) +function! tlib#date#SecondsSince1970(date, ...) "{{{3 + let allow_zero = a:0 >= 2 ? a:2 : 0 + " TLogVAR a:date, allow_zero + let date = tlib#date#Parse(a:date, allow_zero) + if empty(date) + return 0 + endif + let [year, month, days] = date + if a:0 >= 1 && a:1 > 0 + let days = days + a:1 + end + let days_passed = days + let i = 1970 + while i < year + let days_passed = days_passed + 365 + if i % 4 == 0 || i == 2000 + let days_passed = days_passed + 1 + endif + let i = i + 1 + endwh + let i = 1 + while i < month + if i == 1 + let days_passed = days_passed + 31 + elseif i == 2 + let days_passed = days_passed + 28 + if year % 4 == 0 || year == 2000 + let days_passed = days_passed + 1 + endif + elseif i == 3 + let days_passed = days_passed + 31 + elseif i == 4 + let days_passed = days_passed + 30 + elseif i == 5 + let days_passed = days_passed + 31 + elseif i == 6 + let days_passed = days_passed + 30 + elseif i == 7 + let days_passed = days_passed + 31 + elseif i == 8 + let days_passed = days_passed + 31 + elseif i == 9 + let days_passed = days_passed + 30 + elseif i == 10 + let days_passed = days_passed + 31 + elseif i == 11 + let days_passed = days_passed + 30 + endif + let i = i + 1 + endwh + let seconds = (days_passed - 1) * 24 * 60 * 60 + let seconds = seconds + (strftime('%H') + g:tlib#date#TimeZoneShift) * 60 * 60 + let seconds = seconds + strftime('%M') * 60 + let seconds = seconds + strftime('%S') + return seconds +endf + + +function! tlib#date#Shift(date, shift) abort "{{{3 + let n = str2nr(matchstr(a:shift, '\d\+')) + let ml = matchlist(a:date, g:tlib#date#date_rx) + " TLogVAR a:date, a:shift, n, ml + if a:shift =~ 'd$' + let date = tlib#date#AddDays(a:date, n) + elseif a:shift =~ 'b$' + let n1 = n + let secs = tlib#date#SecondsSince1970(a:date) + while n1 > 0 + let n1 -= 1 + let secs += g:tlib#date#dayshift + let uday = strftime('%u', secs) + if uday == 6 + let secs += g:tlib#date#dayshift * 2 + elseif uday == 7 + let secs += g:tlib#date#dayshift + endif + endwh + let date = tlib#date#Format(secs) + elseif a:shift =~ 'w$' + let date = tlib#date#AddDays(a:date, n * 7) + elseif a:shift =~ 'm$' + let d = str2nr(ml[3]) + let ms = str2nr(ml[2]) + n + let m = (ms - 1) % 12 + 1 + let yr = str2nr(ml[1]) + (ms - 1) / 12 + let date = printf('%04d-%02d-%02d', yr, m, d) + " TLogVAR d, ms, m, yr, date + elseif a:shift =~ 'y$' + let yr = str2nr(ml[1]) + n + let date = substitute(a:date, '^\d\{4}', yr, '') + else + throw 'tlib#date#Shift: Unsupported arguments: '. string(a:shift) + endif + " if !empty(ml[4]) && date !~ '\s'. ml[4] .'$' + " let date .= ' '. ml[4] + " endif + " TLogVAR date + return date +endf + + +function! tlib#date#AddDays(date, n) abort "{{{3 + let secs = tlib#date#SecondsSince1970(a:date) + g:tlib#date#dayshift * a:n + " TLogVAR secs + let date = tlib#date#Format(secs) + return date +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/dictionary.vim b/sources_non_forked/tlib/autoload/tlib/dictionary.vim new file mode 100644 index 00000000..a7785196 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/dictionary.vim @@ -0,0 +1,45 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2016-04-06 +" @Revision: 22 + + +" :display: tlib#dictionary#Rev(dict, ?opts = {}) abort "{{{3 +function! tlib#dictionary#Rev(dict, ...) abort "{{{3 + let opts = a:0 >= 1 ? a:1 : {} + Tlibtype a:dict, 'dict', opts, 'dict' + let rev = {} + let use_string = get(opts, 'use_string', 0) + let use_eval = get(opts, 'use_eval', 0) + let values_as_list = get(opts, 'values_as_list', 0) + for [m, f] in items(a:dict) + if use_string + let k = string(f) + else + let k = type(f) == 1 ? f : string(f) + if k ==# '' + let k = get(opts, 'empty', '') + if empty(k) + continue + endif + endif + endif + if use_eval + let v = eval(m) + else + let v = m + endif + if values_as_list + if has_key(rev, k) + call add(rev[k], v) + else + let rev[k] = [v] + endif + else + let rev[k] = v + endif + endfor + return rev +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/dir.vim b/sources_non_forked/tlib/autoload/tlib/dir.vim new file mode 100644 index 00000000..02081079 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/dir.vim @@ -0,0 +1,93 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 43 + +" TLet g:tlib#dir#sep = '/' +TLet g:tlib#dir#sep = exists('+shellslash') && !&shellslash ? '\' : '/' + + +let s:dir_stack = [] + +" EXAMPLES: > +" tlib#dir#CanonicName('foo/bar') +" => 'foo/bar/' +function! tlib#dir#CanonicName(dirname) "{{{3 + let dirname = tlib#file#Canonic(a:dirname) + if dirname !~ '[/\\]$' + return dirname . g:tlib#dir#sep + endif + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#NativeName('foo/bar/') +" On Windows: +" => 'foo\bar\' +" On Linux: +" => 'foo/bar/' +function! tlib#dir#NativeName(dirname) "{{{3 + let sep = tlib#rx#EscapeReplace(g:tlib#dir#sep) + let dirname = substitute(a:dirname, '[\/]', sep, 'g') + return dirname +endf + + +" EXAMPLES: > +" tlib#dir#PlainName('foo/bar/') +" => 'foo/bar' +function! tlib#dir#PlainName(dirname) "{{{3 + let dirname = a:dirname + while index(['/', '\'], dirname[-1 : -1]) != -1 + let dirname = dirname[0 : -2] + endwh + return dirname + " return substitute(a:dirname, tlib#rx#Escape(g:tlib#dir#sep).'\+$', '', '') +endf + + +" Create a directory if it doesn't already exist. +function! tlib#dir#Ensure(dir) "{{{3 + if !isdirectory(a:dir) + let dir = tlib#dir#PlainName(a:dir) + return mkdir(dir, 'p') + endif + return 1 +endf + + +" Return the first directory in &rtp. +function! tlib#dir#MyRuntime() "{{{3 + return get(split(&rtp, ','), 0) +endf + + +" :def: function! tlib#dir#CD(dir, ?locally=0) => CWD +function! tlib#dir#CD(dir, ...) "{{{3 + TVarArg ['locally', haslocaldir()] + let cmd = locally ? 'lcd! ' : 'cd! ' + " let cwd = getcwd() + let cmd .= tlib#arg#Ex(a:dir) + " TLogVAR a:dir, locally, cmd + exec 'silent' cmd + " return cwd + return getcwd() +endf + + +" :def: function! tlib#dir#Push(dir, ?locally=0) => CWD +function! tlib#dir#Push(dir, ...) "{{{3 + TVarArg ['locally', haslocaldir()] + call add(s:dir_stack, [getcwd(), locally]) + return tlib#dir#CD(a:dir, locally) +endf + + +" :def: function! tlib#dir#Pop() => CWD +function! tlib#dir#Pop() "{{{3 + let [dir, locally] = remove(s:dir_stack, -1) + return tlib#dir#CD(dir, locally) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/eval.vim b/sources_non_forked/tlib/autoload/tlib/eval.vim new file mode 100644 index 00000000..117209ed --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/eval.vim @@ -0,0 +1,72 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 56 + + +function! tlib#eval#FormatValue(value, ...) "{{{3 + TVarArg ['indent', 0] + " TLogVAR a:value, indent + let indent1 = indent + 1 + let indenti = repeat(' ', &sw) + let type = type(a:value) + let acc = [] + if type == 0 || type == 1 || type == 2 + " TLogDBG 'Use string() for type='. type + call add(acc, string(a:value)) + elseif type == 3 "List + " TLogDBG 'List' + call add(acc, '[') + for e in a:value + call add(acc, printf('%s%s,', indenti, tlib#eval#FormatValue(e, indent1))) + unlet e + endfor + call add(acc, ']') + elseif type == 4 "Dictionary + " TLogDBG 'Dictionary' + call add(acc, '{') + let indent1 = indent + 1 + for [k, v] in items(a:value) + call add(acc, printf("%s%s: %s,", indenti, string(k), tlib#eval#FormatValue(v, indent1))) + unlet k v + endfor + call add(acc, '}') + else + " TLogDBG 'Unknown type: '. string(a:value) + call add(acc, string(a:value)) + endif + if indent > 0 + let is = repeat(' ', indent * &sw) + for i in range(1,len(acc) - 1) + let acc[i] = is . acc[i] + endfor + endif + return join(acc, "\n") +endf + + +function! tlib#eval#Extend(a, b, ...) abort "{{{3 + let mode = a:0 >= 1 ? a:1 : 'force' + if type(a:a) != type(a:b) + throw 'tlib#eval#Extend: Incompatible types: a='. string(a:a) .' b='. string(a:b) + elseif type(a:a) == 3 " list + return extend(a:a, a:b, mode) + elseif type(a:a) == 4 " dict + for k in keys(a:b) + if has_key(a:a, k) + if mode == 'force' + let a:a[k] = tlib#eval#Extend(copy(a:a[k]), a:b[k], mode) + elseif mode == 'error' + throw 'tlib#eval#Extend: Key already exists: '. k + endif + else + let a:a[k] = a:b[k] + endif + unlet! k + endfor + return a:a + else + return a:b + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/file.vim b/sources_non_forked/tlib/autoload/tlib/file.vim new file mode 100644 index 00000000..a52c1be3 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/file.vim @@ -0,0 +1,356 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 225 + + +if !exists('g:tlib#file#drop') + " If true, use |:drop| to edit loaded buffers (only available with GUI). + let g:tlib#file#drop = has('gui') "{{{2 +endif + + +if !exists('g:tlib#file#use_tabs') + let g:tlib#file#use_tabs = 0 "{{{2 +endif + + +if !exists('g:tlib#file#edit_cmds') + let g:tlib#file#edit_cmds = g:tlib#file#use_tabs ? {'buffer': 'tab split | buffer', 'edit': 'tabedit'} : {} "{{{2 +endif + + +if !exists('g:tlib#file#absolute_filename_rx') + let g:tlib#file#absolute_filename_rx = '^\~\?[\/]' "{{{2 +endif + + +if !exists('g:tlib#file#reject_rx') + let g:tlib#file#reject_rx = '\%(^\|[\/]\)\%(tags\|Thumbs\.db\)$' "{{{2 +endif + + +""" File related {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + + +" EXAMPLES: > +" tlib#file#Split('foo/bar/filename.txt') +" => ['foo', 'bar', 'filename.txt'] +function! tlib#file#Split(filename) abort "{{{3 + let prefix = matchstr(a:filename, '^\(\w\+:\)\?/\+') + Tlibtrace 'tlib', prefix + if !empty(prefix) + let filename = a:filename[len(prefix) : -1] + else + let filename = a:filename + endif + let rv = split(filename, '[\/]') + " let rv = split(filename, '[\/]', 1) + if !empty(prefix) + call insert(rv, prefix[0:-2]) + endif + return rv +endf + + +" :display: tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) +" EXAMPLES: > +" tlib#file#Join(['foo', 'bar', 'filename.txt']) +" => 'foo/bar/filename.txt' +function! tlib#file#Join(filename_parts, ...) abort "{{{3 + TVarArg ['strip_slashes', 1], 'maybe_absolute' + Tlibtrace 'tlib', a:filename_parts, strip_slashes + if maybe_absolute + let filename_parts = [] + for part in a:filename_parts + if part =~ g:tlib#file#absolute_filename_rx + let filename_parts = [] + endif + call add(filename_parts, part) + endfor + else + let filename_parts = a:filename_parts + endif + if strip_slashes + " let rx = tlib#rx#Escape(g:tlib#dir#sep) .'$' + let rx = '[/\\]\+$' + let parts = map(copy(filename_parts), 'substitute(v:val, rx, "", "")') + Tlibtrace 'tlib', parts + return join(parts, g:tlib#dir#sep) + else + return join(filename_parts, g:tlib#dir#sep) + endif +endf + + +" EXAMPLES: > +" tlib#file#Relative('foo/bar/filename.txt', 'foo') +" => 'bar/filename.txt' +function! tlib#file#Relative(filename, basedir) abort "{{{3 + Tlibtrace 'tlib', a:filename, a:basedir + " TLogDBG getcwd() + " TLogDBG expand('%:p') + let b0 = tlib#file#Absolute(a:basedir) + let b = tlib#file#Split(b0) + Tlibtrace 'tlib', b + let f0 = tlib#file#Absolute(a:filename) + let fn = fnamemodify(f0, ':t') + let fd = fnamemodify(f0, ':h') + let f = tlib#file#Split(fd) + Tlibtrace 'tlib', f0, fn, fd, f + if f[0] != b[0] + let rv = f0 + else + while !empty(f) && !empty(b) + if f[0] != b[0] + break + endif + call remove(f, 0) + call remove(b, 0) + endwh + Tlibtrace 'tlib', f, b + let rv = tlib#file#Join(repeat(['..'], len(b)) + f + [fn]) + endif + Tlibtrace 'tlib', rv + return rv +endf + + +function! tlib#file#IsAbsolute(filename) abort "{{{3 + return a:filename =~? '^\%(/\|\w\+:/\)' +endf + + +function! tlib#file#Absolute(filename, ...) abort "{{{3 + if filereadable(a:filename) + let filename = fnamemodify(a:filename, ':p') + elseif a:filename =~# '^\(/\|[^\/]\+:\)' + let filename = a:filename + else + let cwd = a:0 >= 1 ? a:1 : getcwd() + let filename = tlib#file#Join([cwd, a:filename]) + endif + let filename = substitute(filename, '\(^\|[\/]\)\zs\.[\/]', '', 'g') + let filename = substitute(filename, '[\/]\zs[^\/]\+[\/]\.\.[\/]', '', 'g') + return filename +endf + + +function! tlib#file#Canonic(filename, ...) abort "{{{3 + TVarArg ['mode', ''] + if empty(mode) + if a:filename =~# '^\\\\' + let mode = 'windows' + elseif a:filename =~# '^\(file\|ftp\|http\)s\?:' + let mode = 'url' + elseif (empty(mode) && g:tlib#sys#windows) + let mode = 'windows' + endif + endif + let filename = a:filename + if mode ==# 'windows' + let filename = substitute(filename, '/', '\\', 'g') + else + let filename = substitute(filename, '\\', '/', 'g') + endif + return filename +endf + + +function! s:SetScrollBind(world) abort "{{{3 + let sb = get(a:world, 'scrollbind', &scrollbind) + if sb != &scrollbind + let &scrollbind = sb + endif +endf + + +" :def: function! tlib#file#With(fcmd, bcmd, files, ?world={}) abort +function! tlib#file#With(fcmd, bcmd, files, ...) abort "{{{3 + Tlibtrace 'tlib', a:fcmd, a:bcmd, a:files + let world = a:0 >= 1 ? a:1 : {} + let unset_switchbuf = a:0 >= 2 ? a:2 : 0 + exec tlib#arg#Let([['world', {}]]) + call tlib#autocmdgroup#Init() + augroup TLibFileRead + autocmd! + augroup END + if unset_switchbuf + let switchbuf = &switchbuf + set switchbuf& + endif + try + for f in a:files + try + let bn = bufnr('^'.f.'$') + Tlibtrace 'tlib', f, bn + let bufloaded = bufloaded(bn) + let ok = 0 + let s:bufread = "" + if bn != -1 && buflisted(bn) + if !empty(a:bcmd) + let bcmd = a:bcmd .' '. bn + Tlibtrace 'tlib', bcmd + exec bcmd + let ok = 1 + call s:SetScrollBind(world) + endif + else + if filereadable(f) + if !empty(a:fcmd) + " TLogDBG a:fcmd .' '. tlib#arg#Ex(f) + exec 'autocmd TLibFileRead BufRead' escape(f, '\ ') 'let s:bufread=expand(":p")' + try + let fcmd = a:fcmd .' '. tlib#arg#Ex(f) + Tlibtrace 'tlib', fcmd + exec fcmd + finally + exec 'autocmd! TLibFileRead BufRead' + endtry + let ok = 1 + call s:SetScrollBind(world) + endif + else + echohl error + echom 'File not readable: '. f + echohl NONE + endif + endif + Tlibtrace 'tlib', ok, bufloaded, &filetype + if empty(s:bufread) && ok && !bufloaded && empty(&filetype) + doautocmd BufRead + endif + catch /^Vim\%((\a\+)\)\=:E325/ + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endfor + finally + augroup! TLibFileRead + if unset_switchbuf + let &switchbuf = switchbuf + endif + unlet! s:bufread + endtry + " TLogDBG "done" +endf + + +" Return 0 if the file isn't readable/doesn't exist. +" Otherwise return 1. +function! tlib#file#Edit(fileid) abort "{{{3 + if type(a:fileid) == 0 + let bn = a:fileid + let filename = fnamemodify(bufname(bn), ':p') + else + let filename = fnamemodify(a:fileid, ':p') + let bn = bufnr(filename) + endif + if filename == expand('%:p') + return 1 + else + Tlibtrace 'tlib', a:fileid, bn, filename, g:tlib#file#drop, filereadable(filename), bufnr('%') + if bn != -1 && buflisted(bn) + if g:tlib#file#drop + " echom "DBG" get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'drop', 'drop') fnameescape(filename) + " echom "DBG" bufnr('%') + else + " echom "DBG" get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + exec get(g:tlib#file#edit_cmds, 'buffer', 'buffer') bn + " echom "DBG" bufnr('%') + endif + return 1 + endif + if !filereadable(filename) && exists('#TLibPrepareFile#User') + exec 'doautocmd TLibPrepareFile User' filename + endif + if filereadable(filename) + try + " let file = tlib#arg#Ex(filename) + " Tlibtrace 'tlib', file + " echom "DBG" get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + exec get(g:tlib#file#edit_cmds, 'edit', 'edit') fnameescape(filename) + catch /E325/ + " swap file exists, let the user handle it + catch + echohl error + echom v:exception + echohl NONE + endtry + return 1 + else + echom "TLIB: File not readable: " . filename + if filename != a:fileid + echom "TLIB: original filename: " . a:fileid + endif + endif + endif + return 0 +endf + + +function! tlib#file#FilterFiles(files, options) abort "{{{3 + Tlibtrace 'tlib', a:files, a:options, g:tlib#file#reject_rx + if !get(a:options, 'all', 0) + call filter(a:files, 'v:val !~# g:tlib#file#reject_rx') + endif + Tlibtrace 'tlib', a:files + let type = get(a:options, 'type', 'fd') + Tlibtrace 'tlib', type + if type !~# 'd' || type !~# 'f' + call filter(a:files, 'isdirectory(v:val) ? type =~# "d" : type =~# "f"') + endif + Tlibtrace 'tlib', a:files + return a:files +endf + + +if v:version > 704 || (v:version == 704 && has('patch279')) + + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(glob(a:pattern, nosuf, 1), {'all': all}) + endf + + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(globpath(a:path, a:pattern, nosuf, 1), {'all': all}) + endf + +else + + " :nodoc: + function! tlib#file#Glob(pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(glob(a:pattern, nosuf), '\n'), {'all': all}) + endf + + " :nodoc: + function! tlib#file#Globpath(path, pattern, ...) abort "{{{3 + let all = a:0 >= 1 ? a:1 : 0 + let nosuf = a:0 >= 2 ? a:2 : 0 + return tlib#file#FilterFiles(split(globpath(a:path, a:pattern), '\n'), {'all': all}) + endf + +endif + + +let s:filereadable = {} + +augroup TLib + autocmd BufWritePost,FileWritePost,FocusLost * let s:filereadable = {} +augroup end + +function! tlib#file#Filereadable(filename) abort "{{{3 + if !has_key(s:filereadable, a:filename) + let s:filereadable[a:filename] = filereadable(a:filename) + endif + return s:filereadable[a:filename] +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/fixes.vim b/sources_non_forked/tlib/autoload/tlib/fixes.vim new file mode 100644 index 00000000..e9247dd6 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/fixes.vim @@ -0,0 +1,14 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-02-22. +" @Revision: 3 + + +function! tlib#fixes#Winpos() "{{{3 + if has('gui_win32') + return 'winpos '. getwinposx() .' '. getwinposy() + else + return '' + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/grep.vim b/sources_non_forked/tlib/autoload/tlib/grep.vim new file mode 100644 index 00000000..894b1ee7 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/grep.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2013-10-16. +" @Revision: 31 + + +function! tlib#grep#Do(cmd, rx, files) "{{{3 + " TLogVAR a:cmd, a:rx, a:files + let files = join(map(copy(a:files), 'tlib#arg#Ex(v:val, "")'), ' ') + let rx = '/'. escape(a:rx, '/') .'/j' + " TLogVAR rx, files + silent exec a:cmd rx files +endf + + +function! tlib#grep#LocList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd lvimgrep', a:rx, a:files) +endf + + +function! tlib#grep#QuickFixList(rx, files) "{{{3 + return tlib#grep#Do('noautocmd vimgrep', a:rx, a:files) +endf + + +function! tlib#grep#List(rx, files) "{{{3 + call setqflist([]) + call tlib#grep#Do('noautocmd vimgrepadd', a:rx, a:files) + let qfl = getqflist() + " TLogVAR qfl + " try + silent! colder + " catch + " call setqflist([], 'r') + " endtry + return qfl +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/hash.vim b/sources_non_forked/tlib/autoload/tlib/hash.vim new file mode 100644 index 00000000..29c9ef67 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/hash.vim @@ -0,0 +1,145 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 276 + + +if !exists('g:tlib#hash#use_crc32') + let g:tlib#hash#use_crc32 = '' "{{{2 +endif + + +if !exists('g:tlib#hash#use_adler32') + let g:tlib#hash#use_adler32 = '' "{{{2 +endif + + +function! tlib#hash#CRC32B(chars) "{{{3 + if !empty(g:tlib#hash#use_crc32) + let use = g:tlib#hash#use_crc32 + elseif has('ruby') + let use = 'ruby' + else + let use = 'vim' + endif + if exists('*tlib#hash#CRC32B_'. use) + return tlib#hash#CRC32B_{use}(a:chars) + else + throw "Unknown version of tlib#hash#CRC32B: ". use + endif +endf + + +function! tlib#hash#CRC32B_ruby(chars) "{{{3 + if has('ruby') + let rv = '' + if !exists('s:loaded_ruby_zlib') + ruby require 'zlib' + let s:loaded_ruby_zlib = 1 + endif + ruby VIM::command('let rv = "%08X"' % Zlib.crc32(VIM::evaluate("a:chars"))) + return rv + else + throw "tlib#hash#CRC32B_ruby not supported in this version of vim" + endif +endf + + +function! tlib#hash#CRC32B_vim(chars) "{{{3 + if !exists('s:crc_table') + let cfile = tlib#persistent#Filename('tlib', 'crc_table', 1) + let s:crc_table = tlib#persistent#Value(cfile, 'tlib#hash#CreateCrcTable', 0) + endif + let xFFFF_FFFF = repeat([1], 32) + let crc = tlib#bitwise#XOR([0], xFFFF_FFFF, 'bits') + for char in split(a:chars, '\zs') + let octet = char2nr(char) + let r1 = tlib#bitwise#ShiftRight(crc, 8) + let i0 = tlib#bitwise#AND(crc, xFFFF_FFFF, 'bits') + let i1 = tlib#bitwise#XOR(i0, octet, 'bits') + let i2 = tlib#bitwise#Bits2Num(tlib#bitwise#AND(i1, 0xff, 'bits')) + let r2 = s:crc_table[i2] + let crc = tlib#bitwise#XOR(r1, r2, 'bits') + endfor + let crc = tlib#bitwise#XOR(crc, xFFFF_FFFF, 'bits') + let rv = tlib#bitwise#Bits2Num(crc, 16) + if len(rv) < 8 + let rv = repeat('0', 8 - len(rv)) . rv + endif + return rv +endf + + +" :nodoc: +function! tlib#hash#CreateCrcTable() "{{{3 + let sum = 0.0 + for exponent in [0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26, 32] + let exp = tlib#bitwise#Bits2Num(repeat([0], 32 - exponent) + [1], 10.0) + let sum += exp + endfor + let divisor = tlib#bitwise#Num2Bits(sum) + let crc_table = [] + for octet in range(256) + let remainder = tlib#bitwise#Num2Bits(octet) + for i in range(8) + if get(remainder, i) != 0 + let remainder = tlib#bitwise#XOR(remainder, tlib#bitwise#ShiftLeft(divisor, i), "bits") + endif + endfor + let remainder = tlib#bitwise#ShiftRight(remainder, 8) + call add(crc_table, remainder) + endfor + return crc_table +endf + + +function! tlib#hash#Adler32(chars) "{{{3 + if !empty(g:tlib#hash#use_adler32) + let use = g:tlib#hash#use_adler32 + elseif exists('*or') + let use = 'vim' + else + let use = 'tlib' + endif + if exists('*tlib#hash#Adler32_'. use) + return tlib#hash#Adler32_{use}(a:chars) + else + throw "Unknown version of tlib#hash#Adler32_: ". use + endif +endf + + +function! tlib#hash#Adler32_vim(chars) "{{{3 + if exists('*or') + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = b * float2nr(pow(2, 16)) + let checksum = or(bb, a) + " TLogVAR checksum, a, b, bb + return printf("%08X", checksum) + else + throw "TLIB: Vim version doesn't support bitwise or()" + endif +endf + + +function! tlib#hash#Adler32_tlib(chars) "{{{3 + let mod_adler = 65521 + let a = 1 + let b = 0 + for index in range(len(a:chars)) + let c = char2nr(a:chars[index]) + let a = (a + c) % mod_adler + let b = (b + a) % mod_adler + endfor + let bb = tlib#bitwise#ShiftLeft(tlib#bitwise#Num2Bits(b), 16) + let checksum = tlib#bitwise#OR(bb, a, "bits") + return printf('%08s', tlib#bitwise#Bits2Num(checksum, 16)) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/hook.vim b/sources_non_forked/tlib/autoload/tlib/hook.vim new file mode 100644 index 00000000..07d05041 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/hook.vim @@ -0,0 +1,25 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 11 + + +" :def: function! tlib#hook#Run(hook, ?dict={}) +" Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. +function! tlib#hook#Run(hook, ...) "{{{3 + TVarArg ['dict', {}] + if has_key(dict, a:hook) + let hook = dict[a:hook] + else + let hook = tlib#var#Get(a:hook, 'wbg') + endif + if empty(hook) + return 0 + else + let world = dict + exec hook + return 1 + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/input.vim b/sources_non_forked/tlib/autoload/tlib/input.vim new file mode 100644 index 00000000..e294e2ac --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/input.vim @@ -0,0 +1,1270 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 1430 + +" :filedoc: +" Input-related, select from a list etc. + +" If a list is bigger than this value, don't try to be smart when +" selecting an item. Be slightly faster instead. +" See |tlib#input#List()|. +TLet g:tlib#input#sortprefs_threshold = 200 + + +" If a list contains more items, |tlib#input#List()| does not perform an +" incremental "live search" but uses |input()| to query the user for a +" filter. This is useful on slower machines or with very long lists. +TLet g:tlib#input#livesearch_threshold = 1000 + + +" Determine how |tlib#input#List()| and related functions work. +" Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: +" glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, +" |g:tlib#Filter_glob#char|) are interpreted as glob-like +" |wildcards| (this is the default method) +" - Examples: +" - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_glob#New()|. +" cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is +" expanded to "\.\{-}" +" - A period character (".") acts as a wildcard as if ".\{-}" (see +" |/\{-|) were entered. +" - Examples: +" - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match +" "far". +" - Otherwise it is a derivate of the cnf method (see below). +" - See also |tlib#Filter_cnfd#New()|. +" cnf .... Match substrings +" - A blank creates an AND conjunction, i.e. the next pattern has to +" match too. +" - A pipe character ("|") creates an OR conjunction, either this or +" the next next pattern has to match. +" - Patterns are very 'nomagic' |regexp| with a |\V| prefix. +" - A pattern starting with "-" makes the filter exclude items +" matching that pattern. +" - Examples: +" - "foo bar" matches items that contain the strings "foo" AND +" "bar". +" - "foo|bar boo|far" matches items that contain either ("foo" OR +" "bar") AND ("boo" OR "far"). +" - See also |tlib#Filter_cnf#New()|. +" seq .... Match sequences of characters +" - |tlib#Filter_seq#New()| +" fuzzy .. Match fuzzy character sequences +" - |tlib#Filter_fuzzy#New()| +TLet g:tlib#input#filter_mode = 'glob' + + +" The highlight group to use for showing matches in the input list +" window. +" See |tlib#input#List()|. +TLet g:tlib#input#higroup = 'IncSearch' + +" When 1, automatically select the last remaining item only if the list +" had only one item to begin with. +" When 2, automatically select a last remaining item after applying +" any filters. +" See |tlib#input#List()|. +TLet g:tlib_pick_last_item = 1 + + +" :doc: +" Keys for |tlib#input#List|~ + +TLet g:tlib#input#and = ' ' +TLet g:tlib#input#or = '|' +TLet g:tlib#input#not = '-' + +" When editing a list with |tlib#input#List|, typing these numeric chars +" (as returned by getchar()) will select an item based on its index, not +" based on its name. I.e. in the default setting, typing a "4" will +" select the fourth item, not the item called "4". +" In order to make keys 0-9 filter the items in the list and make +" select an item by its index, remove the keys 48 to 57 from +" this dictionary. +" Format: [KEY] = BASE ... the number is calculated as KEY - BASE. +" :nodefault: +TLet g:tlib#input#numeric_chars = { + \ 176: 176, + \ 177: 176, + \ 178: 176, + \ 179: 176, + \ 180: 176, + \ 181: 176, + \ 182: 176, + \ 183: 176, + \ 184: 176, + \ 185: 176, + \} + " \ 48: 48, + " \ 49: 48, + " \ 50: 48, + " \ 51: 48, + " \ 52: 48, + " \ 53: 48, + " \ 54: 48, + " \ 55: 48, + " \ 56: 48, + " \ 57: 48, + + +" :nodefault: +" The default key bindings for single-item-select list views. +" +" This variable is best customized via the variable +" g:tlib_extend_keyagents_InputList_s. If you want to use , +" to move the cursor up and down, add these two lines to your |vimrc| +" file: +" +" let g:tlib_extend_keyagents_InputList_s = { +" \ 10: 'tlib#agent#Down', +" \ 11: 'tlib#agent#Up' +" \ } +TLet g:tlib#input#keyagents_InputList_s = { + \ "\": 'tlib#agent#PageUp', + \ "\": 'tlib#agent#PageDown', + \ "\": 'tlib#agent#Home', + \ "\": 'tlib#agent#End', + \ "\": 'tlib#agent#Up', + \ "\": 'tlib#agent#Down', + \ 9: 'tlib#agent#Complete', + \ "\": 'tlib#agent#UpN', + \ "\": 'tlib#agent#DownN', + \ "\": 'tlib#agent#ShiftLeft', + \ "\": 'tlib#agent#ShiftRight', + \ 18: 'tlib#agent#Reset', + \ 242: 'tlib#agent#Reset', + \ 17: 'tlib#agent#Input', + \ 241: 'tlib#agent#Input', + \ 27: 'tlib#agent#Exit', + \ 26: 'tlib#agent#Suspend', + \ 250: 'tlib#agent#Suspend', + \ 15: 'tlib#agent#SuspendToParentWindow', + \ "\": 'tlib#agent#Help', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ExecAgentByName', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#ReduceFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#PopFilter', + \ "\": 'tlib#agent#Wildcard', + \ 191: 'tlib#agent#Debug', + \ char2nr(g:tlib#input#or): 'tlib#agent#OR', + \ char2nr(g:tlib#input#and): 'tlib#agent#AND', + \ } + " \ 63: 'tlib#agent#Help', + +if exists('g:tlib_extend_keyagents_InputList_s') + let g:tlib#input#keyagents_InputList_s = extend(g:tlib#input#keyagents_InputList_s, g:tlib_extend_keyagents_InputList_s) +endif + + +" :nodefault: +TLet g:tlib#input#keyagents_InputList_m = { + \ 35: 'tlib#agent#Select', + \ "\": 'tlib#agent#SelectUp', + \ "\": 'tlib#agent#SelectDown', + \ 1: 'tlib#agent#SelectAll', + \ 225: 'tlib#agent#SelectAll', + \ "\": 'tlib#agent#ToggleRestrictView', + \ } +" "\": 'tlib#agent#Select' + +if exists('g:tlib_extend_keyagents_InputList_m') + let g:tlib#input#keyagents_InputList_m = extend(g:tlib#input#keyagents_InputList_m, g:tlib_extend_keyagents_InputList_m) +endif + + + +" :nodefault: +TLet g:tlib#input#handlers_EditList = [ + \ {'key': 5, 'agent': 'tlib#agent#EditItem', 'key_name': '', 'help': 'Edit item'}, + \ {'key': 4, 'agent': 'tlib#agent#DeleteItems', 'key_name': '', 'help': 'Delete item(s)'}, + \ {'key': 14, 'agent': 'tlib#agent#NewItem', 'key_name': '', 'help': 'New item'}, + \ {'key': 24, 'agent': 'tlib#agent#Cut', 'key_name': '', 'help': 'Cut item(s)'}, + \ {'key': 3, 'agent': 'tlib#agent#Copy', 'key_name': '', 'help': 'Copy item(s)'}, + \ {'key': 22, 'agent': 'tlib#agent#Paste', 'key_name': '', 'help': 'Paste item(s)'}, + \ {'pick_last_item': 0}, + \ {'return_agent': 'tlib#agent#EditReturnValue'}, + \ {'help_extra': [ + \ 'Submit changes by pressing ENTER or or ', + \ 'Cancel editing by pressing c' + \ ]}, + \ ] + + +" A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to +" customize keyboard shortcuts in the list view. +TLet g:tlib#input#user_shortcuts = {} + + +" If true, define a popup menu for |tlib#input#List()| and related +" functions. +TLet g:tlib#input#use_popup = has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32')) + + +" How to format filenames: +" l ... Show basenames on the left side, separated from the +" directory names +" r ... Show basenames on the right side +TLet g:tlib#input#format_filename = 'l' + + +" If g:tlib#input#format_filename == 'r', how much space should be kept +" free on the right side. +TLet g:tlib#input#filename_padding_r = '&co / 10' + + +" If g:tlib#input#format_filename == 'l', an expression that +" |eval()|uates to the maximum display width of filenames. +TLet g:tlib#input#filename_max_width = '&co / 2' + + +" Functions related to tlib#input#List(type, ...) "{{{2 + +" :def: function! tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) +" Select a single or multiple items from a list. Return either the list +" of selected elements or its indexes. +" +" By default, typing numbers will select an item by its index. See +" |g:tlib#input#numeric_chars| to find out how to change this. +" +" The item is automatically selected if the numbers typed equals the +" number of digits of the list length. I.e. if a list contains 20 items, +" typing 1 will first highlight item 1 but it won't select/use it +" because 1 is an ambiguous input in this context. If you press enter, +" the first item will be selected. If you press another digit (e.g. 0), +" item 10 will be selected. Another way to select item 1 would be to +" type 01. If the list contains only 9 items, typing 1 would select the +" first item right away. +" +" type can be: +" s ... Return one selected element +" si ... Return the index of the selected element +" m ... Return a list of selected elements +" mi ... Return a list of indexes +" +" Several pattern matching styles are supported. See +" |g:tlib#input#filter_mode|. +" +" Users can type to complete the current filter with the longest +" match. +" +" EXAMPLES: > +" echo tlib#input#List('s', 'Select one item', [100,200,300]) +" echo tlib#input#List('si', 'Select one item', [100,200,300]) +" echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) +" echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) +" +" See ../samples/tlib/input/tlib_input_list.vim (move the cursor over +" the filename and press gf) for a more elaborated example. +function! tlib#input#List(type, ...) "{{{3 + exec tlib#arg#Let([ + \ ['query', ''], + \ ['list', []], + \ ['handlers', []], + \ ['rv', ''], + \ ['timeout', 0], + \ ]) + " let handlers = a:0 >= 1 ? a:1 : [] + " let rv = a:0 >= 2 ? a:2 : '' + " let timeout = a:0 >= 3 ? a:3 : 0 + " let backchar = ["\", "\"] + + if a:type =~ '^resume' + let world = b:tlib_{matchstr(a:type, ' \zs.\+')} + else + let world = tlib#World#New({ + \ 'type': a:type, + \ 'base': list, + \ 'query': query, + \ 'timeout': timeout, + \ 'rv': rv, + \ 'handlers': handlers, + \ }) + let scratch_name = tlib#list#Find(handlers, 'has_key(v:val, "scratch_name")', '', 'v:val.scratch_name') + if !empty(scratch_name) + let world.scratch = scratch_name + endif + let world.scratch_vertical = tlib#list#Find(handlers, 'has_key(v:val, "scratch_vertical")', 0, 'v:val.scratch_vertical') + call world.Set_display_format(tlib#list#Find(handlers, 'has_key(v:val, "display_format")', '', 'v:val.display_format')) + let world.initial_index = tlib#list#Find(handlers, 'has_key(v:val, "initial_index")', 1, 'v:val.initial_index') + let world.index_table = tlib#list#Find(handlers, 'has_key(v:val, "index_table")', [], 'v:val.index_table') + let world.state_handlers = filter(copy(handlers), 'has_key(v:val, "state")') + let world.post_handlers = filter(copy(handlers), 'has_key(v:val, "postprocess")') + let world.filter_format = tlib#list#Find(handlers, 'has_key(v:val, "filter_format")', '', 'v:val.filter_format') + let world.return_agent = tlib#list#Find(handlers, 'has_key(v:val, "return_agent")', '', 'v:val.return_agent') + let world.help_extra = tlib#list#Find(handlers, 'has_key(v:val, "help_extra")', '', 'v:val.help_extra') + let world.resize = tlib#list#Find(handlers, 'has_key(v:val, "resize")', '', 'v:val.resize') + let world.show_empty = tlib#list#Find(handlers, 'has_key(v:val, "show_empty")', 0, 'v:val.show_empty') + let world.pick_last_item = tlib#list#Find(handlers, 'has_key(v:val, "pick_last_item")', + \ tlib#var#Get('tlib_pick_last_item', 'bg'), 'v:val.pick_last_item') + let world.numeric_chars = tlib#list#Find(handlers, 'has_key(v:val, "numeric_chars")', + \ g:tlib#input#numeric_chars, 'v:val.numeric_chars') + let world.key_handlers = filter(copy(handlers), 'has_key(v:val, "key")') + let filter = tlib#list#Find(handlers, 'has_key(v:val, "filter")', '', 'v:val.filter') + if !empty(filter) + " let world.initial_filter = [[''], [filter]] + " let world.initial_filter = [[filter]] + Tlibtrace 'tlib', world.initial_filter, filter + call world.SetInitialFilter(filter) + endif + endif + return tlib#input#ListW(world) +endf + + +" A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from +" dict. +function! tlib#input#ListD(dict) "{{{3 + return tlib#input#ListW(tlib#World#New(a:dict)) +endf + + +" :def: function! tlib#input#ListW(world, ?command='') +" The second argument (command) is meant for internal use only. +" The same as |tlib#input#List| but the arguments are packed into world +" (an instance of tlib#World as returned by |tlib#World#New|). +function! tlib#input#ListW(world, ...) "{{{3 + TVarArg 'cmd' + let time0 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time0 + let world = a:world + if world.pick_last_item >= 1 && stridx(world.type, 'e') == -1 && len(world.base) <= 1 + call world.CloseScratch(1) + let rv = get(world.base, 0, world.rv) + if stridx(world.type, 'm') != -1 + return [rv] + else + return rv + endif + endif + call s:Init(world, cmd) + Tlibtrace 'tlib', world.state, world.sticky, world.initial_index + " let statusline = &l:statusline + " let laststatus = &laststatus + let showmode = &showmode + set noshowmode + let lastsearch = @/ + let scrolloff = &l:scrolloff + let &l:scrolloff = 0 + let @/ = '' + let dlist = [] + let post_keys = '' + " let &laststatus = 2 + + try + while !empty(world.state) && world.state !~ '^exit' && (world.show_empty || !empty(world.base)) + let post_keys = '' + Tlibtrace 'tlib', 'while', world.state + let time01 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time01, time01 - time0 + try + let world = s:RunStateHandlers(world) + + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 + if world.state =~ '\' + call world.Reset() + continue + endif + + call s:SetOffset(world) + + let time02 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time02, time02 - time0 + Tlibtrace 'tlib', world.state + if world.state == 'scroll' + let world.prefidx = world.offset + let world.state = 'redisplay' + endif + + if world.state =~ '\' + let world.sticky = 1 + endif + + Tlibtrace 'tlib', world.filter + Tlibtrace 'tlib', world.sticky + if world.state =~ '\' + Tlibtrace 'tlib', world.rv + throw 'picked' + elseif world.state =~ '\' + let world.rv = world.CurrentItem() + Tlibtrace 'tlib', world.rv + throw 'picked' + elseif world.state =~ 'display' + if world.state =~ '^display' + let time03 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time03, time03 - time0 + if world.IsValidFilter() + let time1 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time1, time1 - time0 + call world.BuildTableList() + let time2 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time2, time2 - time0 + let world.llen = len(world.list) + if empty(world.index_table) + let dindex = range(1, world.llen) + let world.index_width = len(world.llen) + else + let dindex = world.index_table + let world.index_width = len(max(dindex)) + endif + let time3 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time3, time3 - time0 + if world.llen == 0 && !world.show_empty + call world.ReduceFilter() + let world.offset = 1 + continue + else + if world.llen == 1 + let world.last_item = world.list[0] + if world.pick_last_item >= 2 + " echom 'Pick last item: '. world.list[0] + let world.prefidx = '1' + throw 'pick' + endif + else + let world.last_item = '' + endif + endif + let time4 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time4, time4 - time0 + Tlibtrace 'tlib', world.idx, world.llen, world.state + if world.state == 'display' + if world.idx == '' && world.llen < g:tlib#input#sortprefs_threshold && !world.FilterIsEmpty() + call world.SetPrefIdx() + else + let world.prefidx = world.idx == '' ? world.initial_index : world.idx + endif + if world.prefidx > world.llen + let world.prefidx = world.llen + elseif world.prefidx < 1 + let world.prefidx = 1 + endif + endif + let time5 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time5, time5 - time0 + Tlibtrace 'tlib', world.initial_index, world.prefidx + Tlibtrace 'tlib', len(world.list) + let dlist = world.DisplayFormat(world.list) + Tlibtrace 'tlib', world.prefidx + let time6 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time6, time6 - time0 + if world.offset_horizontal > 0 + call map(dlist, 'tlib#string#Strcharpart(v:val, world.offset_horizontal)') + endif + let time7 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time7, time7 - time0 + let dlist = map(range(0, world.llen - 1), 'printf("%0'. world.index_width .'d", dindex[v:val]) .": ". dlist[v:val]') + let time8 = str2float(reltimestr(reltime())) + Tlibtrace 'tlib', time8, time8 - time0 + + else + + let dlist = ['Malformed filter'] + + endif + else + if world.prefidx == 0 + let world.prefidx = 1 + endif + endif + Tlibtrace 'tlib', world.idx, world.prefidx + + Tlibtrace 'tlib', world.prefidx, world.offset + Tlibtrace 'tlib', world.initial_display, !tlib#char#IsAvailable() + if world.state =~ '\' || world.initial_display || !tlib#char#IsAvailable() + call world.DisplayList(world.Query(), dlist) + call world.FollowCursor() + let world.initial_display = 0 + endif + if world.state =~ '\' + let world.state = 'suspend' + else + let world.state = '' + endif + else + " if world.state == 'scroll' + " let world.prefidx = world.offset + " endif + call world.DisplayList() + if world.state == 'help' || world.state == 'printlines' + let world.state = 'display' + else + let world.state = '' + call world.FollowCursor() + endif + endif + " TAssert IsNotEmpty(world.scratch) + let world.list_wid = tlib#win#GetID() + let world.list_wnr = winnr() + + Tlibtrace 'tlib', world.state, world.next_state + if !empty(world.next_state) + let world.state = world.next_state + let world.next_state = '' + endif + + if world.state =~ '\' + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + continue + endif + + if world.state =~ '\' + let query = matchstr(world.state, '\" + if v:mouse_win == world.list_wnr + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + " let world.offset = world.prefidx + if empty(world.prefidx) + " call feedkeys(c, 't') + let c = s:GetModdedChar(world) + let world.state = 'help' + continue + endif + throw 'pick' + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + elseif c == "\" + if v:mouse_win == world.list_wnr + call s:BuildMenu(world) + let world.state = 'redisplay' + if s:PopupmenuExists() == 1 + " if v:mouse_lnum != line('.') + " endif + let world.prefidx = world.GetLineIdx(v:mouse_lnum) + let world.next_state = 'eval[Waiting for popup menu ... Press ESC to continue]' + call world.DisplayList() + if line('w$') - v:mouse_lnum < 6 + popup ]TLibInputListPopupMenu + else + popup! ]TLibInputListPopupMenu + endif + endif + else + let post_keys = v:mouse_lnum .'gg'. v:mouse_col .'|'. c + if world.allow_suspend + let world = tlib#agent#SuspendToParentWindow(world, world.rv) + else + let world.state = 'exit empty' + endif + endif + Tlibtrace 'tlib', world.prefidx, world.state + elseif has_key(world.key_map[world.key_mode], 'unknown_key') + let agent = world.key_map[world.key_mode].unknown_key.agent + " let world = call(agent, [world, c]) + " call s:CheckAgentReturnValue(agent, world) + let world = s:CallAgent({'agent': agent}, world, c) + elseif c >= 32 + let world.state = 'display' + let numbase = get(world.numeric_chars, c, -99999) + Tlibtrace 'tlib', numbase, world.numeric_chars, c + if numbase != -99999 + let world.idx .= (c - numbase) + if len(world.idx) == world.index_width + let world.prefidx = world.idx + Tlibtrace 'tlib', world.prefidx + throw 'pick' + endif + else + let world.idx = '' + Tlibtrace 'tlib', world.filter + if world.llen > g:tlib#input#livesearch_threshold + let pattern = input('Filter: ', world.CleanFilter(world.filter[0][0]) . nr2char(c)) + if empty(pattern) + let world.state = 'exit empty' + else + call world.SetFrontFilter(pattern) + echo + endif + elseif c == 124 + call insert(world.filter[0], []) + else + call world.PushFrontFilter(c) + endif + " continue + if c == 45 && world.filter[0][0] == '-' + let world.state = 'redisplay' + end + endif + else + let world.state = 'redisplay' + " let world.state = 'continue' + endif + + catch /^picked$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = 'exit' + + catch /^pick$/ + call world.ClearAllMarks() + call world.MarkCurrent(world.prefidx) + let world.state = '' + + finally + if world.state =~ '\' + " if !world.allow_suspend + " echom "Cannot be suspended" + " let world.state = 'redisplay' + " endif + elseif !empty(world.list) && !empty(world.base) + if empty(world.state) + let world.rv = world.CurrentItem() + Tlibtrace 'tlib', world.state, world.rv + endif + for handler in world.post_handlers + let state = get(handler, 'postprocess', '') + Tlibtrace 'tlib', handler + Tlibtrace 'tlib', state + Tlibtrace 'tlib', world.state + if state == world.state + let agent = handler.agent + let [world, world.rv] = call(agent, [world, world.rv]) + Tlibtrace 'tlib', world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + endif + endfor + endif + endtry + endwh + + Tlibtrace 'tlib', world.state + Tlibtrace 'tlib', len(world.list) + Tlibtrace 'tlib', world.sel_idx + Tlibtrace 'tlib', world.idx + Tlibtrace 'tlib', world.prefidx + Tlibtrace 'tlib', world.rv + if world.state =~ '\<\(empty\|escape\)\>' + let world.sticky = 0 + endif + if world.state =~ '\' + Tlibtrace 'tlib', world.prefidx + " exec world.prefidx + return + elseif world.state =~ '\' + " TLog "empty" + Tlibtrace 'tlib', world.type + if stridx(world.type, 'm') != -1 + return [] + elseif stridx(world.type, 'i') != -1 + return 0 + else + return '' + endif + elseif !empty(world.return_agent) + Tlibtrace 'tlib', world.return_agent + call world.CloseScratch(1) + " TAssert IsNotEmpty(world.scratch) + return call(world.return_agent, [world, world.GetSelectedItems(world.rv)]) + elseif stridx(world.type, 'w') != -1 + " TLog "return_world" + return world + elseif stridx(world.type, 'm') != -1 + " TLog "return_multi" + return world.GetSelectedItems(world.rv) + elseif stridx(world.type, 'i') != -1 + " TLog "return_index" + if empty(world.index_table) + return world.rv + else + return world.index_table[world.rv - 1] + endif + else + " TLog "return_else" + return world.rv + endif + + finally + call world.Leave() + + " Tlibtrace 'tlib', statusline + " let &l:statusline = statusline + " let &laststatus = laststatus + if &showmode != showmode + let &showmode = showmode + endif + silent! let @/ = lastsearch + let &l:scrolloff = scrolloff + if s:PopupmenuExists() == 1 + silent! aunmenu ]TLibInputListPopupMenu + endif + + Tlibtrace 'tlib', world.state + if world.state !~ '\' + " redraw + Tlibtrace 'tlib', world.sticky, bufnr("%") + if world.sticky + Tlibtrace 'tlib', world.bufnr + if world.scratch_split > 0 + if bufwinnr(world.bufnr) == -1 + call world.UseScratch() + endif + let world = tlib#agent#SuspendToParentWindow(world, world.GetSelectedItems(world.rv)) + endif + else + Tlibtrace 'tlib', world.state, world.win_id, world.bufnr + if world.CloseScratch(1) + Tlibtrace 'tlib', get(world,'winview','') + call tlib#win#SetLayout(world.winview) + endif + endif + endif + if world.state !~ '\' + call world.RestoreWindow() + endif + " for i in range(0,5) + " call getchar(0) + " endfor + echo + redraw! + if !empty(post_keys) + Tlibtrace 'tlib', post_keys + call feedkeys(post_keys) + endif + let world.state = '' + endtry +endf + + +function! s:CallAgent(handler, world, list) abort "{{{3 + let agent = a:handler.agent + let args = [a:world, a:list] + if has_key(a:handler, 'args') + let args += a:handler.args + endif + let world = call(agent, args) + Tlibtrace 'tlib', world.state, world.rv + call s:CheckAgentReturnValue(agent, world) + return world +endf + +function! s:GetModdedChar(world) "{{{3 + let [char, mode] = tlib#char#Get(a:world.timeout, a:world.timeout_resolution, 1) + if char !~ '\D' && char > 0 && mode != 0 + return printf("<%s-%s>", mode, char) + else + return char + endif +endf + + +function! s:Init(world, cmd) "{{{3 + Tlibtrace 'tlib', a:cmd + let a:world.initial_display = 1 + if a:cmd =~ '\' + let a:world.sticky = 1 + endif + if a:cmd =~ '^resume' + call a:world.UseInputListScratch() + let a:world.initial_index = line('.') + if a:cmd =~ '\' + let a:world.state = 'pick' + let a:world.prefidx = a:world.initial_index + else + call a:world.Retrieve(1) + endif + " if !empty(a:world.resume_state) + " let a:world.state = a:world.resume_state + " endif + elseif !a:world.initialized + Tlibtrace 'tlib', a:world.initialized, a:world.win_id, a:world.bufnr + let a:world.filetype = &filetype + let a:world.fileencoding = &fileencoding + call a:world.SetMatchMode(tlib#var#Get('tlib#input#filter_mode', 'wb')) + call a:world.Initialize() + if !has_key(a:world, 'key_mode') + let a:world.key_mode = 'default' + endif + Tlibtrace 'tlib', has_key(a:world,'key_map') + if has_key(a:world, 'key_map') + Tlibtrace 'tlib', has_key(a:world.key_map,a:world.key_mode) + if has_key(a:world.key_map, a:world.key_mode) + let a:world.key_map[a:world.key_mode] = extend( + \ a:world.key_map[a:world.key_mode], + \ copy(g:tlib#input#keyagents_InputList_s), + \ 'keep') + else + let a:world.key_map[a:world.key_mode] = copy(g:tlib#input#keyagents_InputList_s) + endif + else + let a:world.key_map = { + \ a:world.key_mode : copy(g:tlib#input#keyagents_InputList_s) + \ } + endif + Tlibtrace 'tlib', a:world.type + if stridx(a:world.type, 'm') != -1 + call extend(a:world.key_map[a:world.key_mode], g:tlib#input#keyagents_InputList_m, 'force') + endif + for key_mode in keys(a:world.key_map) + let a:world.key_map[key_mode] = map(a:world.key_map[key_mode], 'type(v:val) == 4 ? v:val : {"agent": v:val}') + endfor + Tlibtrace 'tlib', a:world.key_mode + if type(a:world.key_handlers) == 3 + call s:ExtendKeyMap(a:world, a:world.key_mode, a:world.key_handlers) + elseif type(a:world.key_handlers) == 4 + for [world_key_mode, world_key_handlers] in items(a:world.key_handlers) + call s:ExtendKeyMap(a:world, world_key_mode, world_key_handlers) + endfor + else + throw "tlib#input#ListW: key_handlers must be either a list or a dictionary" + endif + Tlibtrace 'tlib', a:world.type, a:world.key_map + if !empty(a:cmd) + let a:world.state .= ' '. a:cmd + endif + endif + Tlibtrace 'tlib', a:world.state, a:world.sticky +endf + + +function! s:ExtendKeyMap(world, key_mode, key_handlers) "{{{3 + for handler in a:key_handlers + let k = get(handler, 'key', '') + if !empty(k) + let a:world.key_map[a:key_mode][k] = handler + endif + endfor +endf + + +function! s:PopupmenuExists() + if !g:tlib#input#use_popup + \ || exists(':popup') != 2 + \ || !(has('gui_win32') || has('gui_gtk') || has('gui_gtk2')) + " \ || !has('gui_win32') + let rv = -1 + else + try + let rv = 1 + silent amenu ]TLibInputListPopupMenu + catch + let rv = 0 + endtry + endif + Tlibtrace 'tlib', rv + return rv +endf + + +function! s:BuildMenu(world) "{{{3 + if g:tlib#input#use_popup && s:PopupmenuExists() == 0 + call s:BuildItem('Pick\ selected\ item', {'key_name': '', 'eval': 'let world.state = "pick"'}) + call s:BuildItem('Cancel', {'key_name': '', 'agent': 'tlib#agent#Exit'}) + call s:BuildItem('Select', {'key_name': '#', 'agent': 'tlib#agent#Select'}) + call s:BuildItem('Select\ all', {'key_name': '', 'agent': 'tlib#agent#SelectAll'}) + call s:BuildItem('Reset\ list', {'key_name': '', 'agent': 'tlib#agent#Reset'}) + call s:BuildItem('-StandardEntries-', {'key': ":", 'eval': 'let world.state = "redisplay"'}) + for [key_mode, key_handlers] in items(a:world.key_map) + let keys = sort(keys(key_handlers)) + let mitems = {} + for key in keys + let handler = key_handlers[key] + let k = get(handler, 'key', '') + if !empty(k) && has_key(handler, 'help') && !empty(handler.help) + if empty(key_mode) || key_mode == 'default' + let mname = '' + else + let mname = escape(key_mode, ' .\') .'.' + endif + if has_key(handler, 'submenu') + let submenu = escape(handler.submenu, ' .\') + else + let submenu = '~' + endif + for mfield in ['menu', 'help', 'key_name', 'agent'] + if has_key(handler, mfield) + let mname .= escape(handler[mfield], ' .\') + break + endif + endfor + if !has_key(mitems, submenu) + let mitems[submenu] = {} + endif + let mitems[submenu][mname] = handler + endif + endfor + for msubname in sort(keys(mitems)) + let msubitems = mitems[msubname] + if msubname == '~' + let msubmname = '' + else + let msubmname = msubname .'.' + endif + for mname in sort(keys(msubitems)) + let msname = msubmname . mname + let handler = msubitems[mname] + call s:BuildItem(msname, handler) + " if has_key(handler, 'agent') + " call s:BuildItem(msname, {'agent': handler.agent}) + " else + " call s:BuildItem(msname, {'key': handler.key_name}) + " endif + endfor + endfor + endfor + endif +endf + + +function! s:BuildItem(menu, def) "{{{3 + if has('gui_win32') + let key_mode = 'c' + elseif has('gui_gtk') || has('gui_gtk2') + let key_mode = 'raw' + endif + for k in ['agent', 'eval', 'key_name', 'key'] + if has('gui_win32') + elseif has('gui_gtk') || has('gui_gtk') + if k == 'agent' || k == 'eval' + continue + endif + endif + try + if has_key(a:def, k) + let v = a:def[k] + if k == 'key' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "'. v .'"' + else + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) v + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) v + endif + elseif k == 'key_name' + if key_mode == 'c' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let c = "\'. v .'"' + else + let key = v + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) key + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) key + endif + elseif k == 'agent' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_agent ='. string(v) .'' + elseif k == 'eval' + " echom 'DBG amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + exec 'amenu' (']TLibInputListPopupMenu.'. a:menu) ':let world.next_eval ='. string(v) .'' + endif + return + endif + catch + endtry + endfor +endf + + +function! s:RunStateHandlers(world) "{{{3 + " Provide the variable "world" in the environment of an "exec" + " handler (ea). + let world = a:world + for handler in a:world.state_handlers + let eh = get(handler, 'state', '') + if !empty(eh) && a:world.state =~ eh + let ea = get(handler, 'exec', '') + if !empty(ea) + exec ea + else + let agent = get(handler, 'agent', '') + " let world = call(agent, [a:world, a:world.GetSelectedItems(a:world.CurrentItem())]) + " call s:CheckAgentReturnValue(agent, a:world) + let world = s:CallAgent({'agent': agent}, world, world.GetSelectedItems(world.CurrentItem())) + endif + endif + endfor + return world +endf + + +function! s:CheckAgentReturnValue(name, value) "{{{3 + if type(a:value) != 4 && !has_key(a:value, 'state') + echoerr 'Malformed agent: '. a:name + endif + return a:value +endf + + +function! s:SetOffset(world) "{{{3 + let llenw = len(a:world.base) - winheight(0) + 1 + if a:world.offset > llenw + let a:world.offset = llenw + endif + if a:world.offset < 1 + let a:world.offset = 1 + endif +endf + + +" Functions related to tlib#input#EditList(type, ...) "{{{2 + +" :def: function! tlib#input#EditList(query, list, ?timeout=0) +" Edit a list. +" +" EXAMPLES: > +" echo tlib#input#EditList('Edit:', [100,200,300]) +function! tlib#input#EditList(query, list, ...) "{{{3 + let handlers = a:0 >= 1 && !empty(a:1) ? a:1 : g:tlib#input#handlers_EditList + let default = a:0 >= 2 ? a:2 : [] + let timeout = a:0 >= 3 ? a:3 : 0 + Tlibtrace 'tlib', handlers + let rv = tlib#input#List('me', a:query, copy(a:list), handlers, default, timeout) + Tlibtrace 'tlib', rv + if empty(rv) + return a:list + else + let [success, list] = rv + return success ? list : a:list + endif +endf + + +function! tlib#input#Resume(name, pick, bufnr) "{{{3 + Tlibtrace 'tlib', a:name, a:pick + echo + if bufnr('%') != a:bufnr + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: Not in scratch buffer:" bufname('%') + echohl NONE + endif + let br = tlib#buffer#Set(a:bufnr) + endif + if !exists('b:tlib_'. a:name) + if g:tlib#debug + echohl WarningMsg + echom "tlib#input#Resume: Internal error: b:tlib_". a:name ." does not exist:" bufname('%') + echohl NONE + redir => varss + silent let b: + redir END + let vars = split(varss, '\n') + call filter(vars, 'v:val =~ "^b:tlib_"') + echom "DEBUG tlib#input#Resume" string(vars) + endif + else + call tlib#autocmdgroup#Init() + autocmd! TLib BufEnter + if b:tlib_{a:name}.state !~# 'display\>' + let b:tlib_{a:name}.state = 'redisplay' + endif + " call tlib#input#List('resume '. a:name) + let cmd = 'resume '. a:name + if a:pick >= 1 + let cmd .= ' pick' + if a:pick >= 2 + let cmd .= ' sticky' + end + endif + call tlib#input#ListW(b:tlib_{a:name}, cmd) + endif +endf + + +" :def: function! tlib#input#CommandSelect(command, ?keyargs={}) +" Take a command, view the output, and let the user select an item from +" its output. +" +" EXAMPLE: > +" command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') +" command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +function! tlib#input#CommandSelect(command, ...) "{{{3 + TVarArg ['args', {}] + if has_key(args, 'retrieve') + let list = call(args.retrieve) + elseif has_key(args, 'list') + let list = args.list + else + let list = tlib#cmd#OutputAsList(a:command) + endif + if has_key(args, 'filter') + call map(list, args.filter) + endif + let type = has_key(args, 'type') ? args.type : 's' + let handlers = has_key(args, 'handlers') ? args.handlers : [] + let rv = tlib#input#List(type, 'Select', list, handlers) + if !empty(rv) + if has_key(args, 'process') + let rv = call(args.process, [rv]) + endif + endif + return rv +endf + + +" :def: function! tlib#input#Edit(name, value, callback, ?cb_args=[]) +" +" Edit a value (asynchronously) in a scratch buffer. Use name for +" identification. Call callback when done (or on cancel). +" In the scratch buffer: +" Press or to enter the new value, c to cancel +" editing. +" EXAMPLES: > +" fun! FooContinue(success, text) +" if a:success +" let b:var = a:text +" endif +" endf +" call tlib#input#Edit('foo', b:var, 'FooContinue') +function! tlib#input#EditW(world, name, value, callback, ...) "{{{3 + Tlibtrace 'tlib', a:value + TVarArg ['args', []] + let sargs = {'scratch': '__EDIT__'. a:name .'__', 'win_id': tlib#win#GetID()} + let scr = tlib#scratch#UseScratch(sargs) + let b:tlib_world = a:world + + " :nodoc: + map c :call tlib#input#EditCallback(0) + " :nodoc: + imap c call tlib#input#EditCallback(0) + " :nodoc: + map :call tlib#input#EditCallback(1) + " :nodoc: + imap call tlib#input#EditCallback(1) + " :nodoc: + map :call tlib#input#EditCallback(1) + " :nodoc: + imap call tlib#input#EditCallback(1) + + call tlib#normal#WithRegister('gg"tdG', 't') + call append(1, split(a:value, "\", 1)) + " let hrm = 'DON''T DELETE THIS HEADER' + " let hr3 = repeat('"', (tlib#win#Width(0) - len(hrm)) / 2) + let s:horizontal_line = repeat('`', tlib#win#Width(0)) + " hr3.hrm.hr3 + let hd = ['Keys: , ... save/accept; c ... cancel', s:horizontal_line] + call append(1, hd) + call tlib#normal#WithRegister('gg"tdd', 't') + syntax match TlibEditComment /^\%1l.*/ + syntax match TlibEditComment /^```.*/ + hi link TlibEditComment Comment + exec len(hd) + 1 + if type(a:callback) == 4 + let b:tlib_scratch_edit_callback = get(a:callback, 'submit', '') + call call(get(a:callback, 'init', ''), []) + else + let b:tlib_scratch_edit_callback = a:callback + endif + let b:tlib_scratch_edit_args = args + let b:tlib_scratch_edit_scratch = sargs + " exec 'autocmd BufDelete,BufHidden,BufUnload call tlib#input#EditCallback('. string(a:name) .')' + " echohl MoreMsg + " echom 'Press to enter, c to cancel editing.' + " echohl NONE + let world = getbufvar(scr, 'tlib_world', a:world) + let world.state .= ' norestore' + return world +endf + + +function! tlib#input#EditCallback(...) "{{{3 + TVarArg ['ok', -1] + " , ['bufnr', -1] + " autocmd! BufDelete,BufHidden,BufUnload + if ok == -1 + let ok = confirm('Use value') + endif + let start = getline(2) == s:horizontal_line ? 3 : 1 + let text = ok ? join(getline(start, '$'), "\n") : '' + let cb = b:tlib_scratch_edit_callback + let args = b:tlib_scratch_edit_args + let sargs = b:tlib_scratch_edit_scratch + let world = b:tlib_world + Tlibtrace 'tlib', cb, args, sargs + call call(cb, args + [ok, text, world]) + call tlib#scratch#CloseScratch(b:tlib_scratch_edit_scratch) + call tlib#win#SetById(sargs.win_id) +endf + + +function! tlib#input#Dialog(text, options, default) "{{{3 + if has('dialog_con') || has('dialog_gui') + let opts = join(map(a:options, '"&". v:val'), "\n") + let val = confirm(a:text, opts) + if val + let yn = a:options[val - 1] + else + let yn = a:default + endif + else + let oi = index(a:options, a:default) + if oi == -1 + let opts = printf("(%s|%s)", join(a:options, '/'), a:default) + else + let options = copy(a:options) + let options[oi] = toupper(options[oi]) + let opts = printf("(%s)", join(a:options, '/')) + endif + let yn = inputdialog(a:text .' '. opts) + endif + return yn +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/list.vim b/sources_non_forked/tlib/autoload/tlib/list.vim new file mode 100644 index 00000000..e3f681eb --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/list.vim @@ -0,0 +1,194 @@ +" list.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2017-03-26. +" @Revision: 71 + + +""" List related functions {{{1 +" For the following functions please see ../../test/tlib.vim for examples. + +" :def: function! tlib#list#Inject(list, initial_value, funcref) abort +" EXAMPLES: > +" echo tlib#list#Inject([1,2,3], 0, function('Add') +" => 6 +function! tlib#list#Inject(list, value, Function) abort "{{{3 + if empty(a:list) + return a:value + else + let item = a:list[0] + let rest = a:list[1:-1] + let value = call(a:Function, [a:value, item]) + return tlib#list#Inject(rest, value, a:Function) + endif +endf + + +" EXAMPLES: > +" tlib#list#Compact([0,1,2,3,[], {}, ""]) +" => [1,2,3] +function! tlib#list#Compact(list) abort "{{{3 + return filter(copy(a:list), '!empty(v:val)') +endf + + +" EXAMPLES: > +" tlib#list#Flatten([0,[1,2,[3,""]]]) +" => [0,1,2,3,""] +function! tlib#list#Flatten(list) abort "{{{3 + let acc = [] + for e in a:list + if type(e) == 3 + let acc += tlib#list#Flatten(e) + else + call add(acc, e) + endif + unlet e + endfor + return acc +endf + + +" :def: function! tlib#list#FindAll(list, filter, ?process_expr="") abort +" Basically the same as filter() +" +" EXAMPLES: > +" tlib#list#FindAll([1,2,3], 'v:val >= 2') +" => [2, 3] +function! tlib#list#FindAll(list, filter, ...) abort "{{{3 + let rv = filter(copy(a:list), a:filter) + if a:0 >= 1 && !empty(a:1) + let rv = map(rv, a:1) + endif + return rv +endf + + +" :def: function! tlib#list#Find(list, filter, ?default="", ?process_expr="") abort +" +" EXAMPLES: > +" tlib#list#Find([1,2,3], 'v:val >= 2') +" => 2 +function! tlib#list#Find(list, filter, ...) abort "{{{3 + let default = a:0 >= 1 ? a:1 : '' + let expr = a:0 >= 2 ? a:2 : '' + return get(tlib#list#FindAll(a:list, a:filter, expr), 0, default) +endf + + +" EXAMPLES: > +" tlib#list#Any([1,2,3], 'v:val >= 2') +" => 1 +function! tlib#list#Any(list, expr) abort "{{{3 + return !empty(tlib#list#FindAll(a:list, a:expr)) +endf + + +" EXAMPLES: > +" tlib#list#All([1,2,3], 'v:val >= 2') +" => 0 +function! tlib#list#All(list, expr) abort "{{{3 + return len(tlib#list#FindAll(a:list, a:expr)) == len(a:list) +endf + + +" EXAMPLES: > +" tlib#list#Remove([1,2,1,2], 2) +" => [1,1,2] +function! tlib#list#Remove(list, element) abort "{{{3 + let idx = index(a:list, a:element) + if idx != -1 + call remove(a:list, idx) + endif + return a:list +endf + + +" EXAMPLES: > +" tlib#list#RemoveAll([1,2,1,2], 2) +" => [1,1] +function! tlib#list#RemoveAll(list, element) abort "{{{3 + call filter(a:list, 'v:val != a:element') + return a:list +endf + + +" :def: function! tlib#list#Zip(lists, ?default='') abort +" EXAMPLES: > +" tlib#list#Zip([[1,2,3], [4,5,6]]) +" => [[1,4], [2,5], [3,6]] +function! tlib#list#Zip(lists, ...) abort "{{{3 + TVarArg 'default' + let lists = copy(a:lists) + let max = 0 + for l in lists + let ll = len(l) + if ll > max + let max = ll + endif + endfor + " TLogVAR default, max + return map(range(0, max - 1), 's:GetNthElement(v:val, lists, default)') +endf + +function! s:GetNthElement(n, lists, default) abort "{{{3 + " TLogVAR a:n, a:lists, a:default + return map(copy(a:lists), 'get(v:val, a:n, a:default)') +endf + + +function! tlib#list#Uniq(list, ...) abort "{{{3 + " TLogVAR a:list + TVarArg ['get_value', ''], ['remove_empty', 0] + if remove_empty + call filter(a:list, 'type(v:val) == 0 || !empty(v:val)') + endif + " CREDITS: Based on syntastic#util#unique(list) by scrooloose + let emptystring = 0 + let seen = {} + let uniques = [] + if empty(get_value) + for e in a:list + if empty(e) + if !emptystring + let emptystring = 1 + call add(uniques, e) + endif + elseif !has_key(seen, e) + let seen[e] = 1 + call add(uniques, e) + endif + unlet e + endfor + else + for e in a:list + let v = eval(printf(get_value, string(e))) + if empty(v) + if !emptystring + let emptystring = 1 + call add(uniques, v) + endif + elseif !has_key(seen, v) + let seen[v] = 1 + call add(uniques, v) + endif + unlet e v + endfor + endif + return uniques +endf + + +function! tlib#list#ToDictionary(list, default, ...) abort "{{{3 + TVarArg ['generator', ''] + let dict = {} + for item in a:list + if !empty(item) + let dict[item] = empty(generator) ? a:default : call(generator, [item, a:default]) + endif + endfor + return dict +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/loclist.vim b/sources_non_forked/tlib/autoload/tlib/loclist.vim new file mode 100644 index 00000000..198dd1be --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/loclist.vim @@ -0,0 +1,13 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-10-24 +" @Revision: 2 + + +function! tlib#loclist#Browse(...) abort "{{{3 + let list = getloclist(0) + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/map.vim b/sources_non_forked/tlib/autoload/tlib/map.vim new file mode 100644 index 00000000..c1af13f6 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/map.vim @@ -0,0 +1,23 @@ +" map.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-08-23. +" @Last Change: 2009-08-23. +" @Revision: 0.0.4 + +let s:save_cpo = &cpo +set cpo&vim + + +" If |pumvisible()| is true, return "\". Otherwise return a:key. +" For use in maps like: > +" imap tlib#map#PumAccept("\") +function! tlib#map#PumAccept(key) "{{{3 + return pumvisible() ? "\" : a:key +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/normal.vim b/sources_non_forked/tlib/autoload/tlib/normal.vim new file mode 100644 index 00000000..faaa4448 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/normal.vim @@ -0,0 +1,34 @@ +" normal.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-10-06. +" @Last Change: 2010-09-22. +" @Revision: 28 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') +" Execute a normal command while maintaining all registers. +function! tlib#normal#WithRegister(cmd, ...) "{{{3 + TVarArg ['register', 't'], ['norm_cmd', 'norm!'] + let registers = {} + for reg in split('123456789'. register, '\zs') + exec 'let registers[reg] = @'. reg + endfor + exec 'let reg = @'. register + try + exec norm_cmd .' '. a:cmd + exec 'return @'. register + finally + for [reg, value] in items(registers) + exec 'let @'. reg .' = value' + endfor + endtry +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/notify.vim b/sources_non_forked/tlib/autoload/tlib/notify.vim new file mode 100644 index 00000000..d12d1099 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/notify.vim @@ -0,0 +1,113 @@ +" notify.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2008-09-19. +" @Last Change: 2017-09-28. +" @Revision: 3.3.19 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: tlib#notify#Echo(text, ?style='') +" Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' +" in order to prevent |press-enter| messages. +function! tlib#notify#Echo(text, ...) + TVarArg 'style' + let ruler = &ruler + let showcmd = &showcmd + let text = substitute(a:text, '\n', '|', 'g') + try + set noruler + set noshowcmd + if !empty(style) + exec 'echohl' style + endif + echo tlib#string#Strcharpart(text, 0, &columns - 1) + finally + if !empty(style) + echohl None + endif + let &ruler = ruler + let &showcmd = showcmd + endtry +endf + + +" Contributed by Erik Falor: +" If the line containing the message is too long, echoing it will cause +" a 'Hit ENTER' prompt to appear. This function cleans up the line so +" that does not happen. +" The echoed line is too long if it is wider than the width of the +" window, minus cmdline space taken up by the ruler and showcmd +" features. +function! tlib#notify#TrimMessage(message) "{{{3 + let filler = '...' + + " If length of message with tabs converted into spaces + length of + " line number + 2 (for the ': ' that follows the line number) is + " greater than the width of the screen, truncate in the middle + let to_fill = &columns + " TLogVAR to_fill + + " Account for space used by elements in the command-line to avoid + " 'Hit ENTER' prompts. + " If showcmd is on, it will take up 12 columns. + " If the ruler is enabled, but not displayed in the statusline, it + " will in its default form take 17 columns. If the user defines a + " custom &rulerformat, they will need to specify how wide it is. + if has('cmdline_info') + if &showcmd + let to_fill -= 12 + else + let to_fill -= 1 + endif + " TLogVAR &showcmd, to_fill + + " TLogVAR &laststatus, &ruler, &rulerformat + if &ruler + if &laststatus == 0 || winnr('$') == 1 + if has('statusline') + if &rulerformat == '' + " default ruler is 17 chars wide + let to_fill -= 17 + elseif exists('g:MP_rulerwidth') + let to_fill -= g:MP_rulerwidth + else + " tml: fallback: guess length + let to_fill -= strlen(&rulerformat) + endif + else + endif + endif + else + endif + else + let to_fill -= 1 + endif + + " TLogVAR to_fill + " TLogDBG strlen(a:message) + if strlen(a:message) > to_fill + let front = to_fill / 2 - 1 + let back = front + if to_fill % 2 == 0 | let back -= 1 | endif + return tlib#string#Strcharpart(a:message, 0, front) . filler . + \ tlib#string#Strcharpart(a:message, strlen(a:message) - back) + else + return a:message + endif +endfunction + + +function! tlib#notify#PrintError() abort "{{{3 + echohl ErrorMsg + echom v:exception + echom v:throwpoint + echohl NONE +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/number.vim b/sources_non_forked/tlib/autoload/tlib/number.vim new file mode 100644 index 00000000..8326b47a --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/number.vim @@ -0,0 +1,36 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 26 + + +function! tlib#number#ConvertBase(num, base, ...) "{{{3 + let rtype = a:0 >= 1 ? a:1 : 'string' + " TLogVAR a:num, a:base, rtype + if a:base == 32 + let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" + elseif a:base == 63 || a:base == 64 + let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + elseif a:base == 85 + let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~" + elseif a:base <= 62 + let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + else + throw 'tlib#number#ConvertBase: base is not supported' + endif + let rv = [] + let num = 0.0 + a:num + while floor(num) > 0.0 + let div = floor(num / a:base) + let num1 = float2nr(num - a:base * div) + call insert(rv, chars[num1]) + let num = num / a:base + endwh + " TLogVAR rv + if rtype == 'list' + return rv + else + return join(rv, '') + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/paragraph.vim b/sources_non_forked/tlib/autoload/tlib/paragraph.vim new file mode 100644 index 00000000..dd0d1123 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/paragraph.vim @@ -0,0 +1,97 @@ +" paragraph.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-10-26. +" @Last Change: 2011-04-03. +" @Revision: 62 + +let s:save_cpo = &cpo +set cpo&vim + + +" Return an object describing a |paragraph|. +function! tlib#paragraph#GetMetric() "{{{3 + let sp = {'text_start': line("'{") + 1} + if line("'}") == line("$") + let sp.last = 1 + let sp.text_end = line("'}") + if line("'{") == 1 + let sp.ws_start = 0 + let sp.ws_end = 0 + let sp.top = sp.text_start + let sp.bottom = sp.text_end + else + let sp.ws_start = prevnonblank(line("'{")) + 1 + let sp.ws_end = line("'{") + let sp.top = sp.ws_start + let sp.bottom = sp.text_end + endif + else + let sp.last = 0 + let sp.text_end = line("'}") - 1 + let sp.ws_start = line("'}") + for i in range(line("'}"), line('$')) + if getline(i) =~ '\w' + let sp.ws_end = i - 1 + break + elseif i == line("$") + let sp.ws_end = i + endif + endfor + let sp.top = sp.text_start + let sp.bottom = sp.ws_end + endif + return sp +endf + + +" This function can be used with the tinymode plugin to move around +" paragraphs. +" +" Example configuration: > +" +" call tinymode#EnterMap("para_move", "gp") +" call tinymode#ModeMsg("para_move", "Move paragraph: j/k") +" call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") +" call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") +" call tinymode#ModeArg("para_move", "owncount", 1) +function! tlib#paragraph#Move(direction, count) + " TLogVAR a:direction, a:count + let mycount = empty(a:count) ? 1 : a:count + for i in range(1, mycount) + let para = tlib#paragraph#GetMetric() + " TLogVAR para + let text = getline(para.text_start, para.text_end) + let ws = getline(para.ws_start, para.ws_end) + " TLogVAR text, ws + exec para.top .','. para.bottom .'delete' + if a:direction == "Down" + let other = tlib#paragraph#GetMetric() + let target = other.bottom + 1 + if other.last + let lines = ws + text + let pos = target + len(ws) + else + let lines = text + ws + let pos = target + endif + elseif a:direction == "Up" + if !para.last + norm! { + endif + let other = tlib#paragraph#GetMetric() + let target = other.text_start + let lines = text + ws + let pos = target + endif + " TLogVAR other, target + " TLogVAR lines + call append(target - 1, lines) + exec pos + endfor +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/persistent.vim b/sources_non_forked/tlib/autoload/tlib/persistent.vim new file mode 100644 index 00000000..8e633a6c --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/persistent.vim @@ -0,0 +1,54 @@ +" persistent.vim -- Persistent data +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-05-11. +" @Last Change: 2017-03-29. +" @Revision: 15 + +" The directory for persistent data files. If empty, use +" |tlib#dir#MyRuntime|.'/share'. +TLet g:tlib_persistent = '' + + +" :display: tlib#persistent#Dir(?mode = 'bg') +" Return the full directory name for persistent data files. +function! tlib#persistent#Dir() "{{{3 + TVarArg ['mode', 'bg'] + let dir = tlib#var#Get('tlib_persistent', mode) + if empty(dir) + let dir = tlib#file#Join([tlib#dir#MyRuntime(), 'share']) + endif + return dir +endf + +" :display: tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') +" Encode `file` and call |tlib#persistent#Filename()|. +function! tlib#persistent#EncodedFilename(type, file, ...) "{{{3 + let file = tlib#url#Encode(a:file) + return call(function('tlib#persistent#Filename'), [a:type, file] + a:000) +endf + +" :def: function! tlib#persistent#Filename(type, ?file=%, ?mkdir=0) +function! tlib#persistent#Filename(type, ...) "{{{3 + " TLogDBG 'bufname='. bufname('.') + let file = a:0 >= 1 ? a:1 : '' + let mkdir = a:0 >= 2 ? a:2 : 0 + return tlib#cache#Filename(a:type, file, mkdir, tlib#persistent#Dir()) +endf + +function! tlib#persistent#Get(...) "{{{3 + return call('tlib#cache#Get', a:000) +endf + +function! tlib#persistent#MTime(cfile) "{{{3 + return tlib#cache#MTime(a:cfile) +endf + +function! tlib#persistent#Value(...) "{{{3 + return call('tlib#cache#Value', a:000) +endf + +function! tlib#persistent#Save(...) "{{{3 + call call(function('tlib#cache#Save'), a:000) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/progressbar.vim b/sources_non_forked/tlib/autoload/tlib/progressbar.vim new file mode 100644 index 00000000..c7e1f866 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/progressbar.vim @@ -0,0 +1,95 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 86 + +let s:id = 0 +let s:ids = [] +let s:statusline = [] +let s:laststatus = [] +let s:max = [] +let s:format = [] +let s:width = [] +let s:value = [] +let s:timestamp = -1 + +" EXAMPLE: > +" call tlib#progressbar#Init(20) +" try +" for i in range(20) +" call tlib#progressbar#Display(i) +" call DoSomethingThatTakesSomeTime(i) +" endfor +" finally +" call tlib#progressbar#Restore() +" endtry +function! tlib#progressbar#Init(max, ...) "{{{3 + TVarArg ['format', '%s'], ['width', 10] + let s:id += 1 + call insert(s:ids, s:id) + call insert(s:statusline, &statusline) + call insert(s:laststatus, &laststatus) + call insert(s:max, a:max) + call insert(s:format, format) + call insert(s:width, width) + call insert(s:value, -1) + let sl = { + \ 'id': s:id, + \ 'statusline': &statusline, + \ 'laststatus': &laststatus, + \ 'max': a:max, + \ 'format': format, + \ 'width': width, + \ 'value': -1 + \ } + let &laststatus = 2 + let s:timestamp = localtime() + return sl +endf + + +function! tlib#progressbar#Restore(...) "{{{3 + if a:0 >= 1 + let sl = a:1 + let idx = index(s:ids, sl.id) + let &statusline = sl.statusline + let &laststatus = sl.laststatus + else + let idx = 0 + let &statusline = remove(s:statusline, idx) + let &laststatus = remove(s:laststatus, idx) + endif + call remove(s:ids, idx) + call remove(s:max, idx) + call remove(s:format, idx) + call remove(s:width, idx) + call remove(s:value, idx) + redrawstatus + " redraw + " echo +endf + + +function! tlib#progressbar#Display(value, ...) "{{{3 + TVarArg 'extra', ['always', 0] + let ts = localtime() + if !always && ts == s:timestamp + return + else + let s:timestamp = ts + endif + let val = a:value * s:width[0] / s:max[0] + if always || val != s:value[0] + let s:value[0] = val + let pbl = repeat('#', val) + let pbr = repeat('.', s:width[0] - val) + let txt = printf(s:format[0], '['.pbl.pbr.']') . extra + let &statusline = txt + " TLogDBG txt + redrawstatus + " redraw + " call tlib#notify#Echo(txt) + endif +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/qfl.vim b/sources_non_forked/tlib/autoload/tlib/qfl.vim new file mode 100644 index 00000000..07eb9416 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/qfl.vim @@ -0,0 +1,317 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2018-02-08 +" @Revision: 69 + +" :nodoc: +TLet g:tlib#qfl#world = { + \ 'type': 'mi', + \ 'query': 'Select entry', + \ 'pick_last_item': 0, + \ 'resize_vertical': 0, + \ 'resize': 20, + \ 'scratch': '__TLibQFL__', + \ 'tlib_UseInputListScratch': 'call tlib#qfl#InitListBuffer(world)', + \ 'key_handlers': [ + \ {'key': 5, 'agent': 'tlib#qfl#AgentWithSelected', 'key_name': '', 'help': 'Run a command on selected lines'}, + \ {'key': 16, 'agent': 'tlib#qfl#AgentPreviewQFE', 'key_name': '', 'help': 'Preview'}, + \ {'key': 60, 'agent': 'tlib#qfl#AgentGotoQFE', 'key_name': '<', 'help': 'Jump (don''t close the list)'}, + \ {'key': 19, 'agent': 'tlib#qfl#AgentSplitBuffer', 'key_name': '', 'help': 'Show in split buffer'}, + \ {'key': 20, 'agent': 'tlib#qfl#AgentTabBuffer', 'key_name': '', 'help': 'Show in tab'}, + \ {'key': 22, 'agent': 'tlib#qfl#AgentVSplitBuffer', 'key_name': '', 'help': 'Show in vsplit buffer'}, + \ {'key': 12, 'agent': 'tlib#qfl#AgentEditLine', 'key_name': '', 'help': 'Edit selected line(s)'}, + \ {'key': "\", 'agent': 'tlib#qfl#SetFollowCursor', 'key_name': '', 'help': 'Toggle trace cursor'}, + \ ], + \ 'return_agent': 'tlib#qfl#AgentEditQFE', + \ } + + +function! tlib#qfl#FormatQFLE(qfe) dict abort "{{{3 + let filename = tlib#qfl#QfeFilename(a:qfe) + let short_filename = get(self, 'qfl_short_filename', '') + if short_filename ==# 'basename' + let filename = matchstr(filename, '[^\\/]\+$') + elseif !empty(short_filename) + let filename = pathshorten(filename) + endif + return printf("%s|%d| %s", filename, a:qfe.lnum, get(a:qfe, "text")) +endf + + +function! tlib#qfl#QfeFilename(qfe) abort "{{{3 + let filename = get(a:qfe, 'filename') + if empty(filename) + let filename = bufname(get(a:qfe, 'bufnr')) + endif + return filename +endf + + +function! tlib#qfl#InitListBuffer(world) "{{{3 + let set_syntax = get(a:world, 'set_syntax', 'tlib#qfl#SetSyntax') + call call(set_syntax, [], a:world) + if has('balloon_eval') + setlocal ballooneval balloonexpr=tlib#qfl#Balloon() + endif +endf + + +function! tlib#qfl#SetSyntax() dict abort "{{{3 + let syntax = get(self, 'qfl_list_syntax', '') + let nextgroup = get(self, 'qfl_list_syntax_nextgroup', '') + " TLogVAR syntax, nextgroup + if !empty(syntax) + exec printf('runtime syntax/%s.vim', syntax) + endif + syn match TTagedFilesFilename /\%(\f\+\| \)\+\ze|\d\+| / nextgroup=TTagedFilesLNum + if !empty(nextgroup) + exec 'syn match TTagedFilesLNum /|\d\+|\s\+/ nextgroup='. nextgroup + else + syn match TTagedFilesLNum /|\d\+|/ + endif + hi def link TTagedFilesFilename Directory + hi def link TTagedFilesLNum LineNr +endf + + +function! tlib#qfl#Balloon() "{{{3 + let world = getbufvar(v:beval_bufnr, 'tlibDisplayListWorld') + let current = max([1, world.offset]) + v:beval_lnum - 1 + if current > len(world.table) + let current = len(world.table) + endif + let baseidx = world.GetBaseIdx0(current) + " TLogVAR world.offset, v:beval_lnum, current, baseidx + let item = world.data[baseidx] + let bufnr = get(item, 'bufnr', 0) + let bufname = get(item, 'filename', '') + if bufnr == 0 && !empty(bufname) + let bufnr = bufnr(bufname) + endif + if empty(bufname) && bufnr > 0 + let bufname = bufname(bufnr) + endif + " TLogVAR item + if bufnr == 0 + return '' + else + let lines = [printf("%d#%d: %s", bufnr, item.lnum, bufname)] + if has('balloon_multiline') + let desc = {'nr': 'Error number', 'type': 'Error type', 'text': ''} + for key in ['nr', 'type', 'text'] + if has_key(item, key) && !empty(item[key]) + let keydesc = get(desc, key, key) + if empty(keydesc) + let text = item[key] + else + let text = printf("%s: %s", key, item[key]) + endif + call add(lines, text) + endif + endfor + endif + return join(lines, "\n") + endif + " v:beval_bufnr number of the buffer in which balloon is going to show + " v:beval_winnr number of the window + " v:beval_lnum line number + " v:beval_col column number (byte index) + " v:beval_text word under or after the mouse pointer +endf + + +function! tlib#qfl#AgentEditQFE(world, selected, ...) "{{{3 + TVarArg ['cmd_edit', ''], ['cmd_buffer', ''], ['set_origin', 1] + " TVarArg ['cmd_edit', 'edit'], ['cmd_buffer', 'buffer'] + " TLogVAR a:selected + if empty(a:selected) + " call a:world.RestoreOrigin() + " call a:world.ResetSelected() + else + call a:world.RestoreOrigin() + for idx in a:selected + let idx -= 1 + " TLogVAR idx + if idx >= 0 + " TLogVAR a:world.data + " call tlog#Debug(string(map(copy(a:world.data), 'v:val.bufnr'))) + " TLogVAR idx, a:world.data[idx] + let qfe = a:world.data[idx] + " let back = a:world.SwitchWindow('win') + " TLogVAR cmd_edit, cmd_buffer, qfe + let fn = tlib#qfl#QfeFilename(qfe) + " TLogVAR cmd_edit, cmd_buffer, fn + if empty(cmd_edit) && empty(cmd_buffer) + if tlib#file#Edit(fn) + call tlib#buffer#ViewLine(qfe.lnum) + endif + else + call tlib#file#With(cmd_edit, cmd_buffer, [fn], a:world) + " TLogDBG bufname('%') + " TLogVAR &filetype + call tlib#buffer#ViewLine(qfe.lnum) + " exec back + endif + endif + endfor + if set_origin + call a:world.SetOrigin() + endif + endif + return a:world +endf + + +function! tlib#qfl#AgentPreviewQFE(world, selected) "{{{3 + " TLogVAR a:selected + let back = a:world.SwitchWindow('win') + call tlib#qfl#AgentEditQFE(a:world, a:selected[0:0], '', '', 0) + exec back + redraw + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#AgentGotoQFE(world, selected) "{{{3 + let world = a:world + if !empty(a:selected) + let world = tlib#agent#Suspend(world, a:selected) + call tlib#qfl#AgentEditQFE(world, a:selected[0:0]) + endif + return world +endf + + +function! tlib#qfl#AgentWithSelected(world, selected, ...) "{{{3 + let cmd = a:0 >= 1 ? a:1 : input('Ex command: ', '', 'command') + let world = a:world + if !empty(cmd) + let world = tlib#qfl#RunCmdOnSelected(world, a:selected, cmd) + else + let world.state = 'redisplay' + endif + return world +endf + + +function! tlib#qfl#RunCmdOnSelected(world, selected, cmd, ...) "{{{3 + let close_scratch = a:0 >= 1 ? a:1 : 1 + if close_scratch + call a:world.CloseScratch() + endif + " TLogVAR a:cmd + for entry in a:selected + " TLogVAR entry, a:world.GetBaseItem(entry) + call tlib#qfl#AgentEditQFE(a:world, [entry], '', '', 0) + " TLogDBG bufname('%') + exec a:cmd + " let item = a:world.data[a:world.GetBaseIdx(entry - 1)] + " <+TODO+> + let item = a:world.data[entry - 1] + " TLogVAR entry, item, getline('.') + if has_key(a:world, 'GetBufferLines') + let lines = a:world.GetBufferLines('.', '.') + else + let lines = getline('.', '.') + endif + let item['text'] = tlib#string#Strip(lines[0]) + endfor + if has_key(a:world, 'AfterRunCmd') + if bufnr('%') == a:world.bufnr + call a:world.AfterRunCmd() + else + " <+TODO+> Run in other buffer + endif + endif + " call s:FormatBase(a:world) + call a:world.RestoreOrigin() + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#AgentSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'split', 'sbuffer') +endf + + +function! tlib#qfl#AgentTabBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'tabedit', 'tab sbuffer') +endf + + +function! tlib#qfl#AgentVSplitBuffer(world, selected) "{{{3 + call a:world.CloseScratch() + return tlib#qfl#AgentEditQFE(a:world, a:selected, 'vertical split', 'vertical sbuffer') +endf + + +" function! tlib#qfl#AgentOpenBuffer(world, selected) "{{{3 +" endf + + +function! tlib#qfl#AgentEditLine(world, selected) "{{{3 + call a:world.CloseScratch() + let cmd = 'call tlib#qfl#EditLine(".")' + return tlib#qfl#RunCmdOnSelected(a:world, a:selected, cmd) + let a:world.state = 'reset' + return a:world +endf + + +function! tlib#qfl#EditLine(lnum) "{{{3 + call inputsave() + let line = input('', getline(a:lnum)) + call inputrestore() + if !empty(line) + call setline(line(a:lnum), line) + endif +endf + + +function! tlib#qfl#SetFollowCursor(world, selected) "{{{3 + if empty(a:world.follow_cursor) + let a:world.follow_cursor = 'tlib#qfl#AgentPreviewQFE' + else + let a:world.follow_cursor = '' + endif + let a:world.state = 'redisplay' + return a:world +endf + + +function! tlib#qfl#QflList(list, ...) abort "{{{3 + TVarArg ['world_dict', {}], ['anyway', 0], ['suspended', 0] + Tlibtrace 'tlib', world_dict, anyway, suspended + " TLogVAR a:list, world_dict, anyway, suspended + if !anyway && empty(a:list) + return + endif + let world = copy(g:tlib#qfl#world) + if !empty(world_dict) + let world = tlib#eval#Extend(world, world_dict) + endif + " TLogVAR world + let world = tlib#World#New(world) + " echom "DBG world" string(sort(keys(world))) + let world.data = copy(a:list) + if !has_key(world, 'format_data') + let world.format_data = 'tlib#qfl#FormatQFLE' + endif + " TLogVAR world + " TLogVAR world.data + " call s:FormatBase(world) + " TLogVAR world.base + return tlib#input#ListW(world, suspended ? 'hibernate' : '') +endf + + +function! tlib#qfl#Browse(...) abort "{{{3 + let list = getqflist() + return call(function('tlib#qfl#QflList'), [list] + a:000) +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/rx.vim b/sources_non_forked/tlib/autoload/tlib/rx.vim new file mode 100644 index 00000000..08e6ae42 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/rx.vim @@ -0,0 +1,54 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 114 + + +" :def: function! tlib#rx#Escape(text, ?magic='m') +" magic can be one of: m, M, v, V +" See :help 'magic' +function! tlib#rx#Escape(text, ...) "{{{3 + TVarArg 'magic' + if empty(magic) + let magic = 'm' + endif + if magic =~# '^\\\?m$' + return escape(a:text, '^$.*\[]~') + elseif magic =~# '^\\\?M$' + return escape(a:text, '^$\') + elseif magic =~# '^\\\?V$' + return escape(a:text, '\') + elseif magic =~# '^\\\?v$' + return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g') + else + echoerr 'tlib: Unsupported magic type' + return a:text + endif +endf + +" :def: function! tlib#rx#EscapeReplace(text, ?magic='m') +" Escape return |sub-replace-special|. +function! tlib#rx#EscapeReplace(text, ...) "{{{3 + TVarArg ['magic', 'm'] + return escape(a:text, '\&~') +endf + + +function! tlib#rx#Suffixes(...) "{{{3 + TVarArg ['magic', 'm'] + let sfx = split(&suffixes, ',') + call map(sfx, 'tlib#rx#Escape(v:val, magic)') + if magic ==# 'v' + return '('. join(sfx, '|') .')$' + elseif magic ==# 'V' + return '\('. join(sfx, '\|') .'\)\$' + else + return '\('. join(sfx, '\|') .'\)$' + endif +endf + + +function! tlib#rx#LooksLikeRegexp(text) abort "{{{3 + return a:text =~ '[.?*+{}\[\]]' +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/scratch.vim b/sources_non_forked/tlib/autoload/tlib/scratch.vim new file mode 100644 index 00000000..c9df64d3 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/scratch.vim @@ -0,0 +1,136 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 255 + + +" Scratch window position. By default the list window is opened on the +" bottom. Set this variable to 'topleft' or '' to change this behaviour. +" See |tlib#input#List()|. +TLet g:tlib_scratch_pos = 'botright' + +" If you want the scratch buffer to be fully removed, you might want to +" set this variable to 'wipe'. +" See also https://github.com/tomtom/tlib_vim/pull/16 +TLet g:tlib#scratch#hidden = 'hide' + + +" :def: function! tlib#scratch#UseScratch(?keyargs={}) +" Display a scratch buffer (a buffer with no file). See :TScratch for an +" example. +" Return the scratch buffer's number. +" Values for keyargs: +" scratch_split ... 1: split, 0: window, -1: tab +function! tlib#scratch#UseScratch(...) "{{{3 + exec tlib#arg#Let([['keyargs', {}]]) + " TLogDBG string(keys(keyargs)) + let id = get(keyargs, 'scratch', '__Scratch__') + " TLogVAR id, bufwinnr(id) + " TLogVAR bufnr(id), bufname(id) + " TLogVAR 1, winnr(), bufnr('%'), bufname("%") + if bufwinnr(id) != -1 + " echom 'DBG noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + exec 'noautocmd keepalt keepj' bufwinnr(id) 'wincmd w' + " TLogVAR "reuse", bufnr("%"), bufname("%") + else + let winpos = '' + let bn = bufnr(id) + let wpos = get(keyargs, 'scratch_pos', g:tlib_scratch_pos) + " TLogVAR keyargs.scratch_vertical + if get(keyargs, 'scratch_vertical') + let wpos .= ' vertical' + let winpos = tlib#fixes#Winpos() + endif + " TLogVAR wpos + let scratch_split = get(keyargs, 'scratch_split', 1) + if bn != -1 + " TLogVAR bn + let wn = bufwinnr(bn) + if wn != -1 + " TLogVAR wn + exec 'noautocmd keepalt keepj' (wn .'wincmd w') + else + if scratch_split == 1 + let cmd = wpos.' sbuffer!' + elseif scratch_split == -1 + let cmd = wpos.' tab sbuffer!' + else + let cmd = 'buffer!' + endif + " TLogVAR cmd, bn + silent exec 'noautocmd keepalt keepj' cmd bn + endif + else + " TLogVAR id + if scratch_split == 1 + let cmd = wpos.' split' + elseif scratch_split == -1 + let cmd = wpos.' tab split' + else + let cmd = 'edit' + endif + " TLogVAR cmd, id + silent exec 'noautocmd keepalt keepj' cmd escape(id, '%#\ ') + " silent exec 'split '. id + endif + let ft = get(keyargs, 'scratch_filetype', '') + " TLogVAR ft, winpos + if !empty(winpos) + exec winpos + endif + setlocal buftype=nofile + let &l:bufhidden = get(keyargs, 'scratch_hidden', g:tlib#scratch#hidden) + setlocal noswapfile + setlocal nobuflisted + setlocal foldmethod=manual + setlocal foldcolumn=0 + setlocal nospell + setlocal modifiable + setlocal noreadonly + " TLogVAR &ft, ft + if !empty(ft) + let &l:ft = ft + endif + endif + let keyargs.scratch = bufnr('%') + let keyargs.scratch_tabpagenr = tabpagenr() + let keyargs.scratch_winnr = winnr() + " TLogVAR 2, winnr(), bufnr('%'), bufname("%"), keyargs.scratch + return keyargs.scratch +endf + + +" Close a scratch buffer as defined in keyargs (usually a World). +" Return 1 if the scratch buffer is closed (or if it already was +" closed). +function! tlib#scratch#CloseScratch(keyargs, ...) "{{{3 + TVarArg ['reset_scratch', 1] + let scratch = get(a:keyargs, 'scratch', '') + " TLogVAR scratch, reset_scratch + " TLogDBG string(tlib#win#List()) + if !empty(scratch) && winnr('$') > 1 + let wn = bufwinnr(scratch) + " TLogVAR wn + try + if wn != -1 + " TLogDBG winnr() + let wb = tlib#win#Set(wn) + let winpos = tlib#fixes#Winpos() + wincmd c + if get(a:keyargs, 'scratch_vertical') && !empty(winpos) + exec winpos + endif + " exec wb + " redraw + " TLogVAR winnr() + endif + return 1 + finally + if reset_scratch + let a:keyargs.scratch = '' + endif + endtry + endif + return 0 +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/selection.vim b/sources_non_forked/tlib/autoload/tlib/selection.vim new file mode 100644 index 00000000..e705f27e --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/selection.vim @@ -0,0 +1,40 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-09-28 +" @Revision: 4 + + +" :display: tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') +" mode can be one of: selection, lines, block +function! tlib#selection#GetSelection(mode, ...) range "{{{3 + if a:0 >= 2 + let mbeg = a:1 + let mend = a:2 + else + let mbeg = "'<" + let mend = "'>" + endif + let opmode = a:0 >= 3 ? a:3 : 'selection' + let l0 = line(mbeg) + let l1 = line(mend) + let text = getline(l0, l1) + let c0 = col(mbeg) + let c1 = col(mend) + " TLogVAR mbeg, mend, opmode, l0, l1, c0, c1 + " TLogVAR text[-1] + " TLogVAR len(text[-1]) + if opmode == 'block' + let clen = c1 - c0 + call map(text, 'tlib#string#Strcharpart(v:val, c0, clen)') + elseif opmode == 'selection' + if c1 > 1 + let text[-1] = tlib#string#Strcharpart(text[-1], 0, c1 - (a:mode == 'o' || c1 > len(text[-1]) ? 0 : 1)) + endif + if c0 > 1 + let text[0] = tlib#string#Strcharpart(text[0], c0 - 1) + endif + endif + return text +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/signs.vim b/sources_non_forked/tlib/autoload/tlib/signs.vim new file mode 100644 index 00000000..16646807 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/signs.vim @@ -0,0 +1,103 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-03-12. +" @Last Change: 2011-03-10. +" @Revision: 0.0.45 + +let s:save_cpo = &cpo +set cpo&vim + + +let s:base = 2327 +let s:register = {} + + +" Clear all signs with name SIGN. +function! tlib#signs#ClearAll(sign) "{{{3 + " TLog a:sign + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" Clear all signs with name SIGN in buffer BUFNR. +function! tlib#signs#ClearBuffer(sign, bufnr) "{{{3 + for bn in keys(s:register) + let idxs = keys(s:register) + call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == a:bufnr') + " TLogVAR bns + for idx in idxs + exec 'sign unplace '. idx .' buffer='. s:register[idx].bn + call remove(s:register, idx) + endfor + endfor +endf + + +" function! tlib#signs#Clear(sign, list) "{{{3 +" " TLogVAR a:sign +" let done = [] +" for item in a:list +" let bn = get(item, 'bufnr', -1) +" if index(done, bn) == -1 +" let idxs = keys(s:register) +" call filter(idxs, 's:register[v:val].sign == a:sign && s:register[v:val].bn == bn') +" for idx in idxs +" exec 'sign unplace '. idx .' buffer='. s:register[idx].bn +" call remove(s:register, idx) +" endfor +" call add(done, bn) +" endif +" endfor +" endf + + +" Add signs for all locations in LIST. LIST must adhere with the +" quickfix list format (see |getqflist()|; only the fields lnum and +" bufnr are required). +" +" list:: a quickfix or location list +" sign:: a sign defined with |:sign-define| +function! tlib#signs#Mark(sign, list) "{{{3 + " TLogVAR a:sign + for item in a:list + let idx = s:SignId(item) + if idx >= 0 + let lnum = get(item, 'lnum', 0) + if lnum > 0 + let bn = get(item, 'bufnr') + exec ':sign place '. idx .' line='. lnum .' name='. a:sign .' buffer='. bn + let s:register[idx] = {'sign': a:sign, 'bn': bn} + endif + endif + endfor +endf + + +function! s:SignId(item) "{{{3 + " TLogVAR a:item + " let bn = bufnr('%') + let bn = get(a:item, 'bufnr', -1) + if bn == -1 + return -1 + else + let idx = s:base + bn * 500 + while has_key(s:register, idx) + let idx += 1 + endwh + return idx + endif +endf + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/string.vim b/sources_non_forked/tlib/autoload/tlib/string.vim new file mode 100644 index 00000000..c15420ef --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/string.vim @@ -0,0 +1,208 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 148 + + +" :def: function! tlib#string#RemoveBackslashes(text, ?chars=' ') +" Remove backslashes from text (but only in front of the characters in +" chars). +function! tlib#string#RemoveBackslashes(text, ...) "{{{3 + exec tlib#arg#Get(1, 'chars', ' ') + " TLogVAR chars + let rv = substitute(a:text, '\\\(['. chars .']\)', '\1', 'g') + return rv +endf + + +" :display: tlib#string#Chomp(string, ?max=0) +function! tlib#string#Chomp(string, ...) "{{{3 + let quant = a:0 >= 1 ? '\{,'. a:1 .'}' : '\+' + return substitute(a:string, '[[:cntrl:][:space:]]'. quant .'$', '', '') +endf + + +" Format a template string. Placeholders have the format "%{NAME}". A +" "%" can be inserted as "%%". +" +" Examples: +" echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') +" => foo 123 foo +function! tlib#string#Format(template, dict, ...) "{{{3 + let prefix = a:0 >= 1 ? a:1 : '%' + let pesc = prefix . prefix + let prx = tlib#rx#Escape(prefix) + let parts = split(a:template, '\ze'. prx .'\({.\{-}}\|.\)') + let partrx = '^'. prx .'\({\(.\{-}\)}\|\(.\)\)\(.*\)$' + let out = [] + for part in parts + let ml = matchlist(part, partrx) + if empty(ml) + let rest = part + else + let var = empty(ml[2]) ? ml[3] : ml[2] + let rest = ml[4] + if has_key(a:dict, var) + call add(out, a:dict[var]) + elseif var ==# pesc + call add(out, prefix) + else + call add(out, ml[1]) + endif + endif + call add(out, rest) + endfor + return join(out, '') +endf + + +" This function deviates from |printf()| in certain ways. +" Additional items: +" %{rx} ... insert escaped regexp +" %{fuzzyrx} ... insert typo-tolerant regexp +function! tlib#string#Printf1(format, string) "{{{3 + let s = split(a:format, '%.\zs') + " TLogVAR s + return join(map(s, 's:PrintFormat(v:val, a:string)'), '') +endf + +function! s:PrintFormat(format, string) "{{{3 + let cut = match(a:format, '%\({.\{-}}\|.\)$') + if cut == -1 + return a:format + else + let head = cut > 0 ? a:format[0 : cut - 1] : '' + let tail = a:format[cut : -1] + " TLogVAR head, tail + if tail == '%{fuzzyrx}' + let frx = [] + for i in range(len(a:string)) + if i > 0 + let pb = i - 1 + else + let pb = 0 + endif + let slice = tlib#rx#Escape(a:string[pb : i + 1]) + call add(frx, '['. slice .']') + call add(frx, '.\?') + endfor + let tail = join(frx, '') + elseif tail == '%{rx}' + let tail = tlib#rx#Escape(a:string) + elseif tail == '%%' + let tail = '%' + elseif tail == '%s' + let tail = a:string + endif + " TLogVAR tail + return head . tail + endif +endf +" function! tlib#string#Printf1(format, string) "{{{3 +" let n = len(split(a:format, '%\@ 0 +" let pb = i - 1 +" else +" let pb = 0 +" endif +" let slice = tlib#rx#Escape(a:string[pb : i + 1]) +" call add(frx, '['. slice .']') +" call add(frx, '.\?') +" endfor +" let f = s:RewriteFormatString(f, '%{fuzzyrx}', join(frx, '')) +" endif +" if f =~ '%\@= 1 ? a:1 : ',\s*' + let parts = split(a:text, '\\\@= 1 ? a:1 : '' + Tlibtrace 'tlib', a:string, a:regexp, eregexp + let ms = [] + if a:regexp =~ '\\ze' + let regexp1 = substitute(a:regexp, '\\ze.*$', '', '') + else + let regexp1 = a:regexp + endif + for m in split(a:string, '\ze'. regexp1) + let m1 = matchstr(m, !empty(eregexp) ? eregexp : a:regexp) + Tlibtrace 'tlib', m, m1 + if !empty(m1) + call add(ms, m1) + endif + endfor + return ms +endf + +if exists('*strcharpart') + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strcharpart'), a:000) + endf +else + function! tlib#string#Strcharpart(...) abort "{{{3 + return call(function('strpart'), a:000) + endf +endif + diff --git a/sources_non_forked/tlib/autoload/tlib/syntax.vim b/sources_non_forked/tlib/autoload/tlib/syntax.vim new file mode 100644 index 00000000..aa30b667 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/syntax.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 13 + + +function! tlib#syntax#Collect() "{{{3 + let acc = {} + let syn = '' + for line in tlib#cmd#OutputAsList('syntax') + if line =~ '^---' + continue + elseif line =~ '^\w' + let ml = matchlist(line, '^\(\w\+\)\s\+\(xxx\s\+\(.*\)\|\(cluster.*\)\)$') + if empty(ml) + " echoerr 'Internal error: '. string(line) + else + let [m_0, syn, m_1, m_def1, m_def2; m_rest] = ml + let acc[syn] = [empty(m_def1) ? m_def2 : m_def1] + endif + else + call add(acc[syn], matchstr(line, '^\s\+\zs.*$')) + endif + endfor + return acc +endf + + +" :def: function! tlib#syntax#Names(?rx='') +function! tlib#syntax#Names(...) "{{{3 + TVarArg 'rx' + let names = keys(tlib#syntax#Collect()) + if !empty(rx) + call filter(names, 'v:val =~ rx') + endif + return names +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/sys.vim b/sources_non_forked/tlib/autoload/tlib/sys.vim new file mode 100644 index 00000000..667ecdc2 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/sys.vim @@ -0,0 +1,218 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-04-12. +" @Revision: 62 + + +if !exists('g:tlib#sys#special_protocols') + " A list of |regexp|s matching protocol names that should be handled + " by |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#special_protocols = ['https\?', 'nntp', 'mailto'] "{{{2 +endif + + +if !exists('g:tlib#sys#special_suffixes') + " A list of |regexp|s matching suffixes that should be handled by + " |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#special_suffixes = ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]'] "{{{2 +endif + + +if !exists('g:tlib#sys#system_rx') + " Open links matching this |regexp| with |g:tlib#sys#system_browser|. + " CAVEAT: Must be a |\V| |regexp|. + let g:tlib#sys#system_rx = printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|')) "{{{2 +endif + + +if !exists("g:tlib#sys#system_browser") + if exists('g:netrw_browsex_viewer') + " Open files in the system browser. + " :read: let g:tlib#sys#system_browser = ... "{{{2 + let g:tlib#sys#system_browser = "exec 'silent !'. g:netrw_browsex_viewer shellescape('%s')" + elseif has("win32") || has("win16") || has("win64") + " let g:tlib#sys#system_browser = "exec 'silent ! start \"\"' shellescape('%s')" + let g:tlib#sys#system_browser = "exec 'silent ! RunDll32.EXE URL.DLL,FileProtocolHandler' shellescape('%s')" + elseif has("mac") + let g:tlib#sys#system_browser = "exec 'silent !open' shellescape('%s')" + elseif exists('$XDG_CURRENT_DESKTOP') && !empty($XDG_CURRENT_DESKTOP) + let g:tlib#sys#system_browser = "exec 'silent !xdg-open' shellescape('%s') '&'" + elseif !empty($GNOME_DESKTOP_SESSION_ID) || $DESKTOP_SESSION ==# 'gnome' + let g:tlib#sys#system_browser = "exec 'silent !gnome-open' shellescape('%s')" + elseif exists("$KDEDIR") && !empty($KDEDIR) + let g:tlib#sys#system_browser = "exec 'silent !kfmclient exec' shellescape('%s')" + else + let g:tlib#sys#system_browser = '' + endif +endif + + +if !exists('g:tlib#sys#windows') + let g:tlib#sys#windows = &shell !~ 'sh' && (has('win16') || has('win32') || has('win64')) "{{{2 +endif + + +if !exists('g:tlib#sys#null') + let g:tlib#sys#null = g:tlib#sys#windows ? 'NUL' : (filereadable('/dev/null') ? '/dev/null' : '') "{{{2 +endif + + +let s:cygwin = {} + +function! tlib#sys#IsCygwinBin(cmd) "{{{3 + " TLogVAR a:cmd + if !g:tlib#sys#windows + return 0 + elseif has_key(s:cygwin, a:cmd) + let rv = s:cygwin[a:cmd] + else + if !tlib#sys#IsExecutable('cygpath', 1) || !tlib#sys#IsExecutable('which', 1) + let rv = 0 + else + let which = substitute(system('which '. shellescape(a:cmd)), '\n$', '', '') + " echom "DBG which:" which + if which =~ '^/' + let filename = system('cygpath -ma '. shellescape(which)) + " echom "DBG filename:" filename + let rv = filename =~ g:tlib#sys#cygwin_path_rx + else + let rv = 0 + endif + endif + let s:cygwin[a:cmd] = rv + endif + " TLogVAR rv + return rv +endf + + +let s:executables = {} + +function! tlib#sys#IsExecutable(cmd, ...) "{{{3 + " TLogVAR a:cmd + " echom "DBG has_key(s:executables, a:cmd)" has_key(s:executables, a:cmd) + if !has_key(s:executables, a:cmd) + let executable = executable(a:cmd) + " TLogVAR 1, executable + let ignore_cyg = a:0 >= 1 ? a:1 : !g:tlib#sys#windows + if !executable && !ignore_cyg + let executable = tlib#sys#IsCygwinBin(a:cmd) + " TLogVAR 2, executable + endif + let s:executables[a:cmd] = executable + endif + " echom "DBG s:executables[a:cmd]" s:executables[a:cmd] + return s:executables[a:cmd] +endf + + +if !exists('g:tlib#sys#check_cygpath') + " If true, check whether we have to convert a path via cyppath -- + " see |tlib#sys#MaybeUseCygpath| + let g:tlib#sys#check_cygpath = g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1) "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_path_rx') + " If a full windows filename (with slashes instead of backslashes) + " matches this |regexp|, it is assumed to be a cygwin executable. + let g:tlib#sys#cygwin_path_rx = '/cygwin/' "{{{2 +endif + + +if !exists('g:tlib#sys#cygwin_expr') + " For cygwin binaries, convert command calls using this vim + " expression. + let g:tlib#sys#cygwin_expr = '"bash -c ''". escape(%s, "''\\") ."''"' "{{{2 +endif + + +function! tlib#sys#GetCmd(cmd) "{{{3 + if !empty(g:tlib#sys#cygwin_expr) && tlib#sys#IsCygwinBin(matchstr(a:cmd, '^\S\+')) + let cmd = eval(printf(g:tlib#sys#cygwin_expr, string(a:cmd))) + " TLogVAR cmd + return cmd + else + return a:cmd + endif +endf + + +" If cmd seems to be a cygwin executable, use cygpath to convert +" filenames. This assumes that cygwin's which command returns full +" filenames for non-cygwin executables. +function! tlib#sys#MaybeUseCygpath(cmd) "{{{3 + " echom "DBG" a:cmd + if g:tlib#sys#check_cygpath && tlib#sys#IsCygwinBin(a:cmd) + return 'cygpath -u "%s"' + endif + return '' +endf + + +function! tlib#sys#ConvertPath(converter, filename) "{{{3 + return tlib#string#Chomp(system(printf(a:converter, shellescape(a:filename)))) +endf + + +let s:native_filenames = {} + +function! tlib#sys#FileArgs(cmd, files) "{{{3 + let cygpath = tlib#sys#MaybeUseCygpath(a:cmd) + " TLogVAR cygpath + if empty(cygpath) + return a:files + else + let files = map(copy(a:files), 'has_key(s:native_filenames, v:val) ? s:native_filenames[v:val] : tlib#sys#CygPath(v:val)') + return files + endif +endf + + +" Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it +" is a special file that should not be opened in vim. +function! tlib#sys#IsSpecial(filename) abort "{{{3 + return a:filename =~ g:tlib#sys#system_rx +endf + + +" Open filename with the default OS application (see +" |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. +" Returns 1 if successful or 0 otherwise. +function! tlib#sys#Open(filename) abort "{{{3 + Tlibtrace 'tlib', a:filename + if !empty(g:tlib#sys#system_browser) && tlib#sys#IsSpecial(a:filename) + try + call tlib#sys#OpenWithSystemViewer(a:filename) + return 1 + catch + echohl ErrorMsg + echom v:exception + echohl NONE + endtry + endif + return 0 +endf + + +" Open filename with the default system viewer. +function! tlib#sys#OpenWithSystemViewer(filename) abort "{{{3 + let cmd = printf(g:tlib#sys#system_browser, a:filename) + " let cmd = printf(g:tlib#sys#system_browser, escape(a:filename, ' %#!')) + Tlibtrace 'tlib', cmd + exec cmd +endf + + +" :def: function! tlib#sys#SystemInDir(dir, expr, ?input='') +function! tlib#sys#SystemInDir(dir, ...) abort "{{{3 + call tlib#dir#CD(a:dir) + try + return call(function('system'), a:000) + finally + silent cd! - + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/tab.vim b/sources_non_forked/tlib/autoload/tlib/tab.vim new file mode 100644 index 00000000..fa6bb8d0 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/tab.vim @@ -0,0 +1,49 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +" Return a dictionary of bufnumbers => [[tabpage, winnr] ...] +function! tlib#tab#BufMap() "{{{3 + let acc = {} + for t in range(tabpagenr('$')) + let bb = tabpagebuflist(t + 1) + for b in range(len(bb)) + let bn = bb[b] + let bd = [t + 1, b + 1] + if has_key(acc, bn) + call add(acc[bn], bd) + else + let acc[bn] = [bd] + endif + endfor + endfor + return acc +endf + + +" Find a buffer's window at some tab page. +function! tlib#tab#TabWinNr(buffer) "{{{3 + let bn = bufnr(a:buffer) + let bt = tlib#tab#BufMap() + let tn = tabpagenr() + let wn = winnr() + let bc = get(bt, bn) + if !empty(bc) + for [t, w] in bc + if t == tn + return [t, w] + endif + endfor + return bc[0] + endif +endf + + +function! tlib#tab#Set(tabnr) "{{{3 + if a:tabnr > 0 + exec a:tabnr .'tabnext' + endif +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/tag.vim b/sources_non_forked/tlib/autoload/tlib/tag.vim new file mode 100644 index 00000000..b82643d1 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/tag.vim @@ -0,0 +1,133 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 64 + + +" Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. +TLet g:tlib_tags_extra = '' + +" Filter the tag description through |substitute()| for these filetypes. +" This applies only if the tag cmd field (see |taglist()|) is used. +" :nodefault: +TLet g:tlib_tag_substitute = { + \ 'java': [['\s*{\s*$', '', '']], + \ 'ruby': [['\<\(def\|class\|module\)\>\s\+', '', '']], + \ 'vim': [ + \ ['^\s*com\%[mand]!\?\(\s\+-\S\+\)*\s*\u\w*\zs.*$', '', ''], + \ ['^\s*\(let\|aug\%[roup]\|fu\%[nction]!\?\|com\%[mand]!\?\(\s\+-\S\+\)*\)\s*', '', ''], + \ ['"\?\s*{{{\d.*$', '', ''], + \ ], + \ } + + +" :def: function! tlib#tag#Retrieve(rx, ?extra_tags=0) +" Get all tags matching rx. Basically, this function simply calls +" |taglist()|, but when extra_tags is true, the list of the tag files +" (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. +" +" Example use: +" If you want to include tags for, eg, JDK, normal tags use can become +" slow. You could proceed as follows: +" 1. Create a tags file for the JDK sources. When creating the tags +" file, make sure to include inheritance information and the like +" (command-line options like --fields=+iaSm --extra=+q should be ok). +" In this example, we want tags only for public methods (there are +" most likely better ways to do this): > +" ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src +" head -n 6 tags > tags0 +" grep access:public tags >> tags0 +" < 2. Make 'tags' include project specific tags files. In +" ~/vimfiles/after/ftplugin/java.vim insert: > +" let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +" < 3. When this function is invoked as > +" echo tlib#tag#Retrieve('print') +" < it will return only project-local tags. If it is invoked as > +" echo tlib#tag#Retrieve('print', 1) +" < tags from the JDK will be included. +function! tlib#tag#Retrieve(rx, ...) "{{{3 + TVarArg ['extra_tags', 0] + Tlibtrace 'tlib', a:rx, extra_tags + if extra_tags + let tags_orig = &l:tags + if empty(tags_orig) + setlocal tags< + endif + try + let more_tags = tlib#var#Get('tlib_tags_extra', 'bg') + if !empty(more_tags) + let &l:tags .= ','. more_tags + endif + let taglist = taglist(a:rx) + finally + let &l:tags = tags_orig + endtry + else + let taglist = taglist(a:rx) + endif + Tlibtrace 'tlib', len(taglist) + return copy(taglist) +endf + + +" Retrieve tags that meet the constraints (a dictionnary of fields and +" regexp, with the exception of the kind field which is a list of chars). +" For the use of the optional use_extra argument see +" |tlib#tag#Retrieve()|. +" :def: function! tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) +function! tlib#tag#Collect(constraints, ...) "{{{3 + TVarArg ['use_extra', 0], ['match_end', 1], ['match_front', 1] + Tlibtrace 'tlib', a:constraints, use_extra, match_end, match_front + let rx = get(a:constraints, 'name', '') + if empty(rx) || rx == '*' + let rx = '.' + else + let rxl = ['\C'] + if match_front + call add(rxl, '^') + endif + " call add(rxl, tlib#rx#Escape(rx)) + call add(rxl, rx) + if match_end + call add(rxl, '$') + endif + let rx = join(rxl, '') + endif + Tlibtrace 'tlib', rx, use_extra + let tags = tlib#tag#Retrieve(rx, use_extra) + Tlibtrace 'tlib', len(tags) + for [field, rx] in items(a:constraints) + if !empty(rx) && rx != '*' + " TLogVAR field, rx + if field == 'kind' + call filter(tags, 'v:val.kind =~ "['. rx .']"') + elseif field != 'name' + call filter(tags, '!empty(get(v:val, field)) && get(v:val, field) =~ rx') + endif + endif + endfor + Tlibtrace 'tlib', len(tags) + return tags +endf + + +function! tlib#tag#Format(tag) "{{{3 + if has_key(a:tag, 'signature') + let name = a:tag.name . a:tag.signature + elseif a:tag.cmd[0] == '/' + let name = a:tag.cmd + let name = substitute(name, '^/\^\?\s*', '', '') + let name = substitute(name, '\s*\$\?/$', '', '') + let name = substitute(name, '\s\{2,}', ' ', 'g') + let tsub = tlib#var#Get('tlib_tag_substitute', 'bg') + if has_key(tsub, &filetype) + for [rx, rplc, sub] in tsub[&filetype] + let name = substitute(name, rx, rplc, sub) + endfor + endif + else + let name = a:tag.name + endif + return name +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/textobjects.vim b/sources_non_forked/tlib/autoload/tlib/textobjects.vim new file mode 100644 index 00000000..fb4170e5 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/textobjects.vim @@ -0,0 +1,45 @@ +" textobjects.vim +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-01-09. +" @Last Change: 2010-01-10. +" @Revision: 0.0.29 + +let s:save_cpo = &cpo +set cpo&vim + + +" :tag: standard-paragraph +" Select a "Standard Paragraph", i.e. a text block followed by blank +" lines. Other than |ap|, the last paragraph in a document is handled +" just the same. +" +" The |text-object| can be accessed as "sp". Example: > +" +" vsp ... select the current standard paragraph +" +" Return 1, if the paragraph is the last one in the document. +function! tlib#textobjects#StandardParagraph() "{{{3 + if line("'}") == line('$') + norm! vip + return 1 + else + norm! vap + return 0 + endif +endf + + +function! tlib#textobjects#Init() "{{{3 + if !exists('s:tlib_done_textobjects') + " sp ... Standard paragraph (for use as |text-objects|). + vnoremap sp :call tlib#textobjects#StandardParagraph() + onoremap sp :normal Vsp + let s:tlib_done_textobjects = 1 + endif +endf + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/autoload/tlib/time.vim b/sources_non_forked/tlib/autoload/tlib/time.vim new file mode 100644 index 00000000..130ef5bc --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/time.vim @@ -0,0 +1,84 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 42 + + +function! tlib#time#MSecs() "{{{3 + let rts = reltimestr(reltime()) + return substitute(rts, '\.', '', '') +endf + + +function! tlib#time#Now() "{{{3 + if has('reltime') + let rts = reltimestr(reltime()) + let rtl = map(split(rts, '\.'), 'str2nr(v:val)') + else + let rtl = [localtime()] + endif + return rtl +endf + + +function! tlib#time#FormatNow() "{{{3 + let rtl = tlib#time#Now() + if len(rtl) == 2 + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) .'.'. rtl[1] + else + let rts = strftime(g:tlib#date#date_format .' %H:%M:%S', rtl[0]) + endif + return rts +endf + + +function! tlib#time#Diff(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + let [as, am] = a:a + let [bs, bm] = a:b + let rv = 0 + (as - bs) + if resolution > 0 + let rv .= repeat('0', resolution) + let am = am[0 : resolution - 1] + let bm = bm[0 : resolution - 1] + let rv += (am - bm) + endif + return rv +endf + + +function! tlib#time#DiffMSecs(a, b, ...) "{{{3 + TVarArg ['resolution', 2] + if a:a == a:b + return 0 + endif + let a = printf('%30s', a:a[0 : -(7 - resolution)]) + let b = printf('%30s', a:b[0 : -(7 - resolution)]) + for i in range(0, 29) + if a[i] != b[i] + let a = a[i : -1] + let b = b[i : -1] + return a - b + endif + endfor + return 0 +endf + + +function! tlib#time#Command(cmd, ...) abort "{{{3 + let loops = a:0 >= 1 ? a:1 : 1 + let silent = a:0 >= 1 ? a:1 : 0 + let start = tlib#time#Now() + for loop in range(loops) + if silent + silent! exec a:cmd + else + exec a:cmd + endif + endfor + let end = tlib#time#Now() + let diff = tlib#time#Diff(end, start) + echom 'Time:' diff + return diff +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/trace.vim b/sources_non_forked/tlib/autoload/tlib/trace.vim new file mode 100644 index 00000000..25a00a23 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/trace.vim @@ -0,0 +1,198 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2017-03-09 +" @Revision: 205 + + +if !exists('g:tlib#trace#backtrace') + " The length of the backtrace that should be included in + " |tlib#trace#Print()|. + let g:tlib#trace#backtrace = 2 "{{{2 +endif + + +if !exists('g:tlib#trace#printer') + " Possible values: + " - 'echom' + " - ['file', FILENAME] + let g:tlib#trace#printer = 'echom' "{{{2 +endif + + +if !exists('g:tlib#trace#hl') + let g:tlib#trace#hl = {'error': 'ErrorMsg', 'fatal': 'ErrorMsg', 'warn': 'WarningMsg'} "{{{2 +endif + + +" Print traces from |tlib#trace#Print()|. +function! tlib#trace#Printer_echom(type, text, args) abort "{{{3 + let hl = get(g:tlib#trace#hl, a:type, '') + try + if !empty(hl) + exec 'echohl' hl + endif + echom a:text + finally + if !empty(hl) + echohl NONE + endif + endtry +endf + + +function! tlib#trace#Printer_file(type, text, args) abort "{{{3 + let filename = get(a:args, 0, '') + if exists(filename) && !filewritable(filename) + throw 'tlib#trace#Printer_file: Cannot write to file: '. filename + else + call writefile([a:text], filename, 'a') + endif +endf + + +" Set the tracing |regexp|. See |:Tlibtrace|. +" This will also call |tlib#trace#Enable()|. +" +" Examples: +" call tlib#trace#Set(["+foo", "-bar"]) +" call tlib#trace#Set("+foo,-bar") +function! tlib#trace#Set(vars, ...) abort "{{{3 + let reset = a:0 >= 1 ? a:1 : 0 + if reset + call tlib#trace#Reset() + endif + if empty(a:vars) + return + endif + call tlib#trace#Enable() + if type(a:vars) == v:t_string + let vars = tlib#string#SplitCommaList(a:vars, '[,[:space:]]\+') + let opts = {} + elseif type(a:vars) == v:t_dict + let vars = a:vars.__rest__ + if has_key(a:vars, 'file') + let g:tlib#trace#printer = ['file', a:vars.file] + endif + if has_key(a:vars, 'echo') + let g:tlib#trace#printer = 'echom' + endif + else + let vars = a:vars + let opts = {} + endif + " TLogVAR vars + for rx in vars + let rx1 = substitute(rx, '^[+-]', '', 'g') + if rx1 !~# '^\%(error\|warn\|fatal\)$' + let erx1 = tlib#rx#Escape(rx1) + " TLogVAR rx, rx1 + " echom "DBG" s:trace_rx + if rx =~ '^-' + let erx1 .= '\[0-\d\]\\?' + if s:trace_rx =~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\\|'. erx1, '', '') + endif + " elseif rx =~ '^+' + else + if erx1 =~ '\d$' + let erx1 = substitute(erx1, '\d$', '[0-\0]\\?', '') + else + let erx1 .= '[0-9]\?' + endif + if s:trace_rx !~# '[(|]'. erx1 .'\\' + let s:trace_rx = substitute(s:trace_rx, '\ze\\)\$', '\\|'. escape(erx1, '\'), '') + endif + " else + " echohl WarningMsg + " echom 'tlib#trace#Print: Unsupported syntax:' rx + " echohl NONE + endif + " echom "DBG" s:trace_rx + endif + endfor + echom "SetTrace:" s:trace_rx +endf + + +function! tlib#trace#Backtrace(caller) abort "{{{3 + let caller = split(a:caller, '\.\.') + let start = max([0, len(caller) - g:tlib#trace#backtrace - 1]) + let caller = caller[start : -1] + return join(caller, '..') +endf + + +" Print the values of vars. The first value is a "guard" (see +" |:Tlibtrace|). +function! tlib#trace#Print(caller, vars, values) abort "{{{3 + " echom "DBG tlib#trace#Print" string(a:vars) string(a:values) + let msg = ['TRACE'] + let guard = a:values[0] + if type(guard) == 0 + let cond = guard + else + let cond = guard =~# s:trace_rx + endif + " TLogVAR guard, cond, a:vars, a:values + if cond + call add(msg, guard) + call add(msg, tlib#time#FormatNow() .':') + if g:tlib#trace#backtrace > 0 + let bt = tlib#trace#Backtrace(a:caller) + if !empty(bt) + call add(msg, bt .':') + endif + endif + if len(a:vars) == len(a:values) + for i in range(1, len(a:vars) - 1) + let v = substitute(a:vars[i], ',$', '', '') + if type(a:values[i]) == v:t_func + let r = string(a:values[i]) + else + let r = a:values[i] + endif + if v =~# '^\([''"]\).\{-}\1$' + call add(msg, r .';') + else + call add(msg, v .'='. string(r) .';') + endif + unlet r + endfor + else + call add(msg, join(a:values[1:-1])) + endif + if type(g:tlib#trace#printer) == v:t_string + let printer = g:tlib#trace#printer + let args = [] + else + let [printer; args] = g:tlib#trace#printer + endif + call tlib#trace#Printer_{printer}(guard, join(msg), args) + endif +endf + + +function! tlib#trace#Reset() abort "{{{3 + let s:trace_rx = '^\%(error\|fatal\|warn\|info\)$' + let g:tlib#trace#printer = 'echom' +endf + + +" Enable tracing via |:Tlibtrace|. +function! tlib#trace#Enable() abort "{{{3 + if !exists('s:trace_rx') + call tlib#trace#Reset() + " :nodoc: + command! -nargs=+ -bang Tlibtrace call tlib#trace#Print(expand(''), [], []) + endif +endf + + +" Disable tracing via |:Tlibtrace|. +function! tlib#trace#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ -bang Tlibtrace : + unlet! s:trace_rx +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/type.vim b/sources_non_forked/tlib/autoload/tlib/type.vim new file mode 100644 index 00000000..6bac9228 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/type.vim @@ -0,0 +1,142 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-09-30. +" @Last Change: 2017-02-22. +" @Revision: 57 + + +let g:tlib#type#nil = [] + + +" Enable type assertiona via |:Tlibtype|. +function! tlib#type#Enable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype call tlib#type#Check(expand(''), [], []) +endf + + +" Disable type assertiona via |:Tlibtype|. +function! tlib#type#Disable() abort "{{{3 + " :nodoc: + command! -nargs=+ Tlibtype : +endf + + +function! tlib#type#IsNil(expr) abort "{{{3 + return tlib#type#Is(a:expr, v:t_none) || a:expr is g:tlib#type#nil +endf + + +function! tlib#type#IsNumber(expr) + return tlib#type#Is(a:expr, 0) +endf + + +function! tlib#type#IsString(expr) + return tlib#type#Is(a:expr, 1) +endf + + +function! tlib#type#IsFuncref(expr) + return tlib#type#Is(a:expr, 2) +endf + + +function! tlib#type#IsList(expr) + return tlib#type#Is(a:expr, 3) +endf + + +function! tlib#type#IsDictionary(expr) + return tlib#type#Is(a:expr, 4) +endf + + +function! tlib#type#Is(val, type) abort "{{{3 + if has_key(s:schemas, a:type) + return tlib#type#Has(a:val, a:type) + else + if type(a:type) == 0 + let type = a:type + elseif a:type =~? '^b\%[oolean]$' + let type = v:t_bool + elseif a:type =~? '^c\%[hannel]$' + let type = v:t_channel + elseif a:type =~? '^d\%[ictionary]$' + let type = v:t_dict + elseif a:type =~? '^fl\%[oat]$' + let type = v:t_float + elseif a:type =~? '^fu\%[ncref]$' + let type = v:t_func + elseif a:type =~? '^j\%[ob]$' + let type = v:t_job + elseif a:type =~? '^l\%[ist]$' + let type = v:t_list + elseif a:type =~? '^\%(nil\|null\|none\)$' + let type = v:t_none + elseif a:type =~? '^n\%[umber]$' + let type = v:t_number + elseif a:type =~? '^s\%[tring]$' + let type = v:t_string + else + throw 'tlib#type#Is: Unknown type: ' a:type + endif + Tlibtrace 'tlib', a:val, a:type, type, type(a:val), type(a:val) == a:type + return type(a:val) == type + endif +endf + + +function! tlib#type#Are(vals, type) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Is(v:val,'. string(a:type) .')') +endf + + +let s:schemas = {} + + +function! tlib#type#Define(name, schema) abort "{{{3 + let s:schemas[a:name] = deepcopy(a:schema) +endf + + +function! tlib#type#Has(val, schema) abort "{{{3 + Tlibtrace 'tlib', type(a:val), type(a:schema) + if !tlib#type#IsDictionary(a:val) + Tlibtrace 'tlib', 'not a dictionary', a:val + return 0 + endif + if tlib#type#IsString(a:schema) + Tlibtrace 'tlib', a:schema + let schema = copy(s:schemas[a:schema]) + else + let schema = copy(a:schema) + endif + if tlib#type#IsDictionary(schema) + return tlib#assert#All(map(schema, 'has_key(a:val, v:key) && tlib#type#Is(a:val[v:key], v:val)')) + else + Tlibtrace 'tlib', keys(a:val), schema + return tlib#assert#All(map(schema, 'has_key(a:val, v:val)')) + endif +endf + + +function! tlib#type#Have(vals, schema) abort "{{{3 + return tlib#assert#Map(a:vals, 'tlib#type#Has(v:val,'. string(a:schema) .')') +endf + + +function! tlib#type#Check(caller, names, vals) abort "{{{3 + Tlibtrace 'tlib', a:names, a:vals, len(a:names) + for i in range(0, len(a:names) - 1, 2) + let val = a:vals[i] + let type = a:vals[i + 1] + Tlibtrace 'tlib', i, val, type + if !tlib#type#Is(val, type) + let name = matchstr(a:names[i], '^''\zs.\{-}\ze'',\?$') + throw 'tlib#type#Check: Type mismatch: '. name .':'. a:vals[i + 1] + endif + endfor +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/url.vim b/sources_non_forked/tlib/autoload/tlib/url.vim new file mode 100644 index 00000000..b948d48a --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/url.vim @@ -0,0 +1,52 @@ +" url.vim +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2007-06-30. +" @Last Change: 2011-03-10. +" @Revision: 0.0.28 + + +" TODO: These functions could use printf() now. + +" Decode an encoded URL. +function! tlib#url#Decode(url) "{{{3 + return substitute(a:url, '\(+\|%\(%\|\x\x\)\)', '\=tlib#url#DecodeChar(submatch(1))', 'g') +endf + + +" Decode a single character. +function! tlib#url#DecodeChar(char) "{{{3 + if a:char == '%%' + return '%' + elseif a:char == '+' + return ' ' + else + return nr2char("0x".a:char[1 : -1]) + endif +endf + + +" Encode a single character. +function! tlib#url#EncodeChar(char) "{{{3 + if a:char == '%' + return '%%' + elseif a:char == ' ' + return '+' + else + return printf("%%%X", char2nr(a:char)) + endif +endf + + +" Encode an URL. +function! tlib#url#Encode(url, ...) "{{{3 + TVarArg ['extrachars', ''] + let rx = '\([^a-zA-Z0-9_.'. extrachars .'-]\)' + " TLogVAR a:url, rx + let rv = substitute(a:url, rx, '\=tlib#url#EncodeChar(submatch(1))', 'g') + " TLogVAR rv + return rv +endf + + diff --git a/sources_non_forked/tlib/autoload/tlib/var.vim b/sources_non_forked/tlib/autoload/tlib/var.vim new file mode 100644 index 00000000..cf0d2946 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/var.vim @@ -0,0 +1,90 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 34 + + +" Define a variable called NAME if yet undefined. +" You can also use the :TLLet command. +" +" EXAMPLES: > +" exec tlib#var#Let('g:foo', 1) +" TLet g:foo = 1 +function! tlib#var#Let(name, val) "{{{3 + return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, string(a:val)) + " return printf('if !exists(%s) | let %s = %s | endif', string(a:name), a:name, a:val) +endf + + +" :def: function! tlib#var#EGet(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo eval(tlib#var#EGet('foo', 'vg')) => 1 +" echo eval(tlib#var#EGet('foo', 'bg')) => 2 +" echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +function! tlib#var#EGet(var, namespace, ...) "{{{3 + let pre = [] + let post = [] + for namespace in split(a:namespace, '\zs') + let var = namespace .':'. a:var + call add(pre, printf('exists("%s") ? %s : (', var, var)) + call add(post, ')') + endfor + let default = a:0 >= 1 ? a:1 : '' + return join(pre) . string(default) . join(post) +endf + + +" :def: function! tlib#var#Get(var, namespace, ?default='') +" Retrieve a variable by searching several namespaces. +" +" EXAMPLES: > +" let g:foo = 1 +" let b:foo = 2 +" let w:foo = 3 +" echo tlib#var#Get('foo', 'bg') => 1 +" echo tlib#var#Get('foo', 'bg') => 2 +" echo tlib#var#Get('foo', 'wbg') => 3 +function! tlib#var#Get(var, namespace, ...) "{{{3 + let var_ = substitute(a:var, '#', '_', 'g') + for namespace in split(a:namespace, '\zs') + let vname = namespace ==# 'g' ? a:var : var_ + let var = namespace .':'. vname + if exists(var) + return {var} + elseif namespace ==# 'g' + try + let val = {var} + catch /^Vim\%((\a\+)\)\=:E\(121\|15\)/ + continue + endtry + return val + endif + endfor + return a:0 >= 1 ? a:1 : '' +endf + + +" :def: function! tlib#var#List(rx, ?prefix='') +" Get a list of variables matching rx. +" EXAMPLE: +" echo tlib#var#List('tlib_', 'g:') +function! tlib#var#List(rx, ...) "{{{3 + TVarArg ['prefix', 'g:'] + if v:version >= 704 + exec 'let varlist = keys('. prefix .')' + else + redir => vars + silent! exec 'let '. prefix + redir END + let varlist = split(vars, '\n') + call map(varlist, 'matchstr(v:val, ''^\S\+'')') + endif + call filter(varlist, 'v:val =~ a:rx') + return varlist +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/vcs.vim b/sources_non_forked/tlib/autoload/tlib/vcs.vim new file mode 100644 index 00000000..e551be22 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/vcs.vim @@ -0,0 +1,230 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2012-03-08. +" @Last Change: 2017-04-10. +" @Revision: 224 + +scriptencoding utf-8 + + +" A dictionarie of supported VCS (currently: git, hg, svn, bzr). +" :display: g:tlib#vcs#def {...} +TLet g:tlib#vcs#def = { + \ 'git': { + \ 'dir': '.git', + \ 'ls': 'git ls-files --full-name', + \ 'ls.postprocess': '*tlib#vcs#GitLsPostprocess', + \ 'diff': 'git diff --no-ext-diff -U0 %s', + \ 'status': 'git status -s', + \ 'status.filterrx': '^\C[ MADRCU!?]\{2}\s'}, + \ 'hg': { + \ 'dir': '.hg', + \ 'diff': 'hg diff -U0 %s', + \ 'ls': 'hg manifest'}, + \ 'svn': { + \ 'dir': '.svn', + \ 'diff': 'svn diff --diff-cmd diff --extensions -U0 %s'}, + \ 'bzr': { + \ 'dir': '.bzr', + \ 'diff': 'bzr diff --diff-options=-U0 %s'} + \ } + + +" A dictionary of custom executables for VCS commands. If the value is +" empty, support for that VCS will be removed. If no key is present, it +" is assumed that the VCS "type" is the name of the executable. +" :display: g:tlib#vcs#executables {...} +TLet g:tlib#vcs#executables = {} + + +" If non-empty, use it as a format string to check whether a VCS is +" installed on your computer. +TLet g:tlib#vcs#check = has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s' + + +if !empty(g:tlib#vcs#check) + for [s:cmd, s:def] in items(g:tlib#vcs#def) + if !has_key(g:tlib#vcs#executables, s:cmd) + let s:cmd1 = printf(g:tlib#vcs#check, s:cmd) + let g:tlib#vcs#executables[s:cmd] = executable(s:cmd1) ? s:cmd1 : '' + endif + endfor + unlet! s:cmd s:def s:cmd1 +endif + + +function! tlib#vcs#Executable(type) "{{{3 + return get(g:tlib#vcs#executables, a:type, '') +endf + + +let s:vcs_cache = {} +autocmd TLib FocusGained * let s:vcs_cache = {} + + +function! tlib#vcs#FindVCS(filename) "{{{3 + let type = '' + let dir = '' + let filename = fnamemodify(a:filename, ':p') + let dirname = isdirectory(filename) ? filename : fnamemodify(filename, ':h') + if !has_key(s:vcs_cache, dirname) + let path = escape(dirname, ';') .';' + " TLogVAR filename, dirname, path + Tlibtrace 'tlib', filename, path + let depth = -1 + for vcs in keys(g:tlib#vcs#def) + let subdir = g:tlib#vcs#def[vcs].dir + let vcsdir = finddir(subdir, path) + " TLogVAR vcs, subdir, vcsdir + Tlibtrace 'tlib', vcs, subdir, vcsdir + if !empty(vcsdir) + let vcsdir_depth = len(split(fnamemodify(vcsdir, ':p'), '\/')) + if vcsdir_depth > depth + let depth = vcsdir_depth + let type = vcs + let dir = vcsdir + " TLogVAR type, depth + endif + endif + endfor + Tlibtrace 'tlib', type, dir + " TLogVAR type, dir + if empty(type) + let s:vcs_cache[dirname] = ['', ''] + else + let s:vcs_cache[dirname] = [type, dir] + endif + endif + return s:vcs_cache[dirname] +endf + + +function! s:GetCmd(vcstype, cmd) + let vcsdef = get(g:tlib#vcs#def, a:vcstype, {}) + if has_key(vcsdef, a:cmd) + let cmd = vcsdef[a:cmd] + if cmd =~# '^\*' + let cmd = substitute(cmd, '^\*', '', '') + else + let bin = get(g:tlib#vcs#executables, a:vcstype, '') + if empty(bin) + let cmd = '' + elseif bin != a:vcstype + " let bin = escape(shellescape(bin), '\') + let bin = escape(bin, '\') + let cmd = substitute(cmd, '^.\{-}\zs'. escape(a:vcstype, '\'), bin, '') + endif + endif + return cmd + else + return '' + endif +endf + + +" :display: tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) +" Return the files under VCS. +function! tlib#vcs#Ls(...) "{{{3 + if a:0 >= 2 + let vcs = a:2 + else + let vcs = tlib#vcs#FindVCS(a:0 >= 1 ? a:1 : bufname('%')) + endif + Tlibtrace 'tlib', vcs, a:000 + " TLogVAR vcs + if !empty(vcs) + let [vcstype, vcsdir] = vcs + if has_key(g:tlib#vcs#def, vcstype) + let ls = s:GetCmd(vcstype, 'ls') + " TLogVAR ls + if !empty(ls) + let rootdir = fnamemodify(vcsdir, ':p:h:h') + " TLogVAR vcsdir, rootdir + if ls =~# '%s' + let cmd = printf(ls, shellescape(rootdir)) + else + let cmd = ls + endif + " TLogVAR cmd, getcwd() + Tlibtrace 'tlib', getcwd(), vcstype, vcsdir, rootdir, cmd + let filess = tlib#sys#SystemInDir(rootdir, cmd) + " TLogVAR filess + let files = split(filess, '\n') + let postprocess = s:GetCmd(vcstype, 'ls.postprocess') + if !empty(postprocess) + call map(files, 'call(postprocess, [v:val])') + endif + call map(files, 'join([rootdir, v:val], "/")') + " TLogVAR files + return files + endif + endif + endif + return [] +endf + + +" :display: tlib#vcs#Diff(filename, ?vcs=[type, dir]) +" Return the diff for "filename" +function! tlib#vcs#Diff(filename, ...) "{{{3 + let vcs = a:0 >= 1 ? a:1 : tlib#vcs#FindVCS(a:filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let diff = s:GetCmd(vcstype, 'diff') + if !empty(diff) + let cmd = printf(diff, shellescape(fnamemodify(a:filename, ':p'))) + let patch = system(cmd) + return patch + endif + endif + return [] +endf + + +function! tlib#vcs#GitLsPostprocess(filename) abort "{{{3 + if a:filename =~# '^".\{-}"$' + let filename = matchstr(a:filename, '^"\zs.\{-}\ze"$') + let filename = substitute(filename, '\%(\\\@= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + if !empty(vcs) + let [vcstype, vcsdir] = vcs + let cstatus = s:GetCmd(vcstype, 'status') + if !empty(cstatus) + let status = exists('*systemlist') ? systemlist(cstatus) : split(system(cstatus), '\n') + let sfilter = s:GetCmd(vcstype, 'status.filterrx') + if !empty(sfilter) + let status = filter(status, 'v:val =~# sfilter') + endif + return status + endif + endif +endf + + +function! tlib#vcs#IsDirty(...) abort "{{{3 + let filename = a:0 >= 1 ? a:1 : '%' + let vcs = a:0 >= 2 ? a:2 : tlib#vcs#FindVCS(filename) + let status = tlib#vcs#Status(filename, vcs) + return empty(status) ? '' : vcs[0] .'!' +endf + + +" function! tlib#vcs#EnableTStatus() abort "{{{3 +" if has('vim_starting') +" autocmd VimEnter * TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" else +" TStatusregister1 --event=FocusGained,BufRead,BufWritePost %s tlib#vcs#IsDirty() +" endif +" endf + diff --git a/sources_non_forked/tlib/autoload/tlib/vim.vim b/sources_non_forked/tlib/autoload/tlib/vim.vim new file mode 100644 index 00000000..7154aeb1 --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/vim.vim @@ -0,0 +1,152 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-07-19. +" @Last Change: 2012-06-08. +" @Revision: 37 + + +let s:restoreframecmd = '' +let s:fullscreen = 0 + +if has('win16') || has('win32') || has('win64') + + if !exists('g:tlib#vim#simalt_maximize') + " The alt-key for maximizing the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_maximize = 'x' "{{{2 + endif + + if !exists('g:tlib#vim#simalt_restore') + " The alt-key for restoring the window. + " CAUTION: The value of this paramter depends on your locale and + " maybe the windows version you are running. + let g:tlib#vim#simalt_restore = 'r' "{{{2 + endif + + if !exists('g:tlib#vim#use_vimtweak') + " If true, use the vimtweak.dll for windows. This will enable + " tlib to remove the caption for fullscreen windows. + let g:tlib#vim#use_vimtweak = 0 "{{{2 + endif + + " Maximize the window. + " You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + " work for you. + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_vimtweak && a:fullscreen + call libcallnr("vimtweak.dll", "EnableCaption", 0) + endif + exec 'simalt ~'. g:tlib#vim#simalt_maximize + endf + + " Restore the original vimsize after having called |tlib#vim#Maximize()|. + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_vimtweak + call libcallnr("vimtweak.dll", "EnableCaption", 1) + endif + exec 'simalt ~'. g:tlib#vim#simalt_restore + call s:RestoreFrameParams() + endf + +else + + if !exists('g:tlib#vim#use_wmctrl') + " If true, use wmctrl for X windows to make a window + " maximized/fullscreen. + " + " This is the preferred method for maximizing windows under X + " windows. Some window managers have problem coping with the + " default method of setting 'lines' and 'columns' to a large + " value. + let g:tlib#vim#use_wmctrl = executable('wmctrl') "{{{2 + endif + + " :nodoc: + fun! tlib#vim#Maximize(fullscreen) "{{{3 + if !has("gui_running") + return + endif + call s:SaveFrameParams() + let s:fullscreen = a:fullscreen + if g:tlib#vim#use_wmctrl + if a:fullscreen + silent !wmctrl -r :ACTIVE: -b add,fullscreen + else + silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz + endif + else + set lines=1000 columns=1000 + endif + endf + + " :nodoc: + function! tlib#vim#RestoreWindow() "{{{3 + if !has("gui_running") + return + endif + if g:tlib#vim#use_wmctrl + if s:fullscreen + silent !wmctrl -r :ACTIVE: -b remove,fullscreen + else + silent !wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz + endif + endif + call s:RestoreFrameParams() + endf + +endif + + +function! s:SaveFrameParams() "{{{3 + let s:restoreframecmd = printf("set lines=%d columns=%d | winpos %d %d", &lines, &columns, getwinposx(), getwinposy()) +endf + + +function! s:RestoreFrameParams() "{{{3 + if !empty(s:restoreframecmd) + exec s:restoreframecmd + let s:restoreframecmd = '' + endif +endf + + +" :display: tlib#vim##CopyFunction(old, new, overwrite=0) +function! tlib#vim#CopyFunction(old, new, ...) "{{{3 + let overwrite = a:0 >= 1 ? a:1 : 0 + redir => oldfn + exec 'silent function' a:old + redir END + if exists('*'. a:new) + if overwrite > 0 + exec 'delfunction' a:new + elseif overwrite < 0 + throw 'tlib#vim##CopyFunction: Function already exists: '. a:old .' -> '. a:new + else + return + endif + endif + let fn = split(oldfn, '\n') + let fn = map(fn, 'substitute(v:val, ''^\d\+'', "", "")') + let fn[0] = substitute(fn[0], '\V\^\s\*fu\%[nction]!\?\s\+\zs'. a:old, a:new, '') + let t = @t + try + let @t = join(fn, "\n") + redir => out + @t + redir END + finally + let @t = t + endtry +endf + diff --git a/sources_non_forked/tlib/autoload/tlib/win.vim b/sources_non_forked/tlib/autoload/tlib/win.vim new file mode 100644 index 00000000..12ad7a0f --- /dev/null +++ b/sources_non_forked/tlib/autoload/tlib/win.vim @@ -0,0 +1,201 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 84 + + +if !exists('g:tlib#win#use_winid') + let g:tlib#win#use_winid = exists('*win_gotoid') && exists('*win_getid') "{{{2 +endif + + +" Return vim code to jump back to the original window. +function! tlib#win#Set(winnr) "{{{3 + if a:winnr > 0 + " TLogVAR a:winnr + " TLogDBG winnr() + " TLogDBG string(tlib#win#List()) + if winnr() != a:winnr && winbufnr(a:winnr) != -1 + let rv = winnr().'wincmd w' + exec a:winnr .'wincmd w' + " TLogVAR rv + " TLogDBG string(tlib#win#List()) + return rv + endif + endif + return '' +endf + + +if g:tlib#win#use_winid + let g:tlib#win#null_id = -1 + function! tlib#win#GetID() abort "{{{3 + return win_getid() + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + call win_gotoid(a:win_id) + endf +else + let s:win_id = 0 + let g:tlib#win#null_id = {} + function! tlib#win#GetID() abort "{{{3 + if !exists('w:tlib_win_id') + let s:win_id += 1 + let w:tlib_win_id = s:win_id + endif + return {'tabpagenr': tabpagenr(), 'bufnr': bufnr('%'), 'winnr': winnr(), 'win_id': w:tlib_win_id} + endf + function! tlib#win#GotoID(win_id) abort "{{{3 + Tlibtrace 'tlib', a:win_id + if tabpagenr() != a:win_id.tabpagenr + exec 'tabnext' a:win_id.tabpagenr + endif + for wnr in range(1, winnr('$')) + let win_id = getwinvar(wnr, 'tlib_win_id', -1) + Tlibtrace 'tlib', wnr, win_id + if win_id == a:win_id.win_id + Tlibtrace 'tlib', wnr + exec wnr 'wincmd w' + return + endif + endfor + " Was the window closed? What should we do now? + if winnr() != a:win_id.winnr + exec a:win_id.winnr 'wincmd w' + endif + if bufnr('%') != a:win_id.bufnr + exec 'hide buffer' a:win_id.bufnr + endif + endf +endif + + +" Return vim code to jump back to the original window. +function! tlib#win#SetById(win_id) "{{{3 + if a:win_id != g:tlib#win#null_id + if g:tlib#win#use_winid + let win_id = tlib#win#GetID() + else + let win_id = tlib#win#GetID().win_id + endif + call tlib#win#GotoID(a:win_id) + return printf('call tlib#win#GotoID(%s)', win_id) + " " TLogVAR a:winnr + " " TLogDBG winnr() + " " TLogDBG string(tlib#win#List()) + " if winnr() != a:winnr && winbufnr(a:winnr) != -1 + " let rv = winnr().'wincmd w' + " exec a:winnr .'wincmd w' + " " TLogVAR rv + " " TLogDBG string(tlib#win#List()) + " return rv + " endif + endif + return '' +endf + + +" :def: function! tlib#win#GetLayout(?save_view=0) +function! tlib#win#GetLayout(...) "{{{3 + TVarArg ['save_view', 0] + let views = {} + if save_view + let winnr = winnr() + windo let views[winnr()] = winsaveview() + " for w in range(1, winnr('$')) + " call tlib#win#Set(w) + " let views[w] = winsaveview() + " endfor + call tlib#win#Set(winnr) + endif + return {'winnr': winnr('$'), 'winrestcmd': winrestcmd(), 'views': views, 'cmdheight': &cmdheight, 'guioptions': &guioptions, 'tabpagenr': tabpagenr()} +endf + + +function! tlib#win#SetLayout(layout) "{{{3 + if a:layout.tabpagenr == tabpagenr() && a:layout.winnr == winnr('$') + " TLogVAR a:layout.winrestcmd + " TLogDBG string(tlib#win#List()) + exec a:layout.winrestcmd + if !empty(a:layout.views) + let winnr = winnr() + " TLogVAR winnr + for [w, v] in items(a:layout.views) + " TLogVAR w, v + call tlib#win#Set(w) + call winrestview(v) + endfor + call tlib#win#Set(winnr) + endif + if a:layout.cmdheight != &cmdheight + let &cmdheight = a:layout.cmdheight + endif + " TLogDBG string(tlib#win#List()) + return 1 + endif + return 0 +endf + + +function! tlib#win#List() "{{{3 + let wl = {} + for wn in range(1, winnr('$')) + let wl[wn] = bufname(winbufnr(wn)) + endfor + return wl +endf + + +" " :def: function! tlib#win#GetLayout1(?save_view=0) +" " Contrary to |tlib#win#GetLayout|, this version doesn't use +" " |winrestcmd()|. It can also save windows views. +" function! tlib#win#GetLayout1(...) "{{{3 +" TVarArg ['save_view', 0] +" let winnr = winnr() +" let acc = {} +" for w in range(1, winnr('$')) +" let def = {'h': winheight(w), 'w': winwidth(w)} +" if save_view +" call tlib#win#Set(w) +" let def.view = winsaveview() +" endif +" let acc[w] = def +" endfor +" call tlib#win#Set(winnr) +" return acc +" endf +" +" +" " Reset layout from the value of |tlib#win#GetLayout1|. +" function! tlib#win#SetLayout1(layout) "{{{3 +" if len(a:layout) != winnr('$') +" return 0 +" endif +" let winnr = winnr() +" for [w, def] in items(a:layout) +" if tlib#win#Set(w) +" exec 'resize '. def.h +" exec 'vertical resize '. def.w +" if has_key(def, 'view') +" call winrestview(def.view) +" endif +" else +" break +" endif +" endfor +" call tlib#win#Set(winnr) +" return 1 +" endf + + +function! tlib#win#Width(wnr) "{{{3 + return winwidth(a:wnr) - &fdc +endf + + +function! tlib#win#WinDo(ex) "{{{3 + let w = winnr() + exec 'windo '. a:ex + exec w .'wincmd w' +endf + diff --git a/sources_non_forked/tlib/doc/tags b/sources_non_forked/tlib/doc/tags new file mode 100644 index 00000000..26ad4085 --- /dev/null +++ b/sources_non_forked/tlib/doc/tags @@ -0,0 +1,223 @@ +:TBrowseOutput tlib.txt /*:TBrowseOutput* +:TBrowseScriptnames tlib.txt /*:TBrowseScriptnames* +:TLet tlib.txt /*:TLet* +:TScratch tlib.txt /*:TScratch* +:TVarArg tlib.txt /*:TVarArg* +:Tbrowseloc tlib.txt /*:Tbrowseloc* +:Tbrowseqfl tlib.txt /*:Tbrowseqfl* +:Texecloc tlib.txt /*:Texecloc* +:Texecqfl tlib.txt /*:Texecqfl* +:Tlibtrace tlib.txt /*:Tlibtrace* +:Tlibtraceset tlib.txt /*:Tlibtraceset* +autoload/tlib/Filter_cnf.vim tlib.txt /*autoload\/tlib\/Filter_cnf.vim* +autoload/tlib/Filter_cnfd.vim tlib.txt /*autoload\/tlib\/Filter_cnfd.vim* +autoload/tlib/Filter_fuzzy.vim tlib.txt /*autoload\/tlib\/Filter_fuzzy.vim* +autoload/tlib/Filter_glob.vim tlib.txt /*autoload\/tlib\/Filter_glob.vim* +autoload/tlib/Object.vim tlib.txt /*autoload\/tlib\/Object.vim* +autoload/tlib/World.vim tlib.txt /*autoload\/tlib\/World.vim* +autoload/tlib/agent.vim tlib.txt /*autoload\/tlib\/agent.vim* +autoload/tlib/arg.vim tlib.txt /*autoload\/tlib\/arg.vim* +autoload/tlib/assert.vim tlib.txt /*autoload\/tlib\/assert.vim* +autoload/tlib/buffer.vim tlib.txt /*autoload\/tlib\/buffer.vim* +autoload/tlib/cache.vim tlib.txt /*autoload\/tlib\/cache.vim* +autoload/tlib/char.vim tlib.txt /*autoload\/tlib\/char.vim* +autoload/tlib/cmd.vim tlib.txt /*autoload\/tlib\/cmd.vim* +autoload/tlib/comments.vim tlib.txt /*autoload\/tlib\/comments.vim* +autoload/tlib/date.vim tlib.txt /*autoload\/tlib\/date.vim* +autoload/tlib/dir.vim tlib.txt /*autoload\/tlib\/dir.vim* +autoload/tlib/file.vim tlib.txt /*autoload\/tlib\/file.vim* +autoload/tlib/hook.vim tlib.txt /*autoload\/tlib\/hook.vim* +autoload/tlib/input.vim tlib.txt /*autoload\/tlib\/input.vim* +autoload/tlib/list.vim tlib.txt /*autoload\/tlib\/list.vim* +autoload/tlib/map.vim tlib.txt /*autoload\/tlib\/map.vim* +autoload/tlib/normal.vim tlib.txt /*autoload\/tlib\/normal.vim* +autoload/tlib/notify.vim tlib.txt /*autoload\/tlib\/notify.vim* +autoload/tlib/paragraph.vim tlib.txt /*autoload\/tlib\/paragraph.vim* +autoload/tlib/persistent.vim tlib.txt /*autoload\/tlib\/persistent.vim* +autoload/tlib/progressbar.vim tlib.txt /*autoload\/tlib\/progressbar.vim* +autoload/tlib/rx.vim tlib.txt /*autoload\/tlib\/rx.vim* +autoload/tlib/scratch.vim tlib.txt /*autoload\/tlib\/scratch.vim* +autoload/tlib/selection.vim tlib.txt /*autoload\/tlib\/selection.vim* +autoload/tlib/signs.vim tlib.txt /*autoload\/tlib\/signs.vim* +autoload/tlib/string.vim tlib.txt /*autoload\/tlib\/string.vim* +autoload/tlib/sys.vim tlib.txt /*autoload\/tlib\/sys.vim* +autoload/tlib/tab.vim tlib.txt /*autoload\/tlib\/tab.vim* +autoload/tlib/tag.vim tlib.txt /*autoload\/tlib\/tag.vim* +autoload/tlib/textobjects.vim tlib.txt /*autoload\/tlib\/textobjects.vim* +autoload/tlib/trace.vim tlib.txt /*autoload\/tlib\/trace.vim* +autoload/tlib/type.vim tlib.txt /*autoload\/tlib\/type.vim* +autoload/tlib/url.vim tlib.txt /*autoload\/tlib\/url.vim* +autoload/tlib/var.vim tlib.txt /*autoload\/tlib\/var.vim* +autoload/tlib/vcs.vim tlib.txt /*autoload\/tlib\/vcs.vim* +autoload/tlib/vim.vim tlib.txt /*autoload\/tlib\/vim.vim* +autoload/tlib/win.vim tlib.txt /*autoload\/tlib\/win.vim* +g:tlib#Filter_glob#char tlib.txt /*g:tlib#Filter_glob#char* +g:tlib#Filter_glob#seq tlib.txt /*g:tlib#Filter_glob#seq* +g:tlib#cache#dont_purge tlib.txt /*g:tlib#cache#dont_purge* +g:tlib#cache#max_filename tlib.txt /*g:tlib#cache#max_filename* +g:tlib#cache#purge_days tlib.txt /*g:tlib#cache#purge_days* +g:tlib#cache#purge_every_days tlib.txt /*g:tlib#cache#purge_every_days* +g:tlib#cache#run_script tlib.txt /*g:tlib#cache#run_script* +g:tlib#cache#script_encoding tlib.txt /*g:tlib#cache#script_encoding* +g:tlib#cache#verbosity tlib.txt /*g:tlib#cache#verbosity* +g:tlib#dir#sep tlib.txt /*g:tlib#dir#sep* +g:tlib#file#drop tlib.txt /*g:tlib#file#drop* +g:tlib#input#filename_max_width tlib.txt /*g:tlib#input#filename_max_width* +g:tlib#input#filename_padding_r tlib.txt /*g:tlib#input#filename_padding_r* +g:tlib#input#filter_mode tlib.txt /*g:tlib#input#filter_mode* +g:tlib#input#format_filename tlib.txt /*g:tlib#input#format_filename* +g:tlib#input#higroup tlib.txt /*g:tlib#input#higroup* +g:tlib#input#keyagents_InputList_s tlib.txt /*g:tlib#input#keyagents_InputList_s* +g:tlib#input#livesearch_threshold tlib.txt /*g:tlib#input#livesearch_threshold* +g:tlib#input#numeric_chars tlib.txt /*g:tlib#input#numeric_chars* +g:tlib#input#sortprefs_threshold tlib.txt /*g:tlib#input#sortprefs_threshold* +g:tlib#input#use_popup tlib.txt /*g:tlib#input#use_popup* +g:tlib#input#user_shortcuts tlib.txt /*g:tlib#input#user_shortcuts* +g:tlib#scratch#hidden tlib.txt /*g:tlib#scratch#hidden* +g:tlib#sys#check_cygpath tlib.txt /*g:tlib#sys#check_cygpath* +g:tlib#sys#cygwin_expr tlib.txt /*g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_path_rx tlib.txt /*g:tlib#sys#cygwin_path_rx* +g:tlib#sys#special_protocols tlib.txt /*g:tlib#sys#special_protocols* +g:tlib#sys#special_suffixes tlib.txt /*g:tlib#sys#special_suffixes* +g:tlib#sys#system_browser tlib.txt /*g:tlib#sys#system_browser* +g:tlib#sys#system_rx tlib.txt /*g:tlib#sys#system_rx* +g:tlib#trace#backtrace tlib.txt /*g:tlib#trace#backtrace* +g:tlib#trace#printer tlib.txt /*g:tlib#trace#printer* +g:tlib#vcs#check tlib.txt /*g:tlib#vcs#check* +g:tlib#vcs#def tlib.txt /*g:tlib#vcs#def* +g:tlib#vcs#executables tlib.txt /*g:tlib#vcs#executables* +g:tlib#vim#simalt_maximize tlib.txt /*g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_restore tlib.txt /*g:tlib#vim#simalt_restore* +g:tlib#vim#use_vimtweak tlib.txt /*g:tlib#vim#use_vimtweak* +g:tlib#vim#use_wmctrl tlib.txt /*g:tlib#vim#use_wmctrl* +g:tlib_cache tlib.txt /*g:tlib_cache* +g:tlib_inputlist_filename_indicators tlib.txt /*g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_max_cols tlib.txt /*g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_lines tlib.txt /*g:tlib_inputlist_max_lines* +g:tlib_inputlist_pct tlib.txt /*g:tlib_inputlist_pct* +g:tlib_inputlist_shortmessage tlib.txt /*g:tlib_inputlist_shortmessage* +g:tlib_inputlist_width_filename tlib.txt /*g:tlib_inputlist_width_filename* +g:tlib_persistent tlib.txt /*g:tlib_persistent* +g:tlib_pick_last_item tlib.txt /*g:tlib_pick_last_item* +g:tlib_scratch_pos tlib.txt /*g:tlib_scratch_pos* +g:tlib_scroll_lines tlib.txt /*g:tlib_scroll_lines* +g:tlib_tag_substitute tlib.txt /*g:tlib_tag_substitute* +g:tlib_tags_extra tlib.txt /*g:tlib_tags_extra* +g:tlib_viewline_position tlib.txt /*g:tlib_viewline_position* +plugin/02tlib.vim tlib.txt /*plugin\/02tlib.vim* +standard-paragraph tlib.txt /*standard-paragraph* +tlib#Filter_cnf#New() tlib.txt /*tlib#Filter_cnf#New()* +tlib#Filter_cnfd#New() tlib.txt /*tlib#Filter_cnfd#New()* +tlib#Filter_fuzzy#New() tlib.txt /*tlib#Filter_fuzzy#New()* +tlib#Filter_glob#New() tlib.txt /*tlib#Filter_glob#New()* +tlib#Object#New() tlib.txt /*tlib#Object#New()* +tlib#agent#GotoLine() tlib.txt /*tlib#agent#GotoLine()* +tlib#agent#NewItem() tlib.txt /*tlib#agent#NewItem()* +tlib#agent#Suspend() tlib.txt /*tlib#agent#Suspend()* +tlib#agent#SuspendToParentWindow() tlib.txt /*tlib#agent#SuspendToParentWindow()* +tlib#arg#Ex() tlib.txt /*tlib#arg#Ex()* +tlib#arg#Get() tlib.txt /*tlib#arg#Get()* +tlib#arg#GetOpts() tlib.txt /*tlib#arg#GetOpts()* +tlib#arg#Let() tlib.txt /*tlib#arg#Let()* +tlib#assert#Disable() tlib.txt /*tlib#assert#Disable()* +tlib#assert#Enable() tlib.txt /*tlib#assert#Enable()* +tlib#buffer#BufDo() tlib.txt /*tlib#buffer#BufDo()* +tlib#buffer#DeleteRange() tlib.txt /*tlib#buffer#DeleteRange()* +tlib#buffer#Eval() tlib.txt /*tlib#buffer#Eval()* +tlib#buffer#GetList() tlib.txt /*tlib#buffer#GetList()* +tlib#buffer#InsertText() tlib.txt /*tlib#buffer#InsertText()* +tlib#buffer#KeepCursorPosition() tlib.txt /*tlib#buffer#KeepCursorPosition()* +tlib#buffer#ReplaceRange() tlib.txt /*tlib#buffer#ReplaceRange()* +tlib#buffer#ScratchEnd() tlib.txt /*tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchStart() tlib.txt /*tlib#buffer#ScratchStart()* +tlib#buffer#Set() tlib.txt /*tlib#buffer#Set()* +tlib#buffer#ViewLine() tlib.txt /*tlib#buffer#ViewLine()* +tlib#cache#Dir() tlib.txt /*tlib#cache#Dir()* +tlib#cache#EncodedFilename() tlib.txt /*tlib#cache#EncodedFilename()* +tlib#cache#MaybePurge() tlib.txt /*tlib#cache#MaybePurge()* +tlib#cache#Purge() tlib.txt /*tlib#cache#Purge()* +tlib#cache#Value() tlib.txt /*tlib#cache#Value()* +tlib#char#Get() tlib.txt /*tlib#char#Get()* +tlib#cmd#BrowseOutput() tlib.txt /*tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutputWithCallback() tlib.txt /*tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#Time() tlib.txt /*tlib#cmd#Time()* +tlib#cmd#UseVertical() tlib.txt /*tlib#cmd#UseVertical()* +tlib#comments#Comments() tlib.txt /*tlib#comments#Comments()* +tlib#date#SecondsSince1970() tlib.txt /*tlib#date#SecondsSince1970()* +tlib#dir#CanonicName() tlib.txt /*tlib#dir#CanonicName()* +tlib#dir#Ensure() tlib.txt /*tlib#dir#Ensure()* +tlib#dir#MyRuntime() tlib.txt /*tlib#dir#MyRuntime()* +tlib#dir#NativeName() tlib.txt /*tlib#dir#NativeName()* +tlib#dir#PlainName() tlib.txt /*tlib#dir#PlainName()* +tlib#file#Edit() tlib.txt /*tlib#file#Edit()* +tlib#file#Join() tlib.txt /*tlib#file#Join()* +tlib#file#Relative() tlib.txt /*tlib#file#Relative()* +tlib#file#Split() tlib.txt /*tlib#file#Split()* +tlib#hook#Run() tlib.txt /*tlib#hook#Run()* +tlib#input#CommandSelect() tlib.txt /*tlib#input#CommandSelect()* +tlib#input#Edit() tlib.txt /*tlib#input#Edit()* +tlib#input#EditList() tlib.txt /*tlib#input#EditList()* +tlib#input#List() tlib.txt /*tlib#input#List()* +tlib#input#ListD() tlib.txt /*tlib#input#ListD()* +tlib#input#ListW() tlib.txt /*tlib#input#ListW()* +tlib#list#All() tlib.txt /*tlib#list#All()* +tlib#list#Any() tlib.txt /*tlib#list#Any()* +tlib#list#Compact() tlib.txt /*tlib#list#Compact()* +tlib#list#Find() tlib.txt /*tlib#list#Find()* +tlib#list#FindAll() tlib.txt /*tlib#list#FindAll()* +tlib#list#Flatten() tlib.txt /*tlib#list#Flatten()* +tlib#list#Inject() tlib.txt /*tlib#list#Inject()* +tlib#list#Remove() tlib.txt /*tlib#list#Remove()* +tlib#list#RemoveAll() tlib.txt /*tlib#list#RemoveAll()* +tlib#list#Zip() tlib.txt /*tlib#list#Zip()* +tlib#map#PumAccept() tlib.txt /*tlib#map#PumAccept()* +tlib#normal#WithRegister() tlib.txt /*tlib#normal#WithRegister()* +tlib#notify#Echo() tlib.txt /*tlib#notify#Echo()* +tlib#notify#TrimMessage() tlib.txt /*tlib#notify#TrimMessage()* +tlib#paragraph#GetMetric() tlib.txt /*tlib#paragraph#GetMetric()* +tlib#paragraph#Move() tlib.txt /*tlib#paragraph#Move()* +tlib#persistent#Dir() tlib.txt /*tlib#persistent#Dir()* +tlib#persistent#EncodedFilename() tlib.txt /*tlib#persistent#EncodedFilename()* +tlib#progressbar#Init() tlib.txt /*tlib#progressbar#Init()* +tlib#rx#Escape() tlib.txt /*tlib#rx#Escape()* +tlib#rx#EscapeReplace() tlib.txt /*tlib#rx#EscapeReplace()* +tlib#scratch#CloseScratch() tlib.txt /*tlib#scratch#CloseScratch()* +tlib#scratch#UseScratch() tlib.txt /*tlib#scratch#UseScratch()* +tlib#selection#GetSelection() tlib.txt /*tlib#selection#GetSelection()* +tlib#signs#ClearAll() tlib.txt /*tlib#signs#ClearAll()* +tlib#signs#ClearBuffer() tlib.txt /*tlib#signs#ClearBuffer()* +tlib#signs#Mark() tlib.txt /*tlib#signs#Mark()* +tlib#string#Format() tlib.txt /*tlib#string#Format()* +tlib#string#Printf1() tlib.txt /*tlib#string#Printf1()* +tlib#string#RemoveBackslashes() tlib.txt /*tlib#string#RemoveBackslashes()* +tlib#sys#IsSpecial() tlib.txt /*tlib#sys#IsSpecial()* +tlib#sys#MaybeUseCygpath() tlib.txt /*tlib#sys#MaybeUseCygpath()* +tlib#sys#Open() tlib.txt /*tlib#sys#Open()* +tlib#sys#OpenWithSystemViewer() tlib.txt /*tlib#sys#OpenWithSystemViewer()* +tlib#tab#BufMap() tlib.txt /*tlib#tab#BufMap()* +tlib#tab#TabWinNr() tlib.txt /*tlib#tab#TabWinNr()* +tlib#tag#Collect() tlib.txt /*tlib#tag#Collect()* +tlib#tag#Retrieve() tlib.txt /*tlib#tag#Retrieve()* +tlib#trace#Disable() tlib.txt /*tlib#trace#Disable()* +tlib#trace#Enable() tlib.txt /*tlib#trace#Enable()* +tlib#trace#Print() tlib.txt /*tlib#trace#Print()* +tlib#trace#Printer_echom() tlib.txt /*tlib#trace#Printer_echom()* +tlib#trace#Set() tlib.txt /*tlib#trace#Set()* +tlib#type#Disable() tlib.txt /*tlib#type#Disable()* +tlib#type#Enable() tlib.txt /*tlib#type#Enable()* +tlib#url#Decode() tlib.txt /*tlib#url#Decode()* +tlib#url#DecodeChar() tlib.txt /*tlib#url#DecodeChar()* +tlib#url#Encode() tlib.txt /*tlib#url#Encode()* +tlib#url#EncodeChar() tlib.txt /*tlib#url#EncodeChar()* +tlib#var#EGet() tlib.txt /*tlib#var#EGet()* +tlib#var#Get() tlib.txt /*tlib#var#Get()* +tlib#var#Let() tlib.txt /*tlib#var#Let()* +tlib#var#List() tlib.txt /*tlib#var#List()* +tlib#vcs#Diff() tlib.txt /*tlib#vcs#Diff()* +tlib#vcs#Ls() tlib.txt /*tlib#vcs#Ls()* +tlib#vim#Maximize() tlib.txt /*tlib#vim#Maximize()* +tlib#vim#RestoreWindow() tlib.txt /*tlib#vim#RestoreWindow()* +tlib#win#Set() tlib.txt /*tlib#win#Set()* +tlib#win#SetById() tlib.txt /*tlib#win#SetById()* +tlib.txt tlib.txt /*tlib.txt* +v_sp tlib.txt /*v_sp* diff --git a/sources_non_forked/tlib/doc/tlib.txt b/sources_non_forked/tlib/doc/tlib.txt new file mode 100644 index 00000000..648181d9 --- /dev/null +++ b/sources_non_forked/tlib/doc/tlib.txt @@ -0,0 +1,1610 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +======================================================================== +Contents~ + + :TLet ................................... |:TLet| + :TScratch ............................... |:TScratch| + :TVarArg ................................ |:TVarArg| + :TBrowseOutput .......................... |:TBrowseOutput| + :TBrowseScriptnames ..................... |:TBrowseScriptnames| + :Texecqfl ............................... |:Texecqfl| + :Texecloc ............................... |:Texecloc| + :Tlibtrace .............................. |:Tlibtrace| + :Tlibtraceset ........................... |:Tlibtraceset| + :Tbrowseqfl ............................. |:Tbrowseqfl| + :Tbrowseloc ............................. |:Tbrowseloc| + tlib#Filter_cnf#New ..................... |tlib#Filter_cnf#New()| + tlib#Filter_cnfd#New .................... |tlib#Filter_cnfd#New()| + tlib#Filter_fuzzy#New ................... |tlib#Filter_fuzzy#New()| + g:tlib#Filter_glob#seq .................. |g:tlib#Filter_glob#seq| + g:tlib#Filter_glob#char ................. |g:tlib#Filter_glob#char| + tlib#Filter_glob#New .................... |tlib#Filter_glob#New()| + tlib#Object#New ......................... |tlib#Object#New()| + g:tlib_inputlist_pct .................... |g:tlib_inputlist_pct| + g:tlib_inputlist_max_lines .............. |g:tlib_inputlist_max_lines| + g:tlib_inputlist_max_cols ............... |g:tlib_inputlist_max_cols| + g:tlib_inputlist_width_filename ......... |g:tlib_inputlist_width_filename| + g:tlib_inputlist_filename_indicators .... |g:tlib_inputlist_filename_indicators| + g:tlib_inputlist_shortmessage ........... |g:tlib_inputlist_shortmessage| + g:tlib_scroll_lines ..................... |g:tlib_scroll_lines| + tlib#agent#SuspendToParentWindow ........ |tlib#agent#SuspendToParentWindow()| + tlib#agent#Suspend ...................... |tlib#agent#Suspend()| + tlib#agent#NewItem ...................... |tlib#agent#NewItem()| + tlib#agent#GotoLine ..................... |tlib#agent#GotoLine()| + tlib#arg#Get ............................ |tlib#arg#Get()| + tlib#arg#Let ............................ |tlib#arg#Let()| + tlib#arg#GetOpts ........................ |tlib#arg#GetOpts()| + tlib#arg#Ex ............................. |tlib#arg#Ex()| + tlib#assert#Enable ...................... |tlib#assert#Enable()| + tlib#assert#Disable ..................... |tlib#assert#Disable()| + g:tlib_viewline_position ................ |g:tlib_viewline_position| + tlib#buffer#Set ......................... |tlib#buffer#Set()| + tlib#buffer#Eval ........................ |tlib#buffer#Eval()| + tlib#buffer#GetList ..................... |tlib#buffer#GetList()| + tlib#buffer#ViewLine .................... |tlib#buffer#ViewLine()| + tlib#buffer#DeleteRange ................. |tlib#buffer#DeleteRange()| + tlib#buffer#ReplaceRange ................ |tlib#buffer#ReplaceRange()| + tlib#buffer#ScratchStart ................ |tlib#buffer#ScratchStart()| + tlib#buffer#ScratchEnd .................. |tlib#buffer#ScratchEnd()| + tlib#buffer#BufDo ....................... |tlib#buffer#BufDo()| + tlib#buffer#InsertText .................. |tlib#buffer#InsertText()| + tlib#buffer#KeepCursorPosition .......... |tlib#buffer#KeepCursorPosition()| + g:tlib_cache ............................ |g:tlib_cache| + g:tlib#cache#purge_days ................. |g:tlib#cache#purge_days| + g:tlib#cache#purge_every_days ........... |g:tlib#cache#purge_every_days| + g:tlib#cache#script_encoding ............ |g:tlib#cache#script_encoding| + g:tlib#cache#run_script ................. |g:tlib#cache#run_script| + g:tlib#cache#verbosity .................. |g:tlib#cache#verbosity| + g:tlib#cache#dont_purge ................. |g:tlib#cache#dont_purge| + g:tlib#cache#max_filename ............... |g:tlib#cache#max_filename| + tlib#cache#Dir .......................... |tlib#cache#Dir()| + tlib#cache#EncodedFilename .............. |tlib#cache#EncodedFilename()| + tlib#cache#Value ........................ |tlib#cache#Value()| + tlib#cache#MaybePurge ................... |tlib#cache#MaybePurge()| + tlib#cache#Purge ........................ |tlib#cache#Purge()| + tlib#char#Get ........................... |tlib#char#Get()| + tlib#cmd#BrowseOutput ................... |tlib#cmd#BrowseOutput()| + tlib#cmd#BrowseOutputWithCallback ....... |tlib#cmd#BrowseOutputWithCallback()| + tlib#cmd#UseVertical .................... |tlib#cmd#UseVertical()| + tlib#cmd#Time ........................... |tlib#cmd#Time()| + tlib#comments#Comments .................. |tlib#comments#Comments()| + tlib#date#SecondsSince1970 .............. |tlib#date#SecondsSince1970()| + g:tlib#dir#sep .......................... |g:tlib#dir#sep| + tlib#dir#CanonicName .................... |tlib#dir#CanonicName()| + tlib#dir#NativeName ..................... |tlib#dir#NativeName()| + tlib#dir#PlainName ...................... |tlib#dir#PlainName()| + tlib#dir#Ensure ......................... |tlib#dir#Ensure()| + tlib#dir#MyRuntime ...................... |tlib#dir#MyRuntime()| + g:tlib#file#drop ........................ |g:tlib#file#drop| + tlib#file#Split ......................... |tlib#file#Split()| + tlib#file#Join .......................... |tlib#file#Join()| + tlib#file#Relative ...................... |tlib#file#Relative()| + tlib#file#Edit .......................... |tlib#file#Edit()| + tlib#hook#Run ........................... |tlib#hook#Run()| + g:tlib#input#sortprefs_threshold ........ |g:tlib#input#sortprefs_threshold| + g:tlib#input#livesearch_threshold ....... |g:tlib#input#livesearch_threshold| + g:tlib#input#filter_mode ................ |g:tlib#input#filter_mode| + g:tlib#input#higroup .................... |g:tlib#input#higroup| + g:tlib_pick_last_item ................... |g:tlib_pick_last_item| + g:tlib#input#numeric_chars .............. |g:tlib#input#numeric_chars| + g:tlib#input#keyagents_InputList_s ...... |g:tlib#input#keyagents_InputList_s| + g:tlib#input#user_shortcuts ............. |g:tlib#input#user_shortcuts| + g:tlib#input#use_popup .................. |g:tlib#input#use_popup| + g:tlib#input#format_filename ............ |g:tlib#input#format_filename| + g:tlib#input#filename_padding_r ......... |g:tlib#input#filename_padding_r| + g:tlib#input#filename_max_width ......... |g:tlib#input#filename_max_width| + tlib#input#List ......................... |tlib#input#List()| + tlib#input#ListD ........................ |tlib#input#ListD()| + tlib#input#ListW ........................ |tlib#input#ListW()| + tlib#input#EditList ..................... |tlib#input#EditList()| + tlib#input#CommandSelect ................ |tlib#input#CommandSelect()| + tlib#input#Edit ......................... |tlib#input#Edit()| + tlib#list#Inject ........................ |tlib#list#Inject()| + tlib#list#Compact ....................... |tlib#list#Compact()| + tlib#list#Flatten ....................... |tlib#list#Flatten()| + tlib#list#FindAll ....................... |tlib#list#FindAll()| + tlib#list#Find .......................... |tlib#list#Find()| + tlib#list#Any ........................... |tlib#list#Any()| + tlib#list#All ........................... |tlib#list#All()| + tlib#list#Remove ........................ |tlib#list#Remove()| + tlib#list#RemoveAll ..................... |tlib#list#RemoveAll()| + tlib#list#Zip ........................... |tlib#list#Zip()| + tlib#map#PumAccept ...................... |tlib#map#PumAccept()| + tlib#normal#WithRegister ................ |tlib#normal#WithRegister()| + tlib#notify#Echo ........................ |tlib#notify#Echo()| + tlib#notify#TrimMessage ................. |tlib#notify#TrimMessage()| + tlib#paragraph#GetMetric ................ |tlib#paragraph#GetMetric()| + tlib#paragraph#Move ..................... |tlib#paragraph#Move()| + g:tlib_persistent ....................... |g:tlib_persistent| + tlib#persistent#Dir ..................... |tlib#persistent#Dir()| + tlib#persistent#EncodedFilename ......... |tlib#persistent#EncodedFilename()| + tlib#progressbar#Init ................... |tlib#progressbar#Init()| + tlib#rx#Escape .......................... |tlib#rx#Escape()| + tlib#rx#EscapeReplace ................... |tlib#rx#EscapeReplace()| + g:tlib_scratch_pos ...................... |g:tlib_scratch_pos| + g:tlib#scratch#hidden ................... |g:tlib#scratch#hidden| + tlib#scratch#UseScratch ................. |tlib#scratch#UseScratch()| + tlib#scratch#CloseScratch ............... |tlib#scratch#CloseScratch()| + tlib#selection#GetSelection ............. |tlib#selection#GetSelection()| + tlib#signs#ClearAll ..................... |tlib#signs#ClearAll()| + tlib#signs#ClearBuffer .................. |tlib#signs#ClearBuffer()| + tlib#signs#Mark ......................... |tlib#signs#Mark()| + tlib#string#RemoveBackslashes ........... |tlib#string#RemoveBackslashes()| + tlib#string#Format ...................... |tlib#string#Format()| + tlib#string#Printf1 ..................... |tlib#string#Printf1()| + g:tlib#sys#special_protocols ............ |g:tlib#sys#special_protocols| + g:tlib#sys#special_suffixes ............. |g:tlib#sys#special_suffixes| + g:tlib#sys#system_rx .................... |g:tlib#sys#system_rx| + g:tlib#sys#system_browser ............... |g:tlib#sys#system_browser| + g:tlib#sys#check_cygpath ................ |g:tlib#sys#check_cygpath| + g:tlib#sys#cygwin_path_rx ............... |g:tlib#sys#cygwin_path_rx| + g:tlib#sys#cygwin_expr .................. |g:tlib#sys#cygwin_expr| + tlib#sys#MaybeUseCygpath ................ |tlib#sys#MaybeUseCygpath()| + tlib#sys#IsSpecial ...................... |tlib#sys#IsSpecial()| + tlib#sys#Open ........................... |tlib#sys#Open()| + tlib#sys#OpenWithSystemViewer ........... |tlib#sys#OpenWithSystemViewer()| + tlib#tab#BufMap ......................... |tlib#tab#BufMap()| + tlib#tab#TabWinNr ....................... |tlib#tab#TabWinNr()| + g:tlib_tags_extra ....................... |g:tlib_tags_extra| + g:tlib_tag_substitute ................... |g:tlib_tag_substitute| + tlib#tag#Retrieve ....................... |tlib#tag#Retrieve()| + tlib#tag#Collect ........................ |tlib#tag#Collect()| + tlib#textobjects#StandardParagraph ...... |standard-paragraph| + v_sp .................................... |v_sp| + g:tlib#trace#backtrace .................. |g:tlib#trace#backtrace| + g:tlib#trace#printer .................... |g:tlib#trace#printer| + tlib#trace#Printer_echom ................ |tlib#trace#Printer_echom()| + tlib#trace#Set .......................... |tlib#trace#Set()| + tlib#trace#Print ........................ |tlib#trace#Print()| + tlib#trace#Enable ....................... |tlib#trace#Enable()| + tlib#trace#Disable ...................... |tlib#trace#Disable()| + tlib#type#Enable ........................ |tlib#type#Enable()| + tlib#type#Disable ....................... |tlib#type#Disable()| + tlib#url#Decode ......................... |tlib#url#Decode()| + tlib#url#DecodeChar ..................... |tlib#url#DecodeChar()| + tlib#url#EncodeChar ..................... |tlib#url#EncodeChar()| + tlib#url#Encode ......................... |tlib#url#Encode()| + tlib#var#Let ............................ |tlib#var#Let()| + tlib#var#EGet ........................... |tlib#var#EGet()| + tlib#var#Get ............................ |tlib#var#Get()| + tlib#var#List ........................... |tlib#var#List()| + g:tlib#vcs#def .......................... |g:tlib#vcs#def| + g:tlib#vcs#executables .................. |g:tlib#vcs#executables| + g:tlib#vcs#check ........................ |g:tlib#vcs#check| + tlib#vcs#Ls ............................. |tlib#vcs#Ls()| + tlib#vcs#Diff ........................... |tlib#vcs#Diff()| + g:tlib#vim#simalt_maximize .............. |g:tlib#vim#simalt_maximize| + g:tlib#vim#simalt_restore ............... |g:tlib#vim#simalt_restore| + g:tlib#vim#use_vimtweak ................. |g:tlib#vim#use_vimtweak| + tlib#vim#Maximize ....................... |tlib#vim#Maximize()| + tlib#vim#RestoreWindow .................. |tlib#vim#RestoreWindow()| + g:tlib#vim#use_wmctrl ................... |g:tlib#vim#use_wmctrl| + tlib#win#Set ............................ |tlib#win#Set()| + tlib#win#SetById ........................ |tlib#win#SetById()| + + +------------------------------------------------------------------------ + *plugin/02tlib.vim* + *:TLet* +:TLet VAR = VALUE + Set a variable only if it doesn't already exist. + EXAMPLES: > + TLet foo = 1 + TLet foo = 2 + echo foo + => 1 +< + + *:TScratch* +:TScratch + Open a scratch buffer (a buffer without a file). + TScratch ... use split window + TScratch! ... use the whole frame + This command takes an (inner) dictionary as optional argument. + EXAMPLES: > + TScratch 'scratch': '__FOO__' + => Open a scratch buffer named __FOO__ +< + + *:TVarArg* +:TVarArg VAR1, [VAR2, DEFAULT2] ... + A convenience wrapper for |tlib#arg#Let|. + EXAMPLES: > + function! Foo(...) + TVarArg ['a', 1], 'b' + echo 'a='. a + echo 'b='. b + endf +< + + *:TBrowseOutput* +:TBrowseOutput COMMAND + Ever wondered how to efficiently browse the output of a command + without redirecting it to a file? This command takes a command as + argument and presents the output via |tlib#input#List()| so that you + can easily search for a keyword (e.g. the name of a variable or + function) and the like. + + If you press enter, the selected line will be copied to the command + line. Press ESC to cancel browsing. + + EXAMPLES: > + TBrowseOutput 20verb TeaseTheCulprit +< + + *:TBrowseScriptnames* +:TBrowseScriptnames + List all sourced script names (the output of ':scriptnames'). + + When you press enter, the selected script will be opened in the current + window. Press ESC to cancel. + + EXAMPLES: > + TBrowseScriptnames +< + + *:Texecqfl* +:Texecqfl CMD + Run CMD and display the quickfix list. + + *:Texecloc* +:Texecloc CMD + Run CMD and display the quickfix list. + + *:Tlibtrace* +:Tlibtrace GUARD, VAR1, VAR2... + Do nothing unless |tlib#trace#Enable()| was called. + + When |:Tlibtraceset| or |tlib#trace#Enable()| were called: + + If GUARD is a number that evaluates to true or if it is a string that + matches a |regexp|, which was added using Tlibtrace! (with '!'), + display the values of VAR1, VAR2 ... + + *:Tlibtraceset* +:Tlibtraceset + :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... + If |tlib#trace#Enable()| was called: With the optional , users + can add and remove GUARDs (actually a |regexp|) that should be traced. + + If no `+` or `-` is prepended, assume `+`. + + With the optional bang '!', reset any options. + + *:Tbrowseqfl* +:Tlibtype val, 'type', ... + Browse the current |quickfix| list. + + *:Tbrowseloc* +:Tbrowseloc + Browse the current |location-list|. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnf.vim* + *tlib#Filter_cnf#New()* +tlib#Filter_cnf#New(...) + The search pattern for |tlib#input#List()| is in conjunctive normal + form: (P1 OR P2 ...) AND (P3 OR P4 ...) ... + The pattern is a '/\V' very no-'/magic' regexp pattern. + + Pressing joins two patterns with AND. + Pressing | joins two patterns with OR. + I.e. In order to get "lala AND (foo OR bar)", you type + "lala foo|bar". + + This is also the base class for other filters. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_cnfd.vim* + *tlib#Filter_cnfd#New()* +tlib#Filter_cnfd#New(...) + The same as |tlib#Filter_cnf#New()| but a dot is expanded to '\.\{-}'. + As a consequence, patterns cannot match dots. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_fuzzy.vim* + *tlib#Filter_fuzzy#New()* +tlib#Filter_fuzzy#New(...) + Support for "fuzzy" pattern matching in |tlib#input#List()|. + Patterns are interpreted as if characters were connected with '.\{-}'. + + In "fuzzy" mode, the pretty printing of filenames is disabled. + + +------------------------------------------------------------------------ + *autoload/tlib/Filter_glob.vim* + *g:tlib#Filter_glob#seq* +g:tlib#Filter_glob#seq (default: '*') + A character that should be expanded to '\.\{-}'. + + *g:tlib#Filter_glob#char* +g:tlib#Filter_glob#char (default: '?') + A character that should be expanded to '\.\?'. + + *tlib#Filter_glob#New()* +tlib#Filter_glob#New(...) + The same as |tlib#Filter_cnf#New()| but a a customizable character + |see tlib#Filter_glob#seq| is expanded to '\.\{-}' and + |g:tlib#Filter_glob#char| is expanded to '\.'. + The pattern is a '/\V' very no-'/magic' regexp pattern. + + +------------------------------------------------------------------------ + *autoload/tlib/Object.vim* +Provides a prototype plus some OO-like methods. + + *tlib#Object#New()* +tlib#Object#New(?fields={}) + This function creates a prototype that provides some kind of + inheritance mechanism and a way to call parent/super methods. + + The usage demonstrated in the following example works best when every + class/prototype is defined in a file of its own. + + The reason for why there is a dedicated constructor function is that + this layout facilitates the use of templates and that methods are + hidden from the user. Other solutions are possible. + + EXAMPLES: > + let s:prototype = tlib#Object#New({ + \ '_class': ['FooBar'], + \ 'foo': 1, + \ 'bar': 2, + \ }) + " Constructor + function! FooBar(...) + let object = s:prototype.New(a:0 >= 1 ? a:1 : {}) + return object + endf + function! s:prototype.babble() { + echo "I think, therefore I am ". (self.foo * self.bar) ." months old." + } + +< This could now be used like this: > + let myfoo = FooBar({'foo': 3}) + call myfoo.babble() + => I think, therefore I am 6 months old. + echo myfoo.IsA('FooBar') + => 1 + echo myfoo.IsA('object') + => 1 + echo myfoo.IsA('Foo') + => 0 + echo myfoo.RespondTo('babble') + => 1 + echo myfoo.RespondTo('speak') + => 0 +< + + +------------------------------------------------------------------------ + *autoload/tlib/World.vim* +A prototype used by |tlib#input#List|. +Inherits from |tlib#Object#New|. + + *g:tlib_inputlist_pct* +g:tlib_inputlist_pct (default: 50) + Size of the input list window (in percent) from the main size (of &lines). + See |tlib#input#List()|. + + *g:tlib_inputlist_max_lines* +g:tlib_inputlist_max_lines (default: -1) + Max height for a horizontal list. + + *g:tlib_inputlist_max_cols* +g:tlib_inputlist_max_cols (default: -1) + Max width for a vertical list. + + *g:tlib_inputlist_width_filename* +g:tlib_inputlist_width_filename (default: '&columns / 3') + Size of filename columns when listing filenames. + See |tlib#input#List()|. + + *g:tlib_inputlist_filename_indicators* +g:tlib_inputlist_filename_indicators (default: 0) + If true, |tlib#input#List()| will show some indicators about the + status of a filename (e.g. buflisted(), bufloaded() etc.). + This is disabled by default because vim checks also for the file on + disk when doing this. + + *g:tlib_inputlist_shortmessage* +g:tlib_inputlist_shortmessage (default: 0) + If not null, display only a short info about the filter. + + +------------------------------------------------------------------------ + *autoload/tlib/agent.vim* +Various agents for use as key handlers in tlib#input#List() + + *g:tlib_scroll_lines* +g:tlib_scroll_lines (default: 10) + Number of items to move when pressing in the input list window. + + *tlib#agent#SuspendToParentWindow()* +tlib#agent#SuspendToParentWindow(world, selected) + Suspend (see |tlib#agent#Suspend|) the input loop and jump back to the + original position in the parent window. + + *tlib#agent#Suspend()* +tlib#agent#Suspend(world, selected) + Suspend lets you temporarily leave the input loop of + |tlib#input#List|. You can resume editing the list by pressing , + . , or in the suspended window. + and will immediatly select the item under the cursor. + < will select the item but the window will remain opened. + + *tlib#agent#NewItem()* +tlib#agent#NewItem(world, selected) + Insert a new item below the current one. + + *tlib#agent#GotoLine()* +tlib#agent#GotoLine(world, selected) + If not called from the scratch, we assume/guess that we don't have to + suspend the input-evaluation loop. + + +------------------------------------------------------------------------ + *autoload/tlib/arg.vim* + *tlib#arg#Get()* +tlib#arg#Get(n, var, ?default="", ?test='') + Set a positional argument from a variable argument list. + See tlib#string#RemoveBackslashes() for an example. + + *tlib#arg#Let()* +tlib#arg#Let(list, ?default='') + Set a positional arguments from a variable argument list. + See tlib#input#List() for an example. + + *tlib#arg#GetOpts()* +tlib#arg#GetOpts(args, ?def={}) + Convert a list of strings of command-line arguments into a dictonary. + + The main use case is to pass [], i.e. the command-line + arguments of a command as list, from a command definition to this + function. + + Example: + ['-h'] + => If def contains a 'help' key, invoke |:help| on its value. + + ['-ab', '--foo', '--bar=BAR', 'bla', bla'] + => {'a': 1, 'b': 1, 'foo': 1, 'bar': 'BAR', '__rest__': ['bla', 'bla']} + + ['-ab', '--', '--foo', '--bar=BAR'] + => {'a': 1, 'b': 1, '__rest__': ['--foo', '--bar=BAR']} + + *tlib#arg#Ex()* +tlib#arg#Ex(arg, ?chars='%#! ') + Escape some characters in a string. + + Use |fnamescape()| if available. + + EXAMPLES: > + exec 'edit '. tlib#arg#Ex('foo%#bar.txt') +< + + +------------------------------------------------------------------------ + *autoload/tlib/assert.vim* + *tlib#assert#Enable()* +tlib#assert#Enable() + Enable tracing via |:Tlibassert|. + + *tlib#assert#Disable()* +tlib#assert#Disable() + Disable tracing via |:Tlibassert|. + + +------------------------------------------------------------------------ + *autoload/tlib/buffer.vim* + *g:tlib_viewline_position* +g:tlib_viewline_position (default: 'zz') + Where to display the line when using |tlib#buffer#ViewLine|. + For possible values for position see |scroll-cursor|. + + *tlib#buffer#Set()* +tlib#buffer#Set(buffer) + Set the buffer to buffer and return a command as string that can be + evaluated by |:execute| in order to restore the original view. + + *tlib#buffer#Eval()* +tlib#buffer#Eval(buffer, code) + Evaluate CODE in BUFFER. + + EXAMPLES: > + call tlib#buffer#Eval('foo.txt', 'echo b:bar') +< + + *tlib#buffer#GetList()* +tlib#buffer#GetList(?show_hidden=0, ?show_number=0, " ?order='bufnr') + Possible values for the "order" argument: + bufnr :: Default behaviour + mru :: Sort buffers according to most recent use + basename :: Sort by the file's basename (last component) + + NOTE: MRU order works on second invocation only. If you want to always + use MRU order, call tlib#buffer#EnableMRU() in your ~/.vimrc file. + + *tlib#buffer#ViewLine()* +tlib#buffer#ViewLine(line, ?position='z') + line is either a number or a string that begins with a number. + For possible values for position see |scroll-cursor|. + See also |g:tlib_viewline_position|. + + *tlib#buffer#DeleteRange()* +tlib#buffer#DeleteRange(line1, line2) + Delete the lines in the current buffer. Wrapper for |:delete|. + + *tlib#buffer#ReplaceRange()* +tlib#buffer#ReplaceRange(line1, line2, lines) + Replace a range of lines. + + *tlib#buffer#ScratchStart()* +tlib#buffer#ScratchStart() + Initialize some scratch area at the bottom of the current buffer. + + *tlib#buffer#ScratchEnd()* +tlib#buffer#ScratchEnd() + Remove the in-buffer scratch area. + + *tlib#buffer#BufDo()* +tlib#buffer#BufDo(exec) + Run exec on all buffers via bufdo and return to the original buffer. + + *tlib#buffer#InsertText()* +tlib#buffer#InsertText(text, keyargs) + Keyargs: + 'shift': 0|N + 'col': col('.')|N + 'lineno': line('.')|N + 'indent': 0|1 + 'pos': 'e'|'s' ... Where to locate the cursor (somewhat like s and e in {offset}) + Insert text (a string) in the buffer. + + *tlib#buffer#KeepCursorPosition()* +tlib#buffer#KeepCursorPosition(cmd) + Evaluate cmd while maintaining the cursor position and jump registers. + + +------------------------------------------------------------------------ + *autoload/tlib/cache.vim* + *g:tlib_cache* +g:tlib_cache (default: '') + The cache directory. If empty, use |tlib#dir#MyRuntime|.'/cache'. + You might want to delete old files from this directory from time to + time with a command like: > + find ~/vimfiles/cache/ -atime +31 -type f -print -delete +< + + *g:tlib#cache#purge_days* +g:tlib#cache#purge_days (default: 31) + |tlib#cache#Purge()|: Remove cache files older than N days. + + *g:tlib#cache#purge_every_days* +g:tlib#cache#purge_every_days (default: 31) + Purge the cache every N days. Disable automatic purging by setting + this value to a negative value. + + *g:tlib#cache#script_encoding* +g:tlib#cache#script_encoding (default: &enc) + The encoding used for the purge-cache script. + Default: 'enc' + + *g:tlib#cache#run_script* +g:tlib#cache#run_script (default: 1) + Whether to run the directory removal script: + 0 ... No + 1 ... Query user + 2 ... Yes + + *g:tlib#cache#verbosity* +g:tlib#cache#verbosity (default: 1) + Verbosity level: + 0 ... Be quiet + 1 ... Display informative message + 2 ... Display detailed messages + + *g:tlib#cache#dont_purge* +g:tlib#cache#dont_purge (default: ['[\/]\.last_purge$']) + A list of regexps that are matched against partial filenames of the + cached files. If a regexp matches, the file won't be removed by + |tlib#cache#Purge()|. + + *g:tlib#cache#max_filename* +g:tlib#cache#max_filename (default: 200) + If the cache filename is longer than N characters, use + |pathshorten()|. + + *tlib#cache#Dir()* +tlib#cache#Dir(?mode = 'bg', ?ensure_dir = true) + The default cache directory. + + *tlib#cache#EncodedFilename()* +tlib#cache#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#cache#Filename()|. + + *tlib#cache#Value()* +tlib#cache#Value(cfile, generator, ftime, ?generator_args=[], ?options={}) + Get a cached value from cfile. If it is outdated (compared to ftime) + or does not exist, create it calling a generator function. + + *tlib#cache#MaybePurge()* +tlib#cache#MaybePurge() + Call |tlib#cache#Purge()| if the last purge was done before + |g:tlib#cache#purge_every_days|. + + *tlib#cache#Purge()* +tlib#cache#Purge() + Delete old files. + + +------------------------------------------------------------------------ + *autoload/tlib/char.vim* + *tlib#char#Get()* +tlib#char#Get(?timeout=0) + Get a character. + + EXAMPLES: > + echo tlib#char#Get() + echo tlib#char#Get(5) +< + + +------------------------------------------------------------------------ + *autoload/tlib/cmd.vim* + *tlib#cmd#BrowseOutput()* +tlib#cmd#BrowseOutput(command) + See |:TBrowseOutput|. + + *tlib#cmd#BrowseOutputWithCallback()* +tlib#cmd#BrowseOutputWithCallback(callback, command) + Execute COMMAND and present its output in a |tlib#input#List()|; + when a line is selected, execute the function named as the CALLBACK + and pass in that line as an argument. + + The CALLBACK function gives you an opportunity to massage the COMMAND output + and possibly act on it in a meaningful way. For example, if COMMAND listed + all URIs found in the current buffer, CALLBACK could validate and then open + the selected URI in the system's default browser. + + This function is meant to be a tool to help compose the implementations of + powerful commands that use |tlib#input#List()| as a common interface. See + |TBrowseScriptnames| as an example. + + EXAMPLES: > + call tlib#cmd#BrowseOutputWithCallback('tlib#cmd#ParseScriptname', 'scriptnames') +< + + *tlib#cmd#UseVertical()* +tlib#cmd#UseVertical(?rx='') + Look at the history whether the command was called with vertical. If + an rx is provided check first if the last entry in the history matches + this rx. + + *tlib#cmd#Time()* +tlib#cmd#Time(cmd) + Print the time in seconds or milliseconds (if your version of VIM + has |+reltime|) a command takes. + + +------------------------------------------------------------------------ + *autoload/tlib/comments.vim* + *tlib#comments#Comments()* +tlib#comments#Comments(...) + function! tlib#comments#Comments(?rx='') + + +------------------------------------------------------------------------ + *autoload/tlib/date.vim* + *tlib#date#SecondsSince1970()* +tlib#date#Parse(date, ?allow_zero=0, ?silent=0) "{{{3 + tlib#date#SecondsSince1970(date, ?daysshift=0, ?allow_zero=0) + + +------------------------------------------------------------------------ + *autoload/tlib/dir.vim* + *g:tlib#dir#sep* +g:tlib#dir#sep (default: exists('+shellslash') && !&shellslash ? '\' : '/') + TLet g:tlib#dir#sep = '/' + + *tlib#dir#CanonicName()* +tlib#dir#CanonicName(dirname) + EXAMPLES: > + tlib#dir#CanonicName('foo/bar') + => 'foo/bar/' +< + + *tlib#dir#NativeName()* +tlib#dir#NativeName(dirname) + EXAMPLES: > + tlib#dir#NativeName('foo/bar/') + On Windows: + => 'foo\bar\' + On Linux: + => 'foo/bar/' +< + + *tlib#dir#PlainName()* +tlib#dir#PlainName(dirname) + EXAMPLES: > + tlib#dir#PlainName('foo/bar/') + => 'foo/bar' +< + + *tlib#dir#Ensure()* +tlib#dir#Ensure(dir) + Create a directory if it doesn't already exist. + + *tlib#dir#MyRuntime()* +tlib#dir#MyRuntime() + Return the first directory in &rtp. + + +------------------------------------------------------------------------ + *autoload/tlib/file.vim* + *g:tlib#file#drop* +g:tlib#file#drop (default: has('gui')) + If true, use |:drop| to edit loaded buffers (only available with GUI). + + *tlib#file#Split()* +tlib#file#Split(filename) + EXAMPLES: > + tlib#file#Split('foo/bar/filename.txt') + => ['foo', 'bar', 'filename.txt'] +< + + *tlib#file#Join()* +tlib#file#Join(filename_parts, ?strip_slashes=1, ?maybe_absolute=0) + EXAMPLES: > + tlib#file#Join(['foo', 'bar', 'filename.txt']) + => 'foo/bar/filename.txt' +< + + *tlib#file#Relative()* +tlib#file#Relative(filename, basedir) + EXAMPLES: > + tlib#file#Relative('foo/bar/filename.txt', 'foo') + => 'bar/filename.txt' +< + + *tlib#file#Edit()* +tlib#file#Edit(fileid) + Return 0 if the file isn't readable/doesn't exist. + Otherwise return 1. + + +------------------------------------------------------------------------ + *autoload/tlib/hook.vim* + *tlib#hook#Run()* +tlib#hook#Run(hook, ?dict={}) + Execute dict[hook], w:{hook}, b:{hook}, or g:{hook} if existent. + + +------------------------------------------------------------------------ + *autoload/tlib/input.vim* +Input-related, select from a list etc. + + *g:tlib#input#sortprefs_threshold* +g:tlib#input#sortprefs_threshold (default: 200) + If a list is bigger than this value, don't try to be smart when + selecting an item. Be slightly faster instead. + See |tlib#input#List()|. + + *g:tlib#input#livesearch_threshold* +g:tlib#input#livesearch_threshold (default: 1000) + If a list contains more items, |tlib#input#List()| does not perform an + incremental "live search" but uses |input()| to query the user for a + filter. This is useful on slower machines or with very long lists. + + *g:tlib#input#filter_mode* +g:tlib#input#filter_mode (default: 'glob') + Determine how |tlib#input#List()| and related functions work. + Can be "glob", "cnf", "cnfd", "seq", or "fuzzy". See: + glob ... Like cnf but "*" and "?" (see |g:tlib#Filter_glob#seq|, + |g:tlib#Filter_glob#char|) are interpreted as glob-like + |wildcards| (this is the default method) + - Examples: + - "f*o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_glob#New()|. + cnfd ... Like cnf but "." is interpreted as a wildcard, i.e. it is + expanded to "\.\{-}" + - A period character (".") acts as a wildcard as if ".\{-}" (see + |/\{-|) were entered. + - Examples: + - "f.o" matches "fo", "fxo", and "fxxxoo", but doesn't match + "far". + - Otherwise it is a derivate of the cnf method (see below). + - See also |tlib#Filter_cnfd#New()|. + cnf .... Match substrings + - A blank creates an AND conjunction, i.e. the next pattern has to + match too. + - A pipe character ("|") creates an OR conjunction, either this or + the next next pattern has to match. + - Patterns are very 'nomagic' |regexp| with a |\V| prefix. + - A pattern starting with "-" makes the filter exclude items + matching that pattern. + - Examples: + - "foo bar" matches items that contain the strings "foo" AND + "bar". + - "foo|bar boo|far" matches items that contain either ("foo" OR + "bar") AND ("boo" OR "far"). + - See also |tlib#Filter_cnf#New()|. + seq .... Match sequences of characters + - |tlib#Filter_seq#New()| + fuzzy .. Match fuzzy character sequences + - |tlib#Filter_fuzzy#New()| + + *g:tlib#input#higroup* +g:tlib#input#higroup (default: 'IncSearch') + The highlight group to use for showing matches in the input list + window. + See |tlib#input#List()|. + + *g:tlib_pick_last_item* +g:tlib_pick_last_item (default: 1) + When 1, automatically select the last remaining item only if the list + had only one item to begin with. + When 2, automatically select a last remaining item after applying + any filters. + See |tlib#input#List()|. + + +Keys for |tlib#input#List|~ + + *g:tlib#input#numeric_chars* +g:tlib#input#numeric_chars + When editing a list with |tlib#input#List|, typing these numeric chars + (as returned by getchar()) will select an item based on its index, not + based on its name. I.e. in the default setting, typing a "4" will + select the fourth item, not the item called "4". + In order to make keys 0-9 filter the items in the list and make + select an item by its index, remove the keys 48 to 57 from + this dictionary. + Format: [KEY] = BASE ... the number is calculated as KEY - BASE. + + *g:tlib#input#keyagents_InputList_s* +g:tlib#input#keyagents_InputList_s + The default key bindings for single-item-select list views. + + This variable is best customized via the variable + g:tlib_extend_keyagents_InputList_s. If you want to use , + to move the cursor up and down, add these two lines to your |vimrc| + file: + + let g:tlib_extend_keyagents_InputList_s = { + \ 10: 'tlib#agent#Down', + \ 11: 'tlib#agent#Up' + \ } + + *g:tlib#input#user_shortcuts* +g:tlib#input#user_shortcuts (default: {}) + A dictionary KEY => {'agent': AGENT, 'key_name': KEY_NAME} to + customize keyboard shortcuts in the list view. + + *g:tlib#input#use_popup* +g:tlib#input#use_popup (default: has('menu') && (has('gui_gtk') || has('gui_gtk2') || has('gui_win32'))) + If true, define a popup menu for |tlib#input#List()| and related + functions. + + *g:tlib#input#format_filename* +g:tlib#input#format_filename (default: 'l') + How to format filenames: + l ... Show basenames on the left side, separated from the + directory names + r ... Show basenames on the right side + + *g:tlib#input#filename_padding_r* +g:tlib#input#filename_padding_r (default: '&co / 10') + If g:tlib#input#format_filename == 'r', how much space should be kept + free on the right side. + + *g:tlib#input#filename_max_width* +g:tlib#input#filename_max_width (default: '&co / 2') + If g:tlib#input#format_filename == 'l', an expression that + |eval()|uates to the maximum display width of filenames. + + *tlib#input#List()* +tlib#input#List(type. ?query='', ?list=[], ?handlers=[], ?default="", ?timeout=0) + Select a single or multiple items from a list. Return either the list + of selected elements or its indexes. + + By default, typing numbers will select an item by its index. See + |g:tlib#input#numeric_chars| to find out how to change this. + + The item is automatically selected if the numbers typed equals the + number of digits of the list length. I.e. if a list contains 20 items, + typing 1 will first highlight item 1 but it won't select/use it + because 1 is an ambiguous input in this context. If you press enter, + the first item will be selected. If you press another digit (e.g. 0), + item 10 will be selected. Another way to select item 1 would be to + type 01. If the list contains only 9 items, typing 1 would select the + first item right away. + + type can be: + s ... Return one selected element + si ... Return the index of the selected element + m ... Return a list of selected elements + mi ... Return a list of indexes + + Several pattern matching styles are supported. See + |g:tlib#input#filter_mode|. + + Users can type to complete the current filter with the longest + match. + + EXAMPLES: > + echo tlib#input#List('s', 'Select one item', [100,200,300]) + echo tlib#input#List('si', 'Select one item', [100,200,300]) + echo tlib#input#List('m', 'Select one or more item(s)', [100,200,300]) + echo tlib#input#List('mi', 'Select one or more item(s)', [100,200,300]) + +< See ../samples/tlib/input/tlib_input_list.vim (move the cursor over + the filename and press gf) for a more elaborated example. + + *tlib#input#ListD()* +tlib#input#ListD(dict) + A wrapper for |tlib#input#ListW()| that builds |tlib#World#New| from + dict. + + *tlib#input#ListW()* +tlib#input#ListW(world, ?command='') + The second argument (command) is meant for internal use only. + The same as |tlib#input#List| but the arguments are packed into world + (an instance of tlib#World as returned by |tlib#World#New|). + + *tlib#input#EditList()* +tlib#input#EditList(query, list, ?timeout=0) + Edit a list. + + EXAMPLES: > + echo tlib#input#EditList('Edit:', [100,200,300]) +< + + *tlib#input#CommandSelect()* +tlib#input#CommandSelect(command, ?keyargs={}) + Take a command, view the output, and let the user select an item from + its output. + + EXAMPLE: > + command! TMarks exec 'norm! `'. matchstr(tlib#input#CommandSelect('marks'), '^ \+\zs.') + command! TAbbrevs exec 'norm i'. matchstr(tlib#input#CommandSelect('abbrev'), '^\S\+\s\+\zs\S\+') +< + + *tlib#input#Edit()* +tlib#input#Edit(name, value, callback, ?cb_args=[]) + + Edit a value (asynchronously) in a scratch buffer. Use name for + identification. Call callback when done (or on cancel). + In the scratch buffer: + Press or to enter the new value, c to cancel + editing. + EXAMPLES: > + fun! FooContinue(success, text) + if a:success + let b:var = a:text + endif + endf + call tlib#input#Edit('foo', b:var, 'FooContinue') +< + + +------------------------------------------------------------------------ + *autoload/tlib/list.vim* + *tlib#list#Inject()* +tlib#list#Inject(list, initial_value, funcref) + EXAMPLES: > + echo tlib#list#Inject([1,2,3], 0, function('Add') + => 6 +< + + *tlib#list#Compact()* +tlib#list#Compact(list) + EXAMPLES: > + tlib#list#Compact([0,1,2,3,[], {}, ""]) + => [1,2,3] +< + + *tlib#list#Flatten()* +tlib#list#Flatten(list) + EXAMPLES: > + tlib#list#Flatten([0,[1,2,[3,""]]]) + => [0,1,2,3,""] +< + + *tlib#list#FindAll()* +tlib#list#FindAll(list, filter, ?process_expr="") + Basically the same as filter() + + EXAMPLES: > + tlib#list#FindAll([1,2,3], 'v:val >= 2') + => [2, 3] +< + + *tlib#list#Find()* +tlib#list#Find(list, filter, ?default="", ?process_expr="") + + EXAMPLES: > + tlib#list#Find([1,2,3], 'v:val >= 2') + => 2 +< + + *tlib#list#Any()* +tlib#list#Any(list, expr) + EXAMPLES: > + tlib#list#Any([1,2,3], 'v:val >= 2') + => 1 +< + + *tlib#list#All()* +tlib#list#All(list, expr) + EXAMPLES: > + tlib#list#All([1,2,3], 'v:val >= 2') + => 0 +< + + *tlib#list#Remove()* +tlib#list#Remove(list, element) + EXAMPLES: > + tlib#list#Remove([1,2,1,2], 2) + => [1,1,2] +< + + *tlib#list#RemoveAll()* +tlib#list#RemoveAll(list, element) + EXAMPLES: > + tlib#list#RemoveAll([1,2,1,2], 2) + => [1,1] +< + + *tlib#list#Zip()* +tlib#list#Zip(lists, ?default='') + EXAMPLES: > + tlib#list#Zip([[1,2,3], [4,5,6]]) + => [[1,4], [2,5], [3,6]] +< + + +------------------------------------------------------------------------ + *autoload/tlib/map.vim* + *tlib#map#PumAccept()* +tlib#map#PumAccept(key) + If |pumvisible()| is true, return "\". Otherwise return a:key. + For use in maps like: > + imap tlib#map#PumAccept("\") +< + + +------------------------------------------------------------------------ + *autoload/tlib/normal.vim* + *tlib#normal#WithRegister()* +tlib#normal#WithRegister(cmd, ?register='t', ?norm_cmd='norm!') + Execute a normal command while maintaining all registers. + + +------------------------------------------------------------------------ + *autoload/tlib/notify.vim* + *tlib#notify#Echo()* +tlib#notify#Echo(text, ?style='') + Print text in the echo area. Temporarily disable 'ruler' and 'showcmd' + in order to prevent |press-enter| messages. + + *tlib#notify#TrimMessage()* +tlib#notify#TrimMessage(message) + Contributed by Erik Falor: + If the line containing the message is too long, echoing it will cause + a 'Hit ENTER' prompt to appear. This function cleans up the line so + that does not happen. + The echoed line is too long if it is wider than the width of the + window, minus cmdline space taken up by the ruler and showcmd + features. + + +------------------------------------------------------------------------ + *autoload/tlib/paragraph.vim* + *tlib#paragraph#GetMetric()* +tlib#paragraph#GetMetric() + Return an object describing a |paragraph|. + + *tlib#paragraph#Move()* +tlib#paragraph#Move(direction, count) + This function can be used with the tinymode plugin to move around + paragraphs. + + Example configuration: > + + call tinymode#EnterMap("para_move", "gp") + call tinymode#ModeMsg("para_move", "Move paragraph: j/k") + call tinymode#Map("para_move", "j", "silent call tlib#paragraph#Move('Down', '[N]')") + call tinymode#Map("para_move", "k", "silent call tlib#paragraph#Move('Up', '[N]')") + call tinymode#ModeArg("para_move", "owncount", 1) +< + + +------------------------------------------------------------------------ + *autoload/tlib/persistent.vim* + *g:tlib_persistent* +g:tlib_persistent (default: '') + The directory for persistent data files. If empty, use + |tlib#dir#MyRuntime|.'/share'. + + *tlib#persistent#Dir()* +tlib#persistent#Dir(?mode = 'bg') + Return the full directory name for persistent data files. + + *tlib#persistent#EncodedFilename()* +tlib#persistent#EncodedFilename(type, file, ?mkdir=0, ?dir='') + Encode `file` and call |tlib#persistent#Filename()|. + + +------------------------------------------------------------------------ + *autoload/tlib/progressbar.vim* + *tlib#progressbar#Init()* +tlib#progressbar#Init(max, ...) + EXAMPLE: > + call tlib#progressbar#Init(20) + try + for i in range(20) + call tlib#progressbar#Display(i) + call DoSomethingThatTakesSomeTime(i) + endfor + finally + call tlib#progressbar#Restore() + endtry +< + + +------------------------------------------------------------------------ + *autoload/tlib/rx.vim* + *tlib#rx#Escape()* +tlib#rx#Escape(text, ?magic='m') + magic can be one of: m, M, v, V + See :help 'magic' + + *tlib#rx#EscapeReplace()* +tlib#rx#EscapeReplace(text, ?magic='m') + Escape return |sub-replace-special|. + + +------------------------------------------------------------------------ + *autoload/tlib/scratch.vim* + *g:tlib_scratch_pos* +g:tlib_scratch_pos (default: 'botright') + Scratch window position. By default the list window is opened on the + bottom. Set this variable to 'topleft' or '' to change this behaviour. + See |tlib#input#List()|. + + *g:tlib#scratch#hidden* +g:tlib#scratch#hidden (default: 'hide') + If you want the scratch buffer to be fully removed, you might want to + set this variable to 'wipe'. + See also https://github.com/tomtom/tlib_vim/pull/16 + + *tlib#scratch#UseScratch()* +tlib#scratch#UseScratch(?keyargs={}) + Display a scratch buffer (a buffer with no file). See :TScratch for an + example. + Return the scratch buffer's number. + Values for keyargs: + scratch_split ... 1: split, 0: window, -1: tab + + *tlib#scratch#CloseScratch()* +tlib#scratch#CloseScratch(keyargs, ...) + Close a scratch buffer as defined in keyargs (usually a World). + Return 1 if the scratch buffer is closed (or if it already was + closed). + + +------------------------------------------------------------------------ + *autoload/tlib/selection.vim* + *tlib#selection#GetSelection()* +tlib#selection#GetSelection(mode, ?mbeg="'<", ?mend="'>", ?opmode='selection') + mode can be one of: selection, lines, block + + +------------------------------------------------------------------------ + *autoload/tlib/signs.vim* + *tlib#signs#ClearAll()* +tlib#signs#ClearAll(sign) + Clear all signs with name SIGN. + + *tlib#signs#ClearBuffer()* +tlib#signs#ClearBuffer(sign, bufnr) + Clear all signs with name SIGN in buffer BUFNR. + + *tlib#signs#Mark()* +tlib#signs#Mark(sign, list) + Add signs for all locations in LIST. LIST must adhere with the + quickfix list format (see |getqflist()|; only the fields lnum and + bufnr are required). + + list:: a quickfix or location list + sign:: a sign defined with |:sign-define| + + +------------------------------------------------------------------------ + *autoload/tlib/string.vim* + *tlib#string#RemoveBackslashes()* +tlib#string#RemoveBackslashes(text, ?chars=' ') + Remove backslashes from text (but only in front of the characters in + chars). + + *tlib#string#Format()* +tlib#string#Chomp(string, ?max=0) + Format a template string. Placeholders have the format "%{NAME}". A + "%" can be inserted as "%%". + + Examples: + echo tlib#string#Format("foo %{bar} foo", {'bar': 123}, ?prefix='%') + => foo 123 foo + + *tlib#string#Printf1()* +tlib#string#Printf1(format, string) + This function deviates from |printf()| in certain ways. + Additional items: + %{rx} ... insert escaped regexp + %{fuzzyrx} ... insert typo-tolerant regexp + + +------------------------------------------------------------------------ + *autoload/tlib/sys.vim* + *g:tlib#sys#special_protocols* +g:tlib#sys#special_protocols (default: ['https\?', 'nntp', 'mailto']) + A list of |regexp|s matching protocol names that should be handled + by |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#special_suffixes* +g:tlib#sys#special_suffixes (default: ['xlsx\?', 'docx\?', 'pptx\?', 'accdb', 'mdb', 'sqlite', 'pdf', 'jpg', 'png', 'gif', 'od\[tspg]']) + A list of |regexp|s matching suffixes that should be handled by + |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_rx* +g:tlib#sys#system_rx (default: printf('\V\%(\^\%(%s\):\|.\%(%s\)\$\)', join(g:tlib#sys#special_protocols, '\|'), join(g:tlib#sys#special_suffixes, '\|'))) + Open links matching this |regexp| with |g:tlib#sys#system_browser|. + CAVEAT: Must be a |\V| |regexp|. + + *g:tlib#sys#system_browser* +g:tlib#sys#system_browser (default: ...) + Open files in the system browser. + + *g:tlib#sys#check_cygpath* +g:tlib#sys#check_cygpath (default: g:tlib#sys#windows && tlib#sys#IsExecutable('cygpath', 1)) + If true, check whether we have to convert a path via cyppath -- + see |tlib#sys#MaybeUseCygpath| + + *g:tlib#sys#cygwin_path_rx* +g:tlib#sys#cygwin_path_rx (default: '/cygwin/') + If a full windows filename (with slashes instead of backslashes) + matches this |regexp|, it is assumed to be a cygwin executable. + + *g:tlib#sys#cygwin_expr* +g:tlib#sys#cygwin_expr (default: '"bash -c ''". escape(%s, "''\\") ."''"') + For cygwin binaries, convert command calls using this vim + expression. + + *tlib#sys#MaybeUseCygpath()* +tlib#sys#MaybeUseCygpath(cmd) + If cmd seems to be a cygwin executable, use cygpath to convert + filenames. This assumes that cygwin's which command returns full + filenames for non-cygwin executables. + + *tlib#sys#IsSpecial()* +tlib#sys#IsSpecial(filename) + Check whether filename matches |g:tlib#sys#system_rx|, i.e. whether it + is a special file that should not be opened in vim. + + *tlib#sys#Open()* +tlib#sys#Open(filename) + Open filename with the default OS application (see + |g:tlib#sys#system_browser|), if |tlib#sys#IsSpecial()| return 1. + Returns 1 if successful or 0 otherwise. + + *tlib#sys#OpenWithSystemViewer()* +tlib#sys#OpenWithSystemViewer(filename) + Open filename with the default system viewer. + + +------------------------------------------------------------------------ + *autoload/tlib/tab.vim* + *tlib#tab#BufMap()* +tlib#tab#BufMap() + Return a dictionary of bufnumbers => [[tabpage, winnr] ...] + + *tlib#tab#TabWinNr()* +tlib#tab#TabWinNr(buffer) + Find a buffer's window at some tab page. + + +------------------------------------------------------------------------ + *autoload/tlib/tag.vim* + *g:tlib_tags_extra* +g:tlib_tags_extra (default: '') + Extra tags for |tlib#tag#Retrieve()| (see there). Can also be buffer-local. + + *g:tlib_tag_substitute* +g:tlib_tag_substitute + Filter the tag description through |substitute()| for these filetypes. + This applies only if the tag cmd field (see |taglist()|) is used. + + *tlib#tag#Retrieve()* +tlib#tag#Retrieve(rx, ?extra_tags=0) + Get all tags matching rx. Basically, this function simply calls + |taglist()|, but when extra_tags is true, the list of the tag files + (see 'tags') is temporarily expanded with |g:tlib_tags_extra|. + + Example use: + If you want to include tags for, eg, JDK, normal tags use can become + slow. You could proceed as follows: + 1. Create a tags file for the JDK sources. When creating the tags + file, make sure to include inheritance information and the like + (command-line options like --fields=+iaSm --extra=+q should be ok). + In this example, we want tags only for public methods (there are + most likely better ways to do this): > + ctags -R --fields=+iaSm --extra=+q ${JAVA_HOME}/src + head -n 6 tags > tags0 + grep access:public tags >> tags0 +< 2. Make 'tags' include project specific tags files. In + ~/vimfiles/after/ftplugin/java.vim insert: > + let b:tlib_tags_extra = $JAVA_HOME .'/tags0' +< 3. When this function is invoked as > + echo tlib#tag#Retrieve('print') +< it will return only project-local tags. If it is invoked as > + echo tlib#tag#Retrieve('print', 1) +< tags from the JDK will be included. + + *tlib#tag#Collect()* +tlib#tag#Collect(constraints, ?use_extra=1, ?match_front=1) + Retrieve tags that meet the constraints (a dictionnary of fields and + regexp, with the exception of the kind field which is a list of chars). + For the use of the optional use_extra argument see + |tlib#tag#Retrieve()|. + + +------------------------------------------------------------------------ + *autoload/tlib/textobjects.vim* + *standard-paragraph* +tlib#textobjects#StandardParagraph() + Select a "Standard Paragraph", i.e. a text block followed by blank + lines. Other than |ap|, the last paragraph in a document is handled + just the same. + + The |text-object| can be accessed as "sp". Example: > + + vsp ... select the current standard paragraph + +< Return 1, if the paragraph is the last one in the document. + + *v_sp* +v_sp ... :call tlib#textobjects#StandardParagraph() + sp ... Standard paragraph (for use as |text-objects|). + + +------------------------------------------------------------------------ + *autoload/tlib/trace.vim* + *g:tlib#trace#backtrace* +g:tlib#trace#backtrace (default: 2) + The length of the backtrace that should be included in + |tlib#trace#Print()|. + + *g:tlib#trace#printer* +g:tlib#trace#printer (default: 'echom') + Possible values: + - 'echom' + - ['file', FILENAME] + + *tlib#trace#Printer_echom()* +tlib#trace#Printer_echom(type, text, args) + Print traces from |tlib#trace#Print()|. + + *tlib#trace#Set()* +tlib#trace#Set(vars, ...) + Set the tracing |regexp|. See |:Tlibtrace|. + This will also call |tlib#trace#Enable()|. + + Examples: + call tlib#trace#Set(["+foo", "-bar"]) + call tlib#trace#Set("+foo,-bar") + + *tlib#trace#Print()* +tlib#trace#Print(caller, vars, values) + Print the values of vars. The first value is a "guard" (see + |:Tlibtrace|). + + *tlib#trace#Enable()* +tlib#trace#Enable() + Enable tracing via |:Tlibtrace|. + + *tlib#trace#Disable()* +tlib#trace#Disable() + Disable tracing via |:Tlibtrace|. + + +------------------------------------------------------------------------ + *autoload/tlib/type.vim* + *tlib#type#Enable()* +tlib#type#Enable() + Enable type assertiona via |:Tlibtype|. + + *tlib#type#Disable()* +tlib#type#Disable() + Disable type assertiona via |:Tlibtype|. + + +------------------------------------------------------------------------ + *autoload/tlib/url.vim* + *tlib#url#Decode()* +tlib#url#Decode(url) + Decode an encoded URL. + + *tlib#url#DecodeChar()* +tlib#url#DecodeChar(char) + Decode a single character. + + *tlib#url#EncodeChar()* +tlib#url#EncodeChar(char) + Encode a single character. + + *tlib#url#Encode()* +tlib#url#Encode(url, ...) + Encode an URL. + + +------------------------------------------------------------------------ + *autoload/tlib/var.vim* + *tlib#var#Let()* +tlib#var#Let(name, val) + Define a variable called NAME if yet undefined. + You can also use the :TLLet command. + + EXAMPLES: > + exec tlib#var#Let('g:foo', 1) + TLet g:foo = 1 +< + + *tlib#var#EGet()* +tlib#var#EGet(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo eval(tlib#var#EGet('foo', 'vg')) => 1 + echo eval(tlib#var#EGet('foo', 'bg')) => 2 + echo eval(tlib#var#EGet('foo', 'wbg')) => 3 +< + + *tlib#var#Get()* +tlib#var#Get(var, namespace, ?default='') + Retrieve a variable by searching several namespaces. + + EXAMPLES: > + let g:foo = 1 + let b:foo = 2 + let w:foo = 3 + echo tlib#var#Get('foo', 'bg') => 1 + echo tlib#var#Get('foo', 'bg') => 2 + echo tlib#var#Get('foo', 'wbg') => 3 +< + + *tlib#var#List()* +tlib#var#List(rx, ?prefix='') + Get a list of variables matching rx. + EXAMPLE: + echo tlib#var#List('tlib_', 'g:') + + +------------------------------------------------------------------------ + *autoload/tlib/vcs.vim* + *g:tlib#vcs#def* +g:tlib#vcs#def {...} + A dictionarie of supported VCS (currently: git, hg, svn, bzr). + + *g:tlib#vcs#executables* +g:tlib#vcs#executables {...} + A dictionary of custom executables for VCS commands. If the value is + empty, support for that VCS will be removed. If no key is present, it + is assumed that the VCS "type" is the name of the executable. + + *g:tlib#vcs#check* +g:tlib#vcs#check (default: has('win16') || has('win32') || has('win64') ? '%s.exe' : '%s') + If non-empty, use it as a format string to check whether a VCS is + installed on your computer. + + *tlib#vcs#Ls()* +tlib#vcs#Ls(?filename=bufname('%'), ?vcs=[type, dir]) + Return the files under VCS. + + *tlib#vcs#Diff()* +tlib#vcs#Diff(filename, ?vcs=[type, dir]) + Return the diff for "filename" + + +------------------------------------------------------------------------ + *autoload/tlib/vim.vim* + *g:tlib#vim#simalt_maximize* +g:tlib#vim#simalt_maximize (default: 'x') + The alt-key for maximizing the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#simalt_restore* +g:tlib#vim#simalt_restore (default: 'r') + The alt-key for restoring the window. + CAUTION: The value of this paramter depends on your locale and + maybe the windows version you are running. + + *g:tlib#vim#use_vimtweak* +g:tlib#vim#use_vimtweak (default: 0) + If true, use the vimtweak.dll for windows. This will enable + tlib to remove the caption for fullscreen windows. + + *tlib#vim#Maximize()* +tlib#vim#Maximize(fullscreen) + Maximize the window. + You might need to redefine |g:tlib#vim#simalt_maximize| if it doesn't + work for you. + + *tlib#vim#RestoreWindow()* +tlib#vim#RestoreWindow() + Restore the original vimsize after having called |tlib#vim#Maximize()|. + + *g:tlib#vim#use_wmctrl* +g:tlib#vim#use_wmctrl (default: executable('wmctrl')) + If true, use wmctrl for X windows to make a window + maximized/fullscreen. + + This is the preferred method for maximizing windows under X + windows. Some window managers have problem coping with the + default method of setting 'lines' and 'columns' to a large + value. + + +------------------------------------------------------------------------ + *autoload/tlib/win.vim* + *tlib#win#Set()* +tlib#win#Set(winnr) + Return vim code to jump back to the original window. + + *tlib#win#SetById()* +tlib#win#SetById(win_id) + Return vim code to jump back to the original window. + + + +vim:tw=78:fo=w2croql:isk=!-~,^*,^|,^":ts=8:ft=help:norl: diff --git a/sources_non_forked/tlib/etc/tpl_tlib.txt b/sources_non_forked/tlib/etc/tpl_tlib.txt new file mode 100644 index 00000000..f8059703 --- /dev/null +++ b/sources_non_forked/tlib/etc/tpl_tlib.txt @@ -0,0 +1,30 @@ +*tlib.txt* tlib -- A library of vim functions + Author: Tom Link, micathom at gmail com + +This library provides some utility functions. There isn't much need to +install it unless another plugin requires you to do so. + +Most of the library is included in autoload files. No autocommands are +created. With the exception of loading ../plugin/02tlib.vim at startup +the library has no impact on startup time or anything else. + +The change-log is included at the bottom of ../plugin/02tlib.vim +(move the cursor over the file name and type gfG) + +Demo of |tlib#input#List()|: +http://vimsomnia.blogspot.com/2010/11/selecting-items-from-list-with-tlibs.html + + +----------------------------------------------------------------------- +Install~ + +Edit the vba file and type: > + + :so % + +See :help vimball for details. If you have difficulties, please make +sure, you have the current version of vimball (vimscript #1502) +installed. + + +%s diff --git a/sources_non_forked/tlib/macros/tlib.vim b/sources_non_forked/tlib/macros/tlib.vim new file mode 100644 index 00000000..3e5a7912 --- /dev/null +++ b/sources_non_forked/tlib/macros/tlib.vim @@ -0,0 +1,38 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @GIT: http://github.com/tomtom/tlib_vim/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2015-11-09. +" @Revision: 10 + +if &cp || exists("loaded_tlib_macros") + finish +endif +let loaded_tlib_macros = 1 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TRequire NAME [VERSION [FILE]] +" Make a certain vim file is loaded. +" +" Conventions: If FILE isn't defined, plugin/NAME.vim is loaded. The +" file must provide a variable loaded_{NAME} that represents the version +" number. +command! -nargs=+ TRequire let s:require = [] + \ | if !exists('loaded_'. get(s:require, 0)) + \ | exec 'runtime '. get(s:require, 2, 'plugin/'. get(s:require, 0) .'.vim') + \ | if !exists('loaded_'. get(s:require, 0)) || loaded_{get(s:require, 0)} < get(s:require, 1, loaded_{get(s:require, 0)}) + \ | echoerr 'Require '. get(s:require, 0) .' >= '. get(s:require, 1, 'any version will do') + \ | finish + \ | endif + \ | endif | unlet s:require + + +" :display: :Ttimecommand CMD +" Time the execution time of CMD. +command! -nargs=1 -complete=command Ttimecommand call tlib#cmd#Time() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/plugin/02tlib.vim b/sources_non_forked/tlib/plugin/02tlib.vim new file mode 100644 index 00000000..76800233 --- /dev/null +++ b/sources_non_forked/tlib/plugin/02tlib.vim @@ -0,0 +1,126 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Created: 2007-04-10. +" @Last Change: 2022-07-21. +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 837 +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" GetLatestVimScripts: 1863 1 tlib.vim +" tlib.vim -- Some utility functions + +if &cp || exists("g:loaded_tlib") + finish +endif +if v:version < 700 "{{{2 + echoerr "tlib requires Vim >= 7" + finish +endif +let g:loaded_tlib = 128 + +let s:save_cpo = &cpo +set cpo&vim + + +" :display: :TLet VAR = VALUE +" Set a variable only if it doesn't already exist. +" EXAMPLES: > +" TLet foo = 1 +" TLet foo = 2 +" echo foo +" => 1 +command! -nargs=+ TLet if !exists(matchstr(, '^[^=[:space:]]\+')) | exec 'let '. | endif + + +" Open a scratch buffer (a buffer without a file). +" TScratch ... use split window +" TScratch! ... use the whole frame +" This command takes an (inner) dictionary as optional argument. +" EXAMPLES: > +" TScratch 'scratch': '__FOO__' +" => Open a scratch buffer named __FOO__ +command! -bar -nargs=* -bang TScratch call tlib#scratch#UseScratch({'scratch_split': empty(''), }) + + +" :display: :TVarArg VAR1, [VAR2, DEFAULT2] ... +" A convenience wrapper for |tlib#arg#Let|. +" EXAMPLES: > +" function! Foo(...) +" TVarArg ['a', 1], 'b' +" echo 'a='. a +" echo 'b='. b +" endf +command! -nargs=+ TVarArg exec tlib#arg#Let([]) + + +" :display: :TBrowseOutput COMMAND +" Ever wondered how to efficiently browse the output of a command +" without redirecting it to a file? This command takes a command as +" argument and presents the output via |tlib#input#List()| so that you +" can easily search for a keyword (e.g. the name of a variable or +" function) and the like. +" +" If you press enter, the selected line will be copied to the command +" line. Press ESC to cancel browsing. +" +" EXAMPLES: > +" TBrowseOutput 20verb TeaseTheCulprit +command! -nargs=1 -complete=command TBrowseOutput call tlib#cmd#BrowseOutput() + + +" :display: :TBrowseScriptnames +" List all sourced script names (the output of ':scriptnames'). +" +" When you press enter, the selected script will be opened in the current +" window. Press ESC to cancel. +" +" EXAMPLES: > +" TBrowseScriptnames +command! -nargs=0 TBrowseScriptnames call tlib#cmd#TBrowseScriptnames() + + +" :display: :Texecqfl CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecqfl | call tlib#qfl#QflList(getqflist()) + + +" :display: :Texecloc CMD +" Run CMD and display the quickfix list. +command! -nargs=1 Texecloc | call tlib#qfl#QflList(getloclist(0)) + + +" :display: :Tlibtrace GUARD, VAR1, VAR2... +" Do nothing unless |tlib#trace#Enable()| was called. +" +" When |:Tlibtraceset| or |tlib#trace#Enable()| were called: +" +" If GUARD is a number that evaluates to true or if it is a string that +" matches a |regexp|, which was added using Tlibtrace! (with '!'), +" display the values of VAR1, VAR2 ... +command! -nargs=+ -bang Tlibtrace : + + +" :Tlibtraceset[!] [--file=FILE] +RX1 -RX2... +" If |tlib#trace#Enable()| was called: With the optional , users +" can add and remove GUARDs (actually a |regexp|) that should be traced. +" +" If no `+` or `-` is prepended, assume `+`. +" +" With the optional bang '!', reset any options. +command! -nargs=+ -bang Tlibtraceset call tlib#trace#Set(tlib#arg#GetOpts([], {'short': 0}), !empty("")) + + +" :display: :Tlibtrace ASSERTION +command! -nargs=+ -bang Tlibassert : + +" :display: :Tlibtype val, 'type', ... +command! -nargs=+ Tlibtype : + + +" Browse the current |quickfix| list. +command! -bar Tbrowseqfl call tlib#qfl#Browse() + +" Browse the current |location-list|. +command! -bar Tbrowseloc call tlib#loclist#Browse() + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim b/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim new file mode 100644 index 00000000..4d668ffa --- /dev/null +++ b/sources_non_forked/tlib/samples/tlib/input/tlib_input_list.vim @@ -0,0 +1,50 @@ +" The following variable configures the way |tlib#input#ListD()| works. +" In this example, we allow selection of multiple items (we could also +" allow only a single choice and make |tlib#input#ListD()| work on the +" indices, not the items). +" +" We also set a prompt that will be displayed in the command area. +" +" By default, |tlib#input#ListD()| will automatically select an item if +" there is only one item left matching the filter. In this example, we +" disable this feature. +" +" For demonstration purposes, we also define a key handler that prints +" the selected items. +let s:state = { + \ 'type': 'm', + \ 'query': 'Select lines for command output', + \ 'pick_last_item': 0, + \ 'key_handlers': [ + \ {'key': 16, 'agent': 'PrintMe', 'key_name': '', 'help': 'Print line'}, + \ ], + \ } + +" A key handler takes two arguments: the current state of the list +" display and a list of selected items/indices (depending on the type +" parameter). +function! PrintMe(state, items) "{{{3 + echom "You selected:" + for i in a:items + echom i + endfor + call input("Press ENTER to continue") + let a:state.state = 'redisplay' + return a:state +endf + +" In this example, we evaluate an ex-command with |:execute| and display +" the command's output as list. The user can select certain lines by +" typing some pattern or by pressing to select an item by +" number. The user can then press to print the lines (see above) +" or to pick the selected lines. +function! SelectOutput(ex) "{{{3 + redir => lines + silent exec a:ex + redir END + let state = copy(s:state) + let state.base = split(lines, '\n') + let picked = tlib#input#ListD(state) + echom "You picked: ". join(picked, ', ') +endf + diff --git a/sources_non_forked/tlib/scripts/create_crc_table.rb b/sources_non_forked/tlib/scripts/create_crc_table.rb new file mode 100644 index 00000000..149fe11f --- /dev/null +++ b/sources_non_forked/tlib/scripts/create_crc_table.rb @@ -0,0 +1,67 @@ +# @Author: Tom Link (micathom AT gmail com) +# @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +# @Revision: 14 + + +def crc_vim_table + tbl = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, + 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, + 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, + 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, + 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, + 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, + 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, + 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, + 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, + 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, + 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, + 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, + 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, + 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, + 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, + 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, + 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, + 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, + 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, + 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, + 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, + 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, + 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, + 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, + 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, + 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, + 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, + 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, + 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, + 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, + 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, + 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, + 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, + 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, + 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, + 0x2d02ef8d] + tbl.map! do |num| + b = "%b" % num + bits = b.split(//) + bits.map! {|b| b.to_i} + bits.reverse + end + VIM::command("let @t = '#{tbl.inspect}'") +end + diff --git a/sources_non_forked/tlib/spec/tlib/arg.vim b/sources_non_forked/tlib/spec/tlib/arg.vim new file mode 100644 index 00000000..cf060a26 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/arg.vim @@ -0,0 +1,66 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 1 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#arg' + +function! TestGetArg(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1) + return foo +endf + +function! TestGetArg1(...) "{{{3 + exec tlib#arg#Get(1, 'foo', 1, '!= ""') + return foo +endf + +Should be equal TestGetArg(), 1 +Should be equal TestGetArg(''), '' +Should be equal TestGetArg(2), 2 +Should be equal TestGetArg1(), 1 +Should be equal TestGetArg1(''), 1 +Should be equal TestGetArg1(2), 2 + +function! TestArgs(...) "{{{3 + exec tlib#arg#Let([['foo', "o"], ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs(), 'oo' +Should be equal TestArgs('a'), 'aa' +Should be equal TestArgs('a', 3), 'aaa' + +function! TestArgs1(...) "{{{3 + exec tlib#arg#Let(['foo', ['bar', 2]]) + return repeat(foo, bar) +endf +Should be equal TestArgs1(), '' +Should be equal TestArgs1('a'), 'aa' +Should be equal TestArgs1('a', 3), 'aaa' + +function! TestArgs2(...) "{{{3 + exec tlib#arg#Let(['foo', 'bar'], 1) + return repeat(foo, bar) +endf +Should be equal TestArgs2(), '1' +Should be equal TestArgs2('a'), 'a' +Should be equal TestArgs2('a', 3), 'aaa' + +function! TestArgs3(...) + TVarArg ['a', 1], 'b' + return a . b +endf +Should be equal TestArgs3(), '1' +Should be equal TestArgs3('a'), 'a' +Should be equal TestArgs3('a', 3), 'a3' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/date.vim b/sources_non_forked/tlib/spec/tlib/date.vim new file mode 100644 index 00000000..42c336bd --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/date.vim @@ -0,0 +1,61 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-09-17. +" @Last Change: 2016-03-16. +" @Revision: 21 + +SpecBegin 'title': 'tlib#date' + +Should be equal tlib#date#Parse('2000-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('2000-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00-1-0', 1), [2000, 1, 0] +Should be equal tlib#date#Parse('00-1-2'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-01-02'), [2000, 1, 2] +Should be equal tlib#date#Parse('00-10-20'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2000/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('2000/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('00/2/1'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/02/01'), [2000, 1, 2] +Should be equal tlib#date#Parse('00/20/10'), [2000, 10, 20] + +Should be equal tlib#date#Parse('2.1.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('2. 1. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02.01.2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('02. 01. 2000'), [2000, 1, 2] +Should be equal tlib#date#Parse('20.10.2000'), [2000, 10, 20] +Should be equal tlib#date#Parse('20. 10. 2000'), [2000, 10, 20] + +Should throw exception "tlib#date#Parse('2000-14-2')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-011-02')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-40')", 'TLib: Invalid date' +Should throw exception "tlib#date#Parse('2000-10-0')", 'TLib: Invalid date' + +Should be equal tlib#date#Shift('2015-10-29', '1m'), '2015-11-29' +Should be equal tlib#date#Shift('2015-11-29', '1m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-12-29', '1m'), '2016-01-29' +Should be equal tlib#date#Shift('2016-01-29', '1m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-10-29', '2m'), '2015-12-29' +Should be equal tlib#date#Shift('2015-10-29', '3m'), '2016-01-29' +Should be equal tlib#date#Shift('2015-10-29', '4m'), '2016-02-29' +Should be equal tlib#date#Shift('2015-12-30', '1d'), '2015-12-31' +Should be equal tlib#date#Shift('2015-12-31', '1d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '2d'), '2016-01-01' +Should be equal tlib#date#Shift('2015-12-30', '3d'), '2016-01-02' + +Should be equal tlib#date#Shift('2016-03-16', '1b'), '2016-03-17' +Should be equal tlib#date#Shift('2016-03-16', '2b'), '2016-03-18' +Should be equal tlib#date#Shift('2016-03-16', '3b'), '2016-03-21' +Should be equal tlib#date#Shift('2016-03-16', '4b'), '2016-03-22' +Should be equal tlib#date#Shift('2016-03-16', '5b'), '2016-03-23' +Should be equal tlib#date#Shift('2016-03-16', '6b'), '2016-03-24' +Should be equal tlib#date#Shift('2016-03-16', '7b'), '2016-03-25' +Should be equal tlib#date#Shift('2016-03-16', '8b'), '2016-03-28' + diff --git a/sources_non_forked/tlib/spec/tlib/dictionary.vim b/sources_non_forked/tlib/spec/tlib/dictionary.vim new file mode 100644 index 00000000..52439e6d --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/dictionary.vim @@ -0,0 +1,28 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2016-04-03. +" @Last Change: 2016-04-03. + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#dictionary' + + +It should handle basic test cases for tlib#dictionary#Rev properly. + +Should be equal tlib#dictionary#Rev({}), {} +Should be equal tlib#dictionary#Rev({1: 2, 3: 4}), {'2': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'empty': '*'}), {'*': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'''''': '1', '4': '3'} +Should be equal tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1, 'use_eval': 1}), {'''''': 1, '4': 3} +Should be equal tlib#dictionary#Rev(tlib#dictionary#Rev({1: '', 3: 4}, {'use_string': 1}), {'use_eval': 1}), {1: '', 3: 4} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1}), {'4': ['1', '2']} +Should be equal tlib#dictionary#Rev({1: 4, 2: 4}, {'values_as_list': 1, 'use_eval': 1}), {'4': [1, 2]} + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/eval.vim b/sources_non_forked/tlib/spec/tlib/eval.vim new file mode 100644 index 00000000..40c51386 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/eval.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2015-10-26. +" @Last Change: 2015-10-26. + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib#eval' + + +let g:eval_a = {'foo': range(0, 5), 'd': {'a': range(0, 5)}} +let g:eval_b = {'foo': range(6, 10), 'd': {'a': range(6, 10), 'b': 2}, 'bar': range(5)} +let g:eval_a0 = deepcopy(g:eval_a) +let g:eval_b0 = deepcopy(g:eval_b) +let g:eval_c = {'foo': range(0, 10), 'd': {'a': range(0, 10), 'b': 2}, 'bar': range(5)} + + +Should be equal tlib#eval#Extend(copy(g:eval_a), g:eval_b), g:eval_c +Should be equal g:eval_a, g:eval_a0 +Should be equal g:eval_b, g:eval_b0 + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/file.vim b/sources_non_forked/tlib/spec/tlib/file.vim new file mode 100644 index 00000000..f692abfc --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/file.vim @@ -0,0 +1,59 @@ +" @Author: Thomas Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-25. +" @Last Change: 2010-04-03. +" @Revision: 13 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib/file', + \ 'sfile': 'autoload/tlib/file.vim' + + + +It should split filenames. +Should be equal tlib#file#Split('foo/bar/filename.txt'), ['foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('/foo/bar/filename.txt'), ['', 'foo', 'bar', 'filename.txt'] +Should be equal tlib#file#Split('ftp://foo/bar/filename.txt'), ['ftp:/', 'foo', 'bar', 'filename.txt'] + + +It should join filenames. +Should be#Equal tlib#file#Join(['foo', 'bar']), 'foo/bar' +Should be#Equal tlib#file#Join(['foo/', 'bar'], 1), 'foo/bar' +Should be#Equal tlib#file#Join(['', 'bar']), '/bar' +Should be#Equal tlib#file#Join(['/', 'bar'], 1), '/bar' +Should be#Equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' +Should be#Equal tlib#file#Join(['ftp://', 'foo', 'bar', 'filename.txt'], 1), 'ftp://foo/bar/filename.txt' + +Should be equal tlib#file#Join(['foo', 'bar', 'filename.txt']), 'foo/bar/filename.txt' +Should be equal tlib#file#Join(['', 'foo', 'bar', 'filename.txt']), '/foo/bar/filename.txt' +Should be equal tlib#file#Join(['ftp:/', 'foo', 'bar', 'filename.txt']), 'ftp://foo/bar/filename.txt' + + +It should construct relative path names. +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be#Equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be#Equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be#Equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be#Equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo'), 'bar/filename.txt' +Should be equal tlib#file#Relative('foo/bar/filename.txt', 'foo/base'), '../bar/filename.txt' +Should be equal tlib#file#Relative('filename.txt', 'foo/base'), '../../filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/boo/base'), '../../foo/bar/filename.txt' +Should be equal tlib#file#Relative('/bar/filename.txt', '/boo/base'), '../../bar/filename.txt' +Should be equal tlib#file#Relative('/foo/bar/filename.txt', '/base'), '../foo/bar/filename.txt' +Should be equal tlib#file#Relative('c:/bar/filename.txt', 'x:/boo/base'), 'c:/bar/filename.txt' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/hash.vim b/sources_non_forked/tlib/spec/tlib/hash.vim new file mode 100644 index 00000000..a2403a3d --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/hash.vim @@ -0,0 +1,58 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Revision: 31 + + +SpecBegin 'title': 'tlib#hash' + + +It should calculate CRC32B checksums. + +let g:tlib_hash_use_crc32 = g:tlib#hash#use_crc32 + +let g:tlib#hash#use_crc32 = 'ruby' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + +let g:tlib#hash#use_crc32 = 'vim' +Should be equal tlib#hash#CRC32B('The quick brown fox jumps over the lazy dog'), '414FA339' +Should be equal tlib#hash#CRC32B('foo'), '8C736521' +Should be equal tlib#hash#CRC32B('f'), '76D32BE0' + + +function! s:CompareHash(text) "{{{3 + if !empty(a:text) + exec 'It should calculate the crc32b checksum for:' a:text + let crc32ruby = tlib#hash#CRC32B_ruby(a:text) + let crc32vim = tlib#hash#CRC32B_vim(a:text) + exec 'Should be equal' string(crc32ruby) ',' string(crc32vim) + exec 'It should calculate the adler32 checksum for:' a:text + let adler32tlib = tlib#hash#Adler32_tlib(a:text) + let adler32vim = tlib#hash#Adler32_vim(a:text) + exec 'Should be equal' string(adler32tlib) ',' string(adler32vim) + endif +endf + +redir => s:scriptnames +silent scriptnames +redir END +for s:script in split(s:scriptnames, '\n') + let s:scriptfile = matchstr(s:script, '^\s*\d\+:\s\+\zs.*$') + call s:CompareHash(s:scriptfile) + try + let s:scriptlines = readfile(s:scriptfile) + call s:CompareHash(join(s:scriptlines, "\n")) + for s:scriptline in s:scriptlines + call s:CompareHash(s:scriptline) + endfor + catch /^Vim\%((\a\+)\)\=:E484/ + endtry +endfor +unlet s:scriptnames, :script, s:scriptfile, s:scriptlines, s:scriptline +delf s:CompareHash + + +let g:tlib#hash#use_crc32 = g:tlib_hash_use_crc32 + diff --git a/sources_non_forked/tlib/spec/tlib/input.vim b/sources_non_forked/tlib/spec/tlib/input.vim new file mode 100644 index 00000000..f82aea6c --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/input.vim @@ -0,0 +1,127 @@ +" @Author: Tom Link (micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @GIT: http://github.com/tomtom/vimtlib/ +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2009-02-28. +" @Last Change: 2009-03-14. +" @Revision: 73 + +let s:save_cpo = &cpo +set cpo&vim + + +SpecBegin 'title': 'tlib: Input', 'scratch': '%', + \ 'after': ':unlet! g:spec_lib_rv', + \ 'options': [ + \ 'vim', + \ ] + + +let g:spec_tlib_list = [10, 20, 30, 40, 'a50', 'aa60', 'b70', 'ba80', 90] + + + +It should return empty values when the user presses . +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, '' + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, [] + +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 0 + + + +It should pick an item from s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 30 + + + +It should return an index from si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal g:spec_lib_rv, 3 + + + +It should return a list from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 40] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [20, 30] + + + +It should return a list of indices from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \#\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 4] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ \\\\ +Should be#Equal sort(g:spec_lib_rv), [2, 3] + + + +It should filter items from a s-type list. +Replay :let g:spec_lib_rv = tlib#input#List('s', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 'aa60' + + + +It should filter items from a si-type list. +Replay :let g:spec_lib_rv = tlib#input#List('si', '', g:spec_tlib_list)\ + \ \a\\ +Should be#Equal g:spec_lib_rv, 6 + + + +It should filter items from a m-type list. +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + +Replay :let g:spec_lib_rv = tlib#input#List('m', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), ['aa60', 'ba80'] + + + +It should filter items from a mi-type list. +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\#\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + +Replay :let g:spec_lib_rv = tlib#input#List('mi', '', g:spec_tlib_list)\ + \ a\\\\ +Should be#Equal sort(g:spec_lib_rv), [6, 8] + + + +let &cpo = s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/list.vim b/sources_non_forked/tlib/spec/tlib/list.vim new file mode 100644 index 00000000..d4aae54a --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/list.vim @@ -0,0 +1,67 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib: List' + " \, 'options': [vim, <+SET+>] + " \, 'sfile': '<+SCRIPT CONTEXT+>' + " \, 'scratch': '<+SCRATCH FILE+>' + " \, 'before': '<+BEFORE EX COMMANDS+>' + " \, 'after': '<+AFTER EX COMMANDS+>' + " \, 'cleanup': ['<+FUNCTION+>()'] + + +" List {{{2 +fun! Add(a,b) + return a:a + a:b +endf + +Should be equal tlib#list#Inject([], 0, function('Add')), 0 +Should be equal tlib#list#Inject([1,2,3], 0, function('Add')), 6 + +Should be equal tlib#list#Compact([]), [] +Should be equal tlib#list#Compact([0,1,2,3,[], {}, ""]), [1,2,3] + +Should be equal tlib#list#Flatten([]), [] +Should be equal tlib#list#Flatten([1,2,3]), [1,2,3] +Should be equal tlib#list#Flatten([1,2, [1,2,3], 3]), [1,2,1,2,3,3] +Should be equal tlib#list#Flatten([0,[1,2,[3,""]]]), [0,1,2,3,""] + +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2'), [2,3] +Should be equal tlib#list#FindAll([1,2,3], 'v:val >= 2', 'v:val * 10'), [20,30] + +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2'), 2 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 2', 0, 'v:val * 10'), 20 +Should be equal tlib#list#Find([1,2,3], 'v:val >= 5', 10), 10 + +Should be equal tlib#list#Any([1,2,3], 'v:val >= 2'), 1 +Should be equal tlib#list#Any([1,2,3], 'v:val >= 5'), 0 + +Should be equal tlib#list#All([1,2,3], 'v:val < 5'), 1 +Should be equal tlib#list#All([1,2,3], 'v:val >= 2'), 0 + +Should be equal tlib#list#Remove([1,2,1,2], 2), [1,1,2] +Should be equal tlib#list#RemoveAll([1,2,1,2], 2), [1,1] + +Should be equal tlib#list#Zip([[1,2,3], [4,5,6]]), [[1,4], [2,5], [3,6]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]]), [[1,4], [2,5], [3,6], ['', 7]] +Should be equal tlib#list#Zip([[1,2,3], [4,5,6,7]], -1), [[1,4], [2,5], [3,6], [-1,7]] +Should be equal tlib#list#Zip([[1,2,3,7], [4,5,6]], -1), [[1,4], [2,5], [3,6], [7,-1]] + + +Should be equal tlib#list#Uniq([]), [] +Should be equal tlib#list#Uniq([1,1]), [1] +Should be equal tlib#list#Uniq([1,2,2,3,2,3,4,2,1,7,2,3,2,3,7]), [1,2,3,4,7] + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/rx.vim b/sources_non_forked/tlib/spec/tlib/rx.vim new file mode 100644 index 00000000..fc281035 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/rx.vim @@ -0,0 +1,27 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#rx' + + +for c in split('^$.*+\()|{}[]~', '\zs') + let s = printf('%sfoo%sbar%s', c, c, c) + Should be like s, '\m^'. tlib#rx#Escape(s, 'm') .'$' + Should be like s, '\M^'. tlib#rx#Escape(s, 'M') .'$' + Should be like s, '\v^'. tlib#rx#Escape(s, 'v') .'$' + Should be like s, '\V\^'. tlib#rx#Escape(s, 'V') .'\$' +endfor + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/string.vim b/sources_non_forked/tlib/spec/tlib/string.vim new file mode 100644 index 00000000..4329d946 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/string.vim @@ -0,0 +1,29 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 4 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#string' + +Should be equal tlib#string#RemoveBackslashes('foo bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ bar'), 'foo bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar'), 'foo \\bar' +Should be equal tlib#string#RemoveBackslashes('foo\ \\bar', '\ '), 'foo \bar' + + +Should be equal tlib#string#Count("fooo", "o"), 3 +Should be equal tlib#string#Count("***", "\\*"), 3 +Should be equal tlib#string#Count("***foo", "\\*"), 3 +Should be equal tlib#string#Count("foo***", "\\*"), 3 + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/url.vim b/sources_non_forked/tlib/spec/tlib/url.vim new file mode 100644 index 00000000..80783e9c --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/url.vim @@ -0,0 +1,23 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#url' + +Should be equal tlib#url#Decode('http://example.com/foo+bar%25bar'), 'http://example.com/foo bar%bar' +Should be equal tlib#url#Decode('Hello%20World.%20%20Good%2c%20bye.'), 'Hello World. Good, bye.' + +Should be equal tlib#url#Encode('foo bar%bar'), 'foo+bar%%bar' +Should be equal tlib#url#Encode('Hello World. Good, bye.'), 'Hello+World.+Good%2c+bye.' + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/tlib/spec/tlib/var.vim b/sources_non_forked/tlib/spec/tlib/var.vim new file mode 100644 index 00000000..28e3fac8 --- /dev/null +++ b/sources_non_forked/tlib/spec/tlib/var.vim @@ -0,0 +1,37 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: http://www.vim.org/account/profile.php?user_id=4037 +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Created: 2010-04-03. +" @Last Change: 2010-04-03. +" @Revision: 2 + +let s:save_cpo = &cpo +set cpo&vim + + + +SpecBegin 'title': 'tlib#var' + + +let g:foo = 1 +let g:bar = 2 +let b:bar = 3 +let s:bar = 4 + +Should be equal tlib#var#Get('bar', 'bg'), 3 +Should be equal tlib#var#Get('bar', 'g'), 2 +Should be equal tlib#var#Get('foo', 'bg'), 1 +Should be equal tlib#var#Get('foo', 'g'), 1 +Should be equal tlib#var#Get('none', 'l'), '' + +Should be equal eval(tlib#var#EGet('bar', 'bg')), 3 +Should be equal eval(tlib#var#EGet('bar', 'g')), 2 +" Should be equal eval(tlib#var#EGet('bar', 'sg')), 4 +Should be equal eval(tlib#var#EGet('foo', 'bg')), 1 +Should be equal eval(tlib#var#EGet('foo', 'g')), 1 +Should be equal eval(tlib#var#EGet('none', 'l')), '' + + + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/sources_non_forked/typescript-vim/README.md b/sources_non_forked/typescript-vim/README.md new file mode 100644 index 00000000..a8809983 --- /dev/null +++ b/sources_non_forked/typescript-vim/README.md @@ -0,0 +1,136 @@ +Typescript Syntax for Vim +========================= + +Syntax file and other settings for [TypeScript](http://typescriptlang.org). The +syntax file is taken from this [blog +post](https://docs.microsoft.com/en-us/archive/blogs/interoperability/sublime-text-vi-emacs-typescript-enabled). + +Checkout [Tsuquyomi](https://github.com/Quramy/tsuquyomi) for omni-completion +and other features for TypeScript editing. + +Install +------- + +From Vim 8 onward, the plugin can be installed as simply as (Unix/Mac): +``` +git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/pack/typescript/start/typescript-vim +``` + +On Windows/Powershell, use the following: +``` +git clone https://github.com/leafgarland/typescript-vim.git $home/vimfiles/pack/typescript/start/typescript-vim +``` + +For older versions of Vim, the simplest way to install is via a Vim add-in manager such as +[Plug](https://github.com/junegunn/vim-plug), +[Vundle](https://github.com/gmarik/vundle) or +[Pathogen](https://github.com/tpope/vim-pathogen/). + +_See the [Installation Wiki](https://github.com/leafgarland/typescript-vim/wiki/Installation)_ + +### Pathogen + +``` +git clone https://github.com/leafgarland/typescript-vim.git ~/.vim/bundle/typescript-vim +``` + +If you want to install manually then you need to copy the files from this +repository into your vim path, see the vim docs for [:help +runtimepath](http://vimdoc.sourceforge.net/htmldoc/options.html#'runtimepath') +for more information. This might be as simple as copying the files and +directories to `~/.vim/` but it depends on your Vim install and operating +system. + +Usage +----- + +Once the files are installed the syntax highlighting and other settings will be +automatically enabled anytime you edit a `.ts` file. + +Indenting +--------- + +This plugin includes a custom indenter (based on [pangloss/vim-javascript's +indenter](https://github.com/pangloss/vim-javascript/blob/master/indent/javascript.vim)), +it works pretty well but there are cases where it fails. If these bother you or +want to use other indent settings you can disable it by setting a flag in your +`.vimrc`: + +```vim +let g:typescript_indent_disable = 1 +``` + +If you want the indenter to automatically indent chained method calls as you type. + +```typescript +something + .foo() + .bar(); +``` + +Then add something like `setlocal indentkeys+=0.` to your `.vimrc`, see `:help +'indentkeys'` in vim for more information. + +If you use the `=` operator to re-indent code it will always indent +chained method calls - this can be disabled by changing the regex the +indent script uses to identify indented lines. In this case removing '.' +from the regex means that it wont indent lines starting with '.'. Note, +this is not ideal as the regex may change making your setting out of date. + +```vim +let g:typescript_opfirst='\%([<>=,?^%|*/&]\|\([-:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)' +``` + +Compiler settings +----------------- + +This plugin contains compiler settings to set `makeprg` and `errorformat`. +The compiler settings enable you to call the `tsc` compiler directly from Vim +and display any errors or warnings in Vim's QuickFix window. + +To run the compiler, enter `:make`, this will run `tsc` against the last saved +version of your currently edited file. + +The default for `makeprg` is `tsc $* %`. You can enter other compiler options into your `:make` +command line and they will be inserted in place of `$*`. + +There are options to change the compiler name and to insert default options. + +```vim +let g:typescript_compiler_binary = 'tsc' +let g:typescript_compiler_options = '' +``` + +These options will be passed to the binary as command arguments. For example, +if `g:typescript_compiler_binary = 'tsc'` and `g:typescript_compiler_options = '--lib es6'`, +`l:makeprg` will be: `tsc --lib es6 $* %`. + +You can completely override this plugin's compiler settings with something like +this in your `.vimrc`, where you can set makeprg to whatever you want. + +```vim + autocmd FileType typescript :set makeprg=tsc +``` + +Note, this plugin's compiler settings are not used by Syntastic which has its own +way of changing the options. See https://github.com/scrooloose/syntastic#faqargs. + +You can use something like this in your `.vimrc` to make the QuickFix +window automatically appear if `:make` has any errors. + +```vim +autocmd QuickFixCmdPost [^l]* nested cwindow +autocmd QuickFixCmdPost l* nested lwindow +``` + +Syntax highlighting +------------------- + +Syntax highlighting for TypeScript can be customized by following variables. + +- `g:typescript_ignore_typescriptdoc`: When this variable is defined, doccomments will not be + highlighted. +- `g:typescript_ignore_browserwords`: When this variable is set to `1`, browser API names such as + `window` or `document` will not be highlighted. (default to `0`) + +![Obligatory screenshot](https://raw.github.com/leafgarland/typescript-vim/master/vimshot01.png) diff --git a/sources_non_forked/typescript-vim/compiler/typescript.vim b/sources_non_forked/typescript-vim/compiler/typescript.vim new file mode 100644 index 00000000..77121eb5 --- /dev/null +++ b/sources_non_forked/typescript-vim/compiler/typescript.vim @@ -0,0 +1,30 @@ +if exists("current_compiler") + finish +endif +let current_compiler = "typescript" + +if !exists("g:typescript_compiler_binary") + let g:typescript_compiler_binary = "tsc" +endif + +if !exists("g:typescript_compiler_options") + let g:typescript_compiler_options = "" +endif + +if exists(":CompilerSet") != 2 + command! -nargs=* CompilerSet setlocal +endif + +let s:cpo_save = &cpo +set cpo-=C + +execute 'CompilerSet makeprg=' + \ . escape(g:typescript_compiler_binary, ' ') + \ . '\ ' + \ . escape(g:typescript_compiler_options, ' ') + \ . '\ $*\ %' + +CompilerSet errorformat=%+A\ %#%f\ %#(%l\\\,%c):\ %m,%C%m + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/sources_non_forked/typescript-vim/compiler/typescriptreact.vim b/sources_non_forked/typescript-vim/compiler/typescriptreact.vim new file mode 100644 index 00000000..0f734095 --- /dev/null +++ b/sources_non_forked/typescript-vim/compiler/typescriptreact.vim @@ -0,0 +1 @@ +runtime! compiler/typescript.vim diff --git a/sources_non_forked/typescript-vim/ftdetect/typescript.vim b/sources_non_forked/typescript-vim/ftdetect/typescript.vim new file mode 100644 index 00000000..7c102061 --- /dev/null +++ b/sources_non_forked/typescript-vim/ftdetect/typescript.vim @@ -0,0 +1,4 @@ +" use `set filetype` to override default filetype=xml for *.ts files +autocmd BufNewFile,BufRead *.ts set filetype=typescript +" use `setfiletype` to not override any other plugins like ianks/vim-tsx +autocmd BufNewFile,BufRead *.tsx setfiletype typescript diff --git a/sources_non_forked/typescript-vim/ftplugin/typescript.vim b/sources_non_forked/typescript-vim/ftplugin/typescript.vim new file mode 100644 index 00000000..da4b1e85 --- /dev/null +++ b/sources_non_forked/typescript-vim/ftplugin/typescript.vim @@ -0,0 +1,21 @@ +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo-=C + +compiler typescript +setlocal commentstring=//\ %s + +" Set 'formatoptions' to break comment lines but not other lines, +" " and insert the comment leader when hitting or using "o". +setlocal formatoptions-=t formatoptions+=croql + +setlocal suffixesadd+=.ts,.tsx + +let b:undo_ftplugin = "setl fo< ofu< com< cms<" + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim b/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim new file mode 100644 index 00000000..c23ec132 --- /dev/null +++ b/sources_non_forked/typescript-vim/ftplugin/typescriptreact.vim @@ -0,0 +1 @@ +runtime! ftplugin/typescript.vim diff --git a/sources_non_forked/typescript-vim/indent/typescript.vim b/sources_non_forked/typescript-vim/indent/typescript.vim new file mode 100644 index 00000000..3ee9aa01 --- /dev/null +++ b/sources_non_forked/typescript-vim/indent/typescript.vim @@ -0,0 +1,360 @@ +" Vim indent file +" Language: Typescript +" Acknowledgement: Almost direct copy from https://github.com/pangloss/vim-javascript + +" Only load this indent file when no other was loaded. +if exists('b:did_indent') || get(g:, 'typescript_indent_disable', 0) + finish +endif +let b:did_indent = 1 + +" Now, set up our indentation expression and keys that trigger it. +setlocal indentexpr=GetTypescriptIndent() +setlocal autoindent nolisp nosmartindent +setlocal indentkeys+=0],0) + +let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<' + +" Only define the function once. +if exists('*GetTypescriptIndent') + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" Get shiftwidth value +if exists('*shiftwidth') + function s:sw() + return shiftwidth() + endfunction +else + function s:sw() + return &sw + endfunction +endif + +" searchpair() wrapper +if has('reltime') + function s:GetPair(start,end,flags,skip,time,...) + return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time) + endfunction +else + function s:GetPair(start,end,flags,skip,...) + return searchpair('\m'.a:start,'','\m'.a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 1000,get(a:000,1)])) + endfunction +endif + +" Regex of syntax group names that are or delimit string or are comments. +let s:syng_strcom = 'string\|comment\|regex\|special\|doc\|template\%(braces\)\@!' +let s:syng_str = 'string\|template\|special' +let s:syng_com = 'comment\|doc' +" Expression used to check whether we should skip a match with searchpair(). +let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'" + +function s:skip_func() + if !s:free || search('\m`\|\${\|\*\/','nW',s:looksyn) + let s:free = !eval(s:skip_expr) + let s:looksyn = line('.') + return !s:free + endif + let s:looksyn = line('.') + return getline('.') =~ '\%<'.col('.').'c\/.\{-}\/\|\%>'.col('.').'c[''"]\|\\$' && + \ eval(s:skip_expr) +endfunction + +function s:alternatePair(stop) + let pos = getpos('.')[1:2] + while search('\m[][(){}]','bW',a:stop) + if !s:skip_func() + let idx = stridx('])}',s:looking_at()) + if idx + 1 + if s:GetPair(['\[','(','{'][idx], '])}'[idx],'bW','s:skip_func()',2000,a:stop) <= 0 + break + endif + else + return + endif + endif + endwhile + call call('cursor',pos) +endfunction + +function s:save_pos(f,...) + let l:pos = getpos('.')[1:2] + let ret = call(a:f,a:000) + call call('cursor',l:pos) + return ret +endfunction + +function s:syn_at(l,c) + return synIDattr(synID(a:l,a:c,0),'name') +endfunction + +function s:looking_at() + return getline('.')[col('.')-1] +endfunction + +function s:token() + return s:looking_at() =~ '\k' ? expand('') : s:looking_at() +endfunction + +function s:previous_token() + let l:n = line('.') + if (s:looking_at() !~ '\k' || search('\m\<','cbW')) && search('\m\S','bW') + if (getline('.')[col('.')-2:col('.')-1] == '*/' || line('.') != l:n && + \ getline('.') =~ '\%<'.col('.').'c\/\/') && s:syn_at(line('.'),col('.')) =~? s:syng_com + while search('\m\/\ze[/*]','cbW') + if !search('\m\S','bW') + break + elseif s:syn_at(line('.'),col('.')) !~? s:syng_com + return s:token() + endif + endwhile + else + return s:token() + endif + endif + return '' +endfunction + +function s:others(p) + return "((line2byte(line('.')) + col('.')) <= ".(line2byte(a:p[0]) + a:p[1]).") || ".s:skip_expr +endfunction + +function s:tern_skip(p) + return s:GetPair('{','}','nbW',s:others(a:p),200,a:p[0]) > 0 +endfunction + +function s:tern_col(p) + return s:GetPair('?',':\@ 0 +endfunction + +function s:label_col() + let pos = getpos('.')[1:2] + let [s:looksyn,s:free] = pos + call s:alternatePair(0) + if s:save_pos('s:IsBlock') + let poss = getpos('.')[1:2] + return call('cursor',pos) || !s:tern_col(poss) + elseif s:looking_at() == ':' + return !s:tern_col([0,0]) + endif +endfunction + +" configurable regexes that define continuation lines, not including (, {, or [. +let s:opfirst = '^' . get(g:,'typescript_opfirst', + \ '\%([<>=,?^%|*/&]\|\([-.:+]\)\1\@!\|!=\|in\%(stanceof\)\=\>\)') +let s:continuation = get(g:,'typescript_continuation', + \ '\%([-+<>=,.~!?/*^%|&:]\|\<\%(typeof\|delete\|void\|in\|instanceof\)\)') . '$' + +function s:continues(ln,con) + return !cursor(a:ln, match(' '.a:con,s:continuation)) && + \ eval( (['s:syn_at(line("."),col(".")) !~? "regex"'] + + \ repeat(['getline(".")[col(".")-2] != tr(s:looking_at(),">","=")'],3) + + \ repeat(['s:previous_token() != "."'],5) + [1])[ + \ index(split('/ > - + typeof in instanceof void delete'),s:token())]) +endfunction + +" get the line of code stripped of comments and move cursor to the last +" non-comment char. +function s:Trim(ln) + call cursor(a:ln+1,1) + call s:previous_token() + return strpart(getline('.'),0,col('.')) +endfunction + +" Find line above 'lnum' that isn't empty or in a comment +function s:PrevCodeLine(lnum) + let l:n = prevnonblank(a:lnum) + while l:n + if getline(l:n) =~ '^\s*\/[/*]' + if (stridx(getline(l:n),'`') > 0 || getline(l:n-1)[-1:] == '\') && + \ s:syn_at(l:n,1) =~? s:syng_str + return l:n + endif + let l:n = prevnonblank(l:n-1) + elseif getline(l:n) =~ '\([/*]\)\1\@![/*]' && s:syn_at(l:n,1) =~? s:syng_com + let l:n = s:save_pos('eval', + \ 'cursor('.l:n.',1) + search(''\m\/\*'',"bW")') + else + return l:n + endif + endwhile +endfunction + +" Check if line 'lnum' has a balanced amount of parentheses. +function s:Balanced(lnum) + let l:open = 0 + let l:line = getline(a:lnum) + let pos = match(l:line, '[][(){}]', 0) + while pos != -1 + if s:syn_at(a:lnum,pos + 1) !~? s:syng_strcom + let l:open += match(' ' . l:line[pos],'[[({]') + if l:open < 0 + return + endif + endif + let pos = match(l:line, '[][(){}]', pos + 1) + endwhile + return !l:open +endfunction + +function s:OneScope(lnum) + let pline = s:Trim(a:lnum) + let kw = 'else do' + if pline[-1:] == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 + call s:previous_token() + let kw = 'for if let while with' + if index(split('await each'),s:token()) + 1 + call s:previous_token() + let kw = 'for' + endif + endif + return pline[-2:] == '=>' || index(split(kw),s:token()) + 1 && + \ s:save_pos('s:previous_token') != '.' +endfunction + +" returns braceless levels started by 'i' and above lines * &sw. 'num' is the +" lineNr which encloses the entire context, 'cont' if whether line 'i' + 1 is +" a continued expression, which could have started in a braceless context +function s:iscontOne(i,num,cont) + let [l:i, l:num, bL] = [a:i, a:num + !a:num, 0] + let pind = a:num ? indent(l:num) + s:W : 0 + let ind = indent(l:i) + (a:cont ? 0 : s:W) + while l:i >= l:num && (ind > pind || l:i == l:num) + if indent(l:i) < ind && s:OneScope(l:i) + let bL += s:W + let l:i = line('.') + elseif !a:cont || bL || ind < indent(a:i) + break + endif + let ind = min([ind, indent(l:i)]) + let l:i = s:PrevCodeLine(l:i - 1) + endwhile + return bL +endfunction + +" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader +function s:IsBlock() + if s:looking_at() == '{' + let l:n = line('.') + let char = s:previous_token() + if match(s:stack,'xml\|jsx') + 1 && s:syn_at(line('.'),col('.')-1) =~? 'xml\|jsx' + return char != '{' + elseif char =~ '\k' + return index(split('return const let import export yield default delete var await void typeof throw case new in instanceof') + \ ,char) < (line('.') != l:n) || s:previous_token() == '.' + elseif char == '>' + return getline('.')[col('.')-2] == '=' || s:syn_at(line('.'),col('.')) =~? '^jsflow' + elseif char == ':' + return getline('.')[col('.')-2] != ':' && s:label_col() + elseif char == '/' + return s:syn_at(line('.'),col('.')) =~? 'regex' + endif + return char !~ '[=~!<*,?^%|&([]' && + \ (char !~ '[-+]' || l:n != line('.') && getline('.')[col('.')-2] == char) + endif +endfunction + +function GetTypescriptIndent() + let b:js_cache = get(b:,'js_cache',[0,0,0]) + " Get the current line. + call cursor(v:lnum,1) + let l:line = getline('.') + " use synstack as it validates syn state and works in an empty line + let s:stack = synstack(v:lnum,1) + let syns = synIDattr(get(s:stack,-1),'name') + + " start with strings,comments,etc. + if syns =~? s:syng_com + if l:line =~ '^\s*\*' + return cindent(v:lnum) + elseif l:line !~ '^\s*\/[/*]' + return -1 + endif + elseif syns =~? s:syng_str && l:line !~ '^[''"]' + if b:js_cache[0] == v:lnum - 1 && s:Balanced(v:lnum-1) + let b:js_cache[0] = v:lnum + endif + return -1 + endif + let l:lnum = s:PrevCodeLine(v:lnum - 1) + if !l:lnum + return + endif + + let l:line = substitute(l:line,'^\s*','','') + if l:line[:1] == '/*' + let l:line = substitute(l:line,'^\%(\/\*.\{-}\*\/\s*\)*','','') + endif + if l:line =~ '^\/[/*]' + let l:line = '' + endif + + " the containing paren, bracket, curly, or closing '>'. + " Many hacks for performance + let idx = index([']',')','}','>'],l:line[0]) + if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum && + \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) + call call('cursor',b:js_cache[1:]) + else + let [s:looksyn, s:free, top] = [v:lnum - 1, 1, (!indent(l:lnum) && + \ s:syn_at(l:lnum,1) !~? s:syng_str) * l:lnum] + if idx + 1 + call s:GetPair(['\[','(','{'][idx],'])}'[idx],'bW','s:skip_func()',2000,top) + elseif getline(v:lnum) !~ '^\S' && syns =~? 'block' + call s:GetPair('{','}','bW','s:skip_func()',2000,top) + else + call s:alternatePair(top) + endif + endif + + let b:js_cache = [v:lnum] + (line('.') == v:lnum ? [0,0] : getpos('.')[1:2]) + let num = b:js_cache[1] + + let [s:W, isOp, bL, switch_offset] = [s:sw(),0,0,0] + if !num || s:IsBlock() + let ilnum = line('.') + let pline = s:save_pos('s:Trim',l:lnum) + if num && s:looking_at() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 + let num = ilnum == num ? line('.') : num + if idx < 0 && s:previous_token() ==# 'switch' && s:previous_token() != '.' + if &cino !~ ':' + let switch_offset = s:W + else + let cinc = matchlist(&cino,'.*:\zs\(-\)\=\(\d*\)\(\.\d\+\)\=\(s\)\=\C') + let switch_offset = max([cinc[0] is '' ? 0 : (cinc[1].1) * + \ ((strlen(cinc[2].cinc[3]) ? str2nr(cinc[2].str2nr(cinc[3][1])) : 10) * + \ (cinc[4] is '' ? 1 : s:W)) / 10, -indent(num)]) + endif + if pline[-1:] != '.' && l:line =~# '^\%(default\|case\)\>' + return indent(num) + switch_offset + endif + endif + endif + if idx < 0 && pline !~ '[{;]$' + if pline =~# ':\@" +hi link shebang Comment + +"" typescript comments"{{{ +syn keyword typescriptCommentTodo TODO FIXME XXX TBD contained +syn match typescriptLineComment "\/\/.*" contains=@Spell,typescriptCommentTodo,typescriptRef +syn match typescriptRefComment /\/\/\/<\(reference\|amd-\(dependency\|module\)\)\s\+.*\/>$/ contains=typescriptRefD,typescriptRefS +syn region typescriptRefD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ +syn region typescriptRefS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ + +syn match typescriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" +syn region typescriptComment start="/\*" end="\*/" contains=@Spell,typescriptCommentTodo extend +"}}} +"" JSDoc support start"{{{ +if !exists("typescript_ignore_typescriptdoc") + syntax case ignore + +" syntax coloring for JSDoc comments (HTML) +"unlet b:current_syntax + + syntax region typescriptDocComment start="/\*\*\s*$" end="\*/" contains=typescriptDocTags,typescriptCommentTodo,typescriptCvsTag,@typescriptHtml,@Spell fold extend + syntax match typescriptDocTags contained "@\(param\|argument\|requires\|exception\|throws\|type\|class\|extends\|see\|link\|member\|module\|method\|title\|namespace\|optional\|default\|base\|file\|returns\=\)\>" nextgroup=typescriptDocParam,typescriptDocSeeTag skipwhite + syntax match typescriptDocTags contained "@\(beta\|deprecated\|description\|fileoverview\|author\|license\|version\|constructor\|private\|protected\|final\|ignore\|addon\|exec\)\>" + syntax match typescriptDocParam contained "\%(#\|\w\|\.\|:\|\/\)\+" + syntax region typescriptDocSeeTag contained matchgroup=typescriptDocSeeTag start="{" end="}" contains=typescriptDocTags + + syntax case match +endif "" JSDoc end +"}}} +syntax case match + +"" Syntax in the typescript code"{{{ +syn match typescriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}" contained containedin=typescriptStringD,typescriptStringS,typescriptStringB display +syn region typescriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=typescriptSpecial,@htmlPreproc extend +syn region typescriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=typescriptSpecial,@htmlPreproc extend +syn region typescriptStringB start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=typescriptInterpolation,typescriptSpecial,@htmlPreproc extend + +syn region typescriptInterpolation matchgroup=typescriptInterpolationDelimiter + \ start=/${/ end=/}/ contained + \ contains=@typescriptExpression + +syn match typescriptNumber "-\=\<\d[0-9_]*L\=\>" display +syn match typescriptNumber "-\=\<0[xX][0-9a-fA-F][0-9a-fA-F_]*\>" display +syn match typescriptNumber "-\=\<0[bB][01][01_]*\>" display +syn match typescriptNumber "-\=\<0[oO]\o[0-7_]*\>" display +syn region typescriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gimsuy]\{0,2\}\s*$+ end=+/[gimsuy]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline +" syntax match typescriptSpecial "\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\." +" syntax region typescriptStringD start=+"+ skip=+\\\\\|\\$"+ end=+"+ contains=typescriptSpecial,@htmlPreproc +" syntax region typescriptStringS start=+'+ skip=+\\\\\|\\$'+ end=+'+ contains=typescriptSpecial,@htmlPreproc +" syntax region typescriptRegexpString start=+/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gimsuy]\{,3}+ contains=typescriptSpecial,@htmlPreproc oneline +" syntax match typescriptNumber /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/ +syntax match typescriptFloat /\<-\=\%(\d[0-9_]*\.\d[0-9_]*\|\d[0-9_]*\.\|\.\d[0-9]*\)\%([eE][+-]\=\d[0-9_]*\)\=\>/ +" syntax match typescriptLabel /\(?\s*\)\@/ +"}}} +"" typescript Prototype"{{{ +syntax keyword typescriptPrototype contained prototype +"}}} +" DOM, Browser and Ajax Support {{{ +"""""""""""""""""""""""" +if get(g:, 'typescript_ignore_browserwords', 0) + syntax keyword typescriptBrowserObjects window navigator screen history location + + syntax keyword typescriptDOMObjects document event HTMLElement Anchor Area Base Body Button Form Frame Frameset Image Link Meta Option Select Style Table TableCell TableRow Textarea + syntax keyword typescriptDOMMethods contained createTextNode createElement insertBefore replaceChild removeChild appendChild hasChildNodes cloneNode normalize isSupported hasAttributes getAttribute setAttribute removeAttribute getAttributeNode setAttributeNode removeAttributeNode getElementsByTagName hasAttribute getElementById adoptNode close compareDocumentPosition createAttribute createCDATASection createComment createDocumentFragment createElementNS createEvent createExpression createNSResolver createProcessingInstruction createRange createTreeWalker elementFromPoint evaluate getBoxObjectFor getElementsByClassName getSelection getUserData hasFocus importNode + syntax keyword typescriptDOMProperties contained nodeName nodeValue nodeType parentNode childNodes firstChild lastChild previousSibling nextSibling attributes ownerDocument namespaceURI prefix localName tagName + + syntax keyword typescriptAjaxObjects XMLHttpRequest + syntax keyword typescriptAjaxProperties contained readyState responseText responseXML statusText + syntax keyword typescriptAjaxMethods contained onreadystatechange abort getAllResponseHeaders getResponseHeader open send setRequestHeader + + syntax keyword typescriptPropietaryObjects ActiveXObject + syntax keyword typescriptPropietaryMethods contained attachEvent detachEvent cancelBubble returnValue + + syntax keyword typescriptHtmlElemProperties contained className clientHeight clientLeft clientTop clientWidth dir href id innerHTML lang length offsetHeight offsetLeft offsetParent offsetTop offsetWidth scrollHeight scrollLeft scrollTop scrollWidth style tabIndex target title + + syntax keyword typescriptEventListenerKeywords contained blur click focus mouseover mouseout load item + + syntax keyword typescriptEventListenerMethods contained scrollIntoView addEventListener dispatchEvent removeEventListener preventDefault stopPropagation +endif +" }}} +"" Programm Keywords"{{{ +syntax keyword typescriptSource import export from as +syntax keyword typescriptIdentifier arguments this void +syntax keyword typescriptStorageClass let var const +syntax keyword typescriptOperator delete new instanceof typeof +syntax keyword typescriptBoolean true false +syntax keyword typescriptNull null undefined +syntax keyword typescriptMessage alert confirm prompt status +syntax keyword typescriptGlobal self top parent +syntax keyword typescriptDeprecated escape unescape all applets alinkColor bgColor fgColor linkColor vlinkColor xmlEncoding +"}}} +"" Statement Keywords"{{{ +syntax keyword typescriptConditional if else switch +syntax keyword typescriptRepeat do while for in of +syntax keyword typescriptBranch break continue yield await +syntax keyword typescriptLabel case default async readonly +syntax keyword typescriptStatement return with + +syntax keyword typescriptGlobalObjects Array Boolean Date Function Infinity JSON Math Number NaN Object Packages RegExp String Symbol netscape ArrayBuffer BigInt64Array BigUint64Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Buffer Collator DataView DateTimeFormat Intl Iterator Map Set WeakMap WeakSet NumberFormat ParallelArray Promise Proxy Reflect Uint8ClampedArray WebAssembly console document fetch window +syntax keyword typescriptGlobalNodeObjects module exports global process __dirname __filename + +syntax keyword typescriptExceptions try catch throw finally Error EvalError RangeError ReferenceError SyntaxError TypeError URIError + +syntax keyword typescriptReserved constructor declare as interface module abstract enum int short export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public type namespace from get set keyof +"}}} +"" typescript/DOM/HTML/CSS specified things"{{{ + +" typescript Objects"{{{ + syn match typescriptFunction "(super\s*|constructor\s*)" contained nextgroup=typescriptVars + syn region typescriptVars start="(" end=")" contained contains=typescriptParameters transparent keepend + syn match typescriptParameters "([a-zA-Z0-9_?.$][\w?.$]*)\s*:\s*([a-zA-Z0-9_?.$][\w?.$]*)" contained skipwhite +"}}} +" DOM2 Objects"{{{ + syntax keyword typescriptType DOMImplementation DocumentFragment Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction void any string boolean number symbol never object unknown + syntax keyword typescriptExceptions DOMException +"}}} +" DOM2 CONSTANT"{{{ + syntax keyword typescriptDomErrNo INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR + syntax keyword typescriptDomNodeConsts ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE +"}}} +" HTML events and internal variables"{{{ + syntax case ignore + syntax keyword typescriptHtmlEvents onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize onload onsubmit + syntax case match +"}}} + +" Follow stuff should be highligh within a special context +" While it can't be handled with context depended with Regex based highlight +" So, turn it off by default +if exists("typescript_enable_domhtmlcss") + +" DOM2 things"{{{ + syntax match typescriptDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/ + syntax match typescriptDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=typescriptParen skipwhite +"}}} +" HTML things"{{{ + syntax match typescriptHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/ + syntax match typescriptHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=typescriptParen skipwhite +"}}} +" CSS Styles in typescript"{{{ + syntax keyword typescriptCssStyles contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition + syntax keyword typescriptCssStyles contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition + syntax keyword typescriptCssStyles contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode + syntax keyword typescriptCssStyles contained bottom height left position right top width zIndex + syntax keyword typescriptCssStyles contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout + syntax keyword typescriptCssStyles contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop + syntax keyword typescriptCssStyles contained listStyle listStyleImage listStylePosition listStyleType + syntax keyword typescriptCssStyles contained background backgroundAttachment backgroundColor backgroundImage backgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat + syntax keyword typescriptCssStyles contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType + syntax keyword typescriptCssStyles contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText + syntax keyword typescriptCssStyles contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor +"}}} +endif "DOM/HTML/CSS + +" Highlight ways"{{{ +syntax match typescriptDotNotation "\." nextgroup=typescriptPrototype,typescriptDomElemAttrs,typescriptDomElemFuncs,typescriptDOMMethods,typescriptDOMProperties,typescriptHtmlElemAttrs,typescriptHtmlElemFuncs,typescriptHtmlElemProperties,typescriptAjaxProperties,typescriptAjaxMethods,typescriptPropietaryMethods,typescriptEventListenerMethods skipwhite skipnl +syntax match typescriptDotNotation "\.style\." nextgroup=typescriptCssStyles +"}}} + +"" end DOM/HTML/CSS specified things""}}} + + +"" Code blocks +syntax cluster typescriptAll contains=typescriptComment,typescriptLineComment,typescriptDocComment,typescriptStringD,typescriptStringS,typescriptStringB,typescriptRegexpString,typescriptNumber,typescriptFloat,typescriptDecorators,typescriptLabel,typescriptSource,typescriptType,typescriptOperator,typescriptBoolean,typescriptNull,typescriptFuncKeyword,typescriptConditional,typescriptGlobal,typescriptRepeat,typescriptBranch,typescriptStatement,typescriptGlobalObjects,typescriptMessage,typescriptIdentifier,typescriptStorageClass,typescriptExceptions,typescriptReserved,typescriptDeprecated,typescriptDomErrNo,typescriptDomNodeConsts,typescriptHtmlEvents,typescriptDotNotation,typescriptBrowserObjects,typescriptDOMObjects,typescriptAjaxObjects,typescriptPropietaryObjects,typescriptDOMMethods,typescriptHtmlElemProperties,typescriptDOMProperties,typescriptEventListenerKeywords,typescriptEventListenerMethods,typescriptAjaxProperties,typescriptAjaxMethods,typescriptFuncArg,typescriptGlobalNodeObjects + +if main_syntax == "typescript" + syntax sync clear + syntax sync ccomment typescriptComment minlines=200 +" syntax sync match typescriptHighlight grouphere typescriptBlock /{/ +endif + +syntax keyword typescriptFuncKeyword function +"syntax region typescriptFuncDef start="function" end="\(.*\)" contains=typescriptFuncKeyword,typescriptFuncArg keepend +"syntax match typescriptFuncArg "\(([^()]*)\)" contains=typescriptParens,typescriptFuncComma contained +"syntax match typescriptFuncComma /,/ contained +" syntax region typescriptFuncBlock contained matchgroup=typescriptFuncBlock start="{" end="}" contains=@typescriptAll,typescriptParensErrA,typescriptParensErrB,typescriptParen,typescriptBracket,typescriptBlock fold + +syn match typescriptBraces "[{}\[\]]" +syn match typescriptParens "[()]" +syn match typescriptEndColons "[;,]" +syn match typescriptLogicSymbols "\(&&\)\|\(||\)\|\(??\)\|\(!\)" +syn match typescriptOpSymbols "=\{1,3}\|!==\|!=\|<\|>\|>=\|<=\|++\|+=\|--\|-=" + +" typescriptFold Function {{{ + +" function! typescriptFold() + +" skip curly braces inside RegEx's and comments +syn region foldBraces start=/{/ skip=/\(\/\/.*\)\|\(\/.*\/\)/ end=/}/ transparent fold keepend extend + +" setl foldtext=FoldText() +" endfunction + +" au FileType typescript call typescriptFold() + +" }}} + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already by this script +" For version 5.8 and later: only when an item doesn't have highlighting yet +" For version 8.1.1486 and later, and nvim 0.5.0 and later: only when not done already by this script (need to override vim's new typescript support) +if version >= 508 || !exists("did_typescript_syn_inits") + if version < 508 || has('patch-8.1.1486') || has('nvim-0.5.0') + let did_typescript_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + "typescript highlighting + HiLink typescriptParameters Operator + HiLink typescriptSuperBlock Operator + + HiLink typescriptEndColons Exception + HiLink typescriptOpSymbols Operator + HiLink typescriptLogicSymbols Boolean + HiLink typescriptBraces Function + HiLink typescriptParens Operator + HiLink typescriptComment Comment + HiLink typescriptLineComment Comment + HiLink typescriptRefComment Include + HiLink typescriptRefS String + HiLink typescriptRefD String + HiLink typescriptDocComment Comment + HiLink typescriptCommentTodo Todo + HiLink typescriptCvsTag Function + HiLink typescriptDocTags Special + HiLink typescriptDocSeeTag Function + HiLink typescriptDocParam Function + HiLink typescriptStringS String + HiLink typescriptStringD String + HiLink typescriptStringB String + HiLink typescriptInterpolationDelimiter Delimiter + HiLink typescriptRegexpString String + HiLink typescriptGlobal Constant + HiLink typescriptCharacter Character + HiLink typescriptPrototype Type + HiLink typescriptConditional Conditional + HiLink typescriptBranch Conditional + HiLink typescriptIdentifier Identifier + HiLink typescriptStorageClass StorageClass + HiLink typescriptRepeat Repeat + HiLink typescriptStatement Statement + HiLink typescriptFuncKeyword Keyword + HiLink typescriptMessage Keyword + HiLink typescriptDeprecated Exception + HiLink typescriptError Error + HiLink typescriptParensError Error + HiLink typescriptParensErrA Error + HiLink typescriptParensErrB Error + HiLink typescriptParensErrC Error + HiLink typescriptReserved Keyword + HiLink typescriptOperator Operator + HiLink typescriptType Type + HiLink typescriptNull Type + HiLink typescriptNumber Number + HiLink typescriptFloat Number + HiLink typescriptDecorators Special + HiLink typescriptBoolean Boolean + HiLink typescriptLabel Label + HiLink typescriptSpecial Special + HiLink typescriptSource Special + HiLink typescriptGlobalObjects Special + HiLink typescriptGlobalNodeObjects Special + HiLink typescriptExceptions Special + + HiLink typescriptDomErrNo Constant + HiLink typescriptDomNodeConsts Constant + HiLink typescriptDomElemAttrs Label + HiLink typescriptDomElemFuncs PreProc + + HiLink typescriptHtmlElemAttrs Label + HiLink typescriptHtmlElemFuncs PreProc + + HiLink typescriptCssStyles Label + + " Ajax Highlighting + HiLink typescriptBrowserObjects Constant + + HiLink typescriptDOMObjects Constant + HiLink typescriptDOMMethods Function + HiLink typescriptDOMProperties Special + + HiLink typescriptAjaxObjects Constant + HiLink typescriptAjaxMethods Function + HiLink typescriptAjaxProperties Special + + HiLink typescriptFuncDef Title + HiLink typescriptFuncArg Special + HiLink typescriptFuncComma Operator + + HiLink typescriptHtmlEvents Special + HiLink typescriptHtmlElemProperties Special + + HiLink typescriptEventListenerKeywords Keyword + + HiLink typescriptNumber Number + HiLink typescriptPropietaryObjects Constant + + delcommand HiLink +endif + +" Define the htmltypescript for HTML syntax html.vim +"syntax clear htmltypescript +"syntax clear typescriptExpression +syntax cluster htmltypescript contains=@typescriptAll,typescriptBracket,typescriptParen,typescriptBlock,typescriptParenError +syntax cluster typescriptExpression contains=@typescriptAll,typescriptBracket,typescriptParen,typescriptBlock,typescriptParenError,@htmlPreproc + +let b:current_syntax = "typescript" +if main_syntax == 'typescript' + unlet main_syntax +endif + +" vim: ts=4 diff --git a/sources_non_forked/typescript-vim/syntax/typescriptreact.vim b/sources_non_forked/typescript-vim/syntax/typescriptreact.vim new file mode 100644 index 00000000..8fc4480f --- /dev/null +++ b/sources_non_forked/typescript-vim/syntax/typescriptreact.vim @@ -0,0 +1 @@ +runtime! syntax/typescript.vim diff --git a/sources_non_forked/typescript-vim/vimshot01.png b/sources_non_forked/typescript-vim/vimshot01.png new file mode 100644 index 00000000..7c2627f9 Binary files /dev/null and b/sources_non_forked/typescript-vim/vimshot01.png differ diff --git a/sources_non_forked/vim-abolish/.github/FUNDING.yml b/sources_non_forked/vim-abolish/.github/FUNDING.yml new file mode 100644 index 00000000..e2a49d11 --- /dev/null +++ b/sources_non_forked/vim-abolish/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: tpope +custom: ["https://www.paypal.me/vimpope"] diff --git a/sources_non_forked/vim-abolish/.gitignore b/sources_non_forked/vim-abolish/.gitignore new file mode 100644 index 00000000..0a56e3fc --- /dev/null +++ b/sources_non_forked/vim-abolish/.gitignore @@ -0,0 +1 @@ +/doc/tags diff --git a/sources_non_forked/vim-abolish/CONTRIBUTING.markdown b/sources_non_forked/vim-abolish/CONTRIBUTING.markdown new file mode 100644 index 00000000..b3f00951 --- /dev/null +++ b/sources_non_forked/vim-abolish/CONTRIBUTING.markdown @@ -0,0 +1 @@ +See the [contribution guidelines for pathogen.vim](https://github.com/tpope/vim-pathogen/blob/master/CONTRIBUTING.markdown). diff --git a/sources_non_forked/vim-abolish/README.markdown b/sources_non_forked/vim-abolish/README.markdown new file mode 100644 index 00000000..e8dd0d03 --- /dev/null +++ b/sources_non_forked/vim-abolish/README.markdown @@ -0,0 +1,149 @@ +# abolish.vim + +I sat on this plugin for 3 years before releasing it, primarily +because it's so gosh darn hard to explain. It's three superficially +unrelated plugins in one that share a common theme: working with +variants of a word. + +## Abbreviation + +I know how to spell "separate". I know how to spell "desperate". My +fingers, however, have trouble distinguishing between the two, and I +invariably have a 50 percent chance of typing "seperate" or "desparate" +each time one of these comes up. At first, I tried abbreviations: + + :iabbrev seperate separate + :iabbrev desparate desperate + +But this falls short at the beginning of a sentence. + + :iabbrev Seperate Separate + :iabbrev Desparate Desperate + +To be really thorough, we need uppercase too! + + :iabbrev SEPERATE SEPARATE + :iabbrev DESPARATE DESPERATE + +Oh, but consider the noun form, and the adverb form! + + :iabbrev seperation separation + :iabbrev desparation desperation + :iabbrev seperately separately + :iabbrev desparately desperately + :iabbrev Seperation separation + :iabbrev Desparation Desperation + :iabbrev Seperately Separately + :iabbrev Desparately Desperately + :iabbrev SEPERATION SEPARATION + :iabbrev DESPARATION DESPERATION + :iabbrev SEPERATELY SEPARATELY + :iabbrev DESPARATELY DESPERATELY + +Wait, there's also "separates", "separated", "separating", +"separations", "separator"... + +Abolish.vim provides a simpler way. The following one command produces +48 abbreviations including all of the above. + + :Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{} + +My current configuration has 25 Abolish commands that create hundreds of +corrections my fingers refuse to learn. + +## Substitution + +One time I had an application with a domain model called +"facility" that needed to be renamed to "building". So, a simple +search and replace, right? + + :%s/facility/building/g + +Oh, but the case variants! + + :%s/Facility/Building/g + :%s/FACILITY/BUILDING/g + +Wait, the plural is more than "s" so we need to get that too! + + :%s/facilities/buildings/g + :%s/Facilities/Buildings/g + :%s/FACILITIES/BUILDINGS/g + +Abolish.vim has your back. One command to do all six, and you can +repeat it with `&` too! + + :%Subvert/facilit{y,ies}/building{,s}/g + +From a conceptual level, one way to think about how this substitution +works is to imagine that in the braces you are declaring the +requirements for turning that word from singular to plural. In +the facility example, the same base letters in both the singular +and plural form of the word are `facilit` To turn "facility" to a +plural word you must change the `y` to `ies` so you specify +`{y,ies}` in the braces. + +To convert the word "building" from singular to plural, again +look at the common letters between the singular and plural forms: +`building`. In this case you do not need to remove any letter +from building to turn it into plural form and you need to +add an `s` so the braces should be `{,s}`. + +A few more examples: + +Address to Reference + + :Subvert/address{,es}/reference{,s}/g + +Blog to Post (you can just do this with a regular :s also) + + :Subvert/blog{,s}/post{,s}/g + +Child to Adult + + :Subvert/child{,ren}/adult{,s}/g + +Be amazed as it correctly turns the word children into the word adults! + +Die to Spinner + + :Subvert/di{e,ce}/spinner{,s}/g + +You can abbreviate it as `:S`, and it accepts the full range of flags +including things like `c` (confirm). + +There's also a variant for searching and a variant for grepping. + +## Coercion + +Want to turn `fooBar` into `foo_bar`? Press `crs` (coerce to +snake\_case). MixedCase (`crm`), camelCase (`crc`), snake\_case +(`crs`), UPPER\_CASE (`cru`), dash-case (`cr-`), dot.case (`cr.`), +space case (`cr`), and Title Case (`crt`) are all just 3 +keystrokes away. + +## Installation + +If you don't have a preferred installation method, I recommend +installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and +then simply copy and paste: + + cd ~/.vim/bundle + git clone git://github.com/tpope/vim-abolish.git + +Once help tags have been generated, you can view the manual with +`:help abolish`. + +## Self-Promotion + +Like abolish.vim? Follow the repository on +[GitHub](https://github.com/tpope/vim-abolish) and vote for it on +[vim.org](http://www.vim.org/scripts/script.php?script_id=1545). And if +you're feeling especially charitable, follow [tpope](http://tpo.pe/) on +[Twitter](http://twitter.com/tpope) and +[GitHub](https://github.com/tpope). + +## License + +Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. +See `:help license`. diff --git a/sources_non_forked/vim-abolish/doc/abolish.txt b/sources_non_forked/vim-abolish/doc/abolish.txt new file mode 100644 index 00000000..91f24da9 --- /dev/null +++ b/sources_non_forked/vim-abolish/doc/abolish.txt @@ -0,0 +1,181 @@ +*abolish.txt* Language friendly searches, substitutions, and abbreviations + +Author: Tim Pope +License: Same terms as Vim itself (see |license|) + +This plugin is only available if 'compatible' is not set. + +INTRODUCTION *abolish* *:Abolish* *:Subvert* + +Abolish lets you quickly find, substitute, and abbreviate several variations +of a word at once. By default, three case variants (foo, Foo, and FOO) are +operated on by every command. + +Two commands are provided. :Abolish is the most general interface. +:Subvert provides an alternative, more concise syntax for searching and +substituting. +> + :Abolish [options] {abbreviation} {replacement} + :Abolish -delete [options] {abbreviation} + + :Abolish -search [options] {pattern} + :Subvert/{pattern}[/flags] + :Abolish!-search [options] {pattern} + :Subvert?{pattern}[?flags] + + :Abolish -search [options] {pattern} {grep-arguments} + :Subvert /{pattern}/[flags] {grep-options} + :Abolish!-search [options] {pattern} {grep-arguments} + :Subvert!/{pattern}/[flags] {grep-options} + + :[range]Abolish -substitute [options] {pattern} {replacement} + :[range]Subvert/{pattern}/{replacement}[/flags] +< + *:S* +In addition to the :Subvert command, a :S synonym is provided if not +already defined. This will be used in examples below. + +PATTERNS *abolish-patterns* + +Patterns can include brace pairs that contain comma separated alternatives: + + box{,es} => box, boxes, Box, Boxes, BOX, BOXES + +For commands with a replacement, corresponding brace pairs are used in both +halves. If the replacement should be identical to the pattern, an empty +brace pair may be used. If fewer replacements are given than were given in +the pattern, they are looped. That is, {a,b} on the replacement side is the +same as {a,b,a,b,a,b,...} repeated indefinitely. + +The following replaces several different misspellings of "necessary": +> + :%S/{,un}nec{ce,ces,e}sar{y,ily}/{}nec{es}sar{}/g +< +ABBREVIATING *abolish-abbrev* + +By default :Abolish creates abbreviations, which replace words automatically +as you type. This is good for words you frequently misspell, or as +shortcuts for longer words. Since these are just Vim abbreviations, only +whole words will match. +> + :Abolish anomol{y,ies} anomal{} + :Abolish {,in}consistant{,ly} {}consistent{} + :Abolish Tqbf The quick, brown fox jumps over the lazy dog +< +Accepts the following options: + + -buffer: buffer local + -cmdline: work in command line in addition to insert mode + +A good place to define abbreviations is "after/plugin/abolish.vim", +relative to ~\vimfiles on Windows and ~/.vim everywhere else. + +With a bang (:Abolish!) the abbreviation is also appended to the file in +g:abolish_save_file. The default is "after/plugin/abolish.vim", relative +to the install directory. + +Abbreviations can be removed with :Abolish -delete: +> + Abolish -delete -buffer -cmdline anomol{y,ies} +< +SEARCHING *abolish-search* + +The -search command does a search in a manner similar to / key. +search. After searching, you can use |n| and |N| as you would with a normal +search. + +The following will search for box, Box, and BOX: +> + :Abolish -search box +< +When given a single word to operate on, :Subvert defaults to doing a +search as well: +> + :S/box/ +< +This one searches for box, boxes, boxed, boxing, Box, Boxes, Boxed, Boxing, +BOX, BOXES, BOXED, and BOXING: +> + :S/box{,es,ed,ing}/ +< +The following syntaxes search in reverse. +> + :Abolish! -search box + :S?box? +< +Flags can be given with the -flags= option to :Abolish, or by appending them +after the separator to :Subvert. The flags trigger the following behaviors: + + I: Disable case variations (box, Box, BOX) + v: Match inside variable names (match my_box, myBox, but not mybox) + w: Match whole words (like surrounding with \< and \>) + +A |search-offset| may follow the flags. +> + :Abolish -search -flags=avs+1 box + :S?box{,es,ed,ing}?we +< +GREPPING *abolish-grep* + +Grepping works similar to searching, and is invoked when additional options +are given. These options are passed directly to the :grep command. +> + :Abolish -search box{,es} + :S /box{,es}/ * + :S /box/aw *.txt *.html +< +The slash delimiters must both be present if used with :Subvert. They may +both be omitted if no flags are used. + +Both an external grepprg and vimgrep (via grepprg=internal) are supported. +With an external grep, the "v" flag behaves less intelligently, due to the +lack of look ahead and look behind support in grep regexps. + +SUBSTITUTING *abolish-substitute* + +Giving a range switches :Subvert into substitute mode. This command will +change box -> bag, boxes -> bags, Box -> Bag, Boxes -> Bags, BOX -> BAG, +BOXES -> BAGS across the entire document: +> + :%Abolish -substitute -flags=g box{,es} bag{,s} + :%S/box{,es}/bag{,s}/g +< +The "c", "e", "g", and "n" flags can be used from the substitute command +|:s_flags|, along with the "a", "I", "v", and "w" flags from searching. + +COERCION *abolish-coercion* *cr* + +Abolish's case mutating algorithms can be applied to the word under the cursor +using the cr mapping (mnemonic: CoeRce) followed by one of the following +characters: + + c: camelCase + m: MixedCase + _: snake_case + s: snake_case + u: SNAKE_UPPERCASE + U: SNAKE_UPPERCASE + -: dash-case (not usually reversible; see |abolish-coercion-reversible|) + k: kebab-case (not usually reversible; see |abolish-coercion-reversible|) + .: dot.case (not usually reversible; see |abolish-coercion-reversible|) + : space case (not usually reversible; see |abolish-coercion-reversible|) + t: Title Case (not usually reversible; see |abolish-coercion-reversible|) + +For example, cru on a lowercase word is a slightly easier to type equivalent +to gUiw. + +COERCION REVERSIBILITY *abolish-coercion-reversible* + +Some separators, such as "-" and ".", are listed as "not usually reversible". +The reason is that these are not "keyword characters", so vim (and +abolish.vim) will treat them as breaking a word. + +For example: "key_word" is a single keyword. The dash-case version, +"key-word", is treated as two keywords, "key" and "word". + +This behaviour is governed by the 'iskeyword' option. If a separator appears +in 'iskeyword', the corresponding coercion will be reversible. For instance, +dash-case is reversible in 'lisp' files, and dot-case is reversible in R +files. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-abolish/plugin/abolish.vim b/sources_non_forked/vim-abolish/plugin/abolish.vim new file mode 100644 index 00000000..4be1122d --- /dev/null +++ b/sources_non_forked/vim-abolish/plugin/abolish.vim @@ -0,0 +1,639 @@ +" abolish.vim - Language friendly searches, substitutions, and abbreviations +" Maintainer: Tim Pope +" Version: 1.1 +" GetLatestVimScripts: 1545 1 :AutoInstall: abolish.vim + +" Initialization {{{1 + +if exists("g:loaded_abolish") || &cp || v:version < 700 + finish +endif +let g:loaded_abolish = 1 + +if !exists("g:abolish_save_file") + if isdirectory(expand("~/.vim")) + let g:abolish_save_file = expand("~/.vim/after/plugin/abolish.vim") + elseif isdirectory(expand("~/vimfiles")) || has("win32") + let g:abolish_save_file = expand("~/vimfiles/after/plugin/abolish.vim") + else + let g:abolish_save_file = expand("~/.vim/after/plugin/abolish.vim") + endif +endif + +" }}}1 +" Utility functions {{{1 + +function! s:function(name) + return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) +endfunction + +function! s:send(self,func,...) + if type(a:func) == type('') || type(a:func) == type(0) + let l:Func = get(a:self,a:func,'') + else + let l:Func = a:func + endif + let s = type(a:self) == type({}) ? a:self : {} + if type(Func) == type(function('tr')) + return call(Func,a:000,s) + elseif type(Func) == type({}) && has_key(Func,'apply') + return call(Func.apply,a:000,Func) + elseif type(Func) == type({}) && has_key(Func,'call') + return call(Func.call,a:000,s) + elseif type(Func) == type('') && Func == '' && has_key(s,'function missing') + return call('s:send',[s,'function missing',a:func] + a:000) + else + return Func + endif +endfunction + +let s:object = {} +function! s:object.clone(...) + let sub = deepcopy(self) + return a:0 ? extend(sub,a:1) : sub +endfunction + +if !exists("g:Abolish") + let Abolish = {} +endif +call extend(Abolish, s:object, 'force') +call extend(Abolish, {'Coercions': {}}, 'keep') + +function! s:throw(msg) + let v:errmsg = a:msg + throw "Abolish: ".a:msg +endfunction + +function! s:words() + let words = [] + let lnum = line('w0') + while lnum <= line('w$') + let line = getline(lnum) + let col = 0 + while match(line,'\<\k\k\+\>',col) != -1 + let words += [matchstr(line,'\<\k\k\+\>',col)] + let col = matchend(line,'\<\k\k\+\>',col) + endwhile + let lnum += 1 + endwhile + return words +endfunction + +function! s:extractopts(list,opts) + let i = 0 + while i < len(a:list) + if a:list[i] =~ '^-[^=]' && has_key(a:opts,matchstr(a:list[i],'-\zs[^=]*')) + let key = matchstr(a:list[i],'-\zs[^=]*') + let value = matchstr(a:list[i],'=\zs.*') + if type(get(a:opts,key)) == type([]) + let a:opts[key] += [value] + elseif type(get(a:opts,key)) == type(0) + let a:opts[key] = 1 + else + let a:opts[key] = value + endif + else + let i += 1 + continue + endif + call remove(a:list,i) + endwhile + return a:opts +endfunction + +" }}}1 +" Dictionary creation {{{1 + +function! s:mixedcase(word) + return substitute(s:camelcase(a:word),'^.','\u&','') +endfunction + +function! s:camelcase(word) + let word = substitute(a:word, '-', '_', 'g') + if word !~# '_' && word =~# '\l' + return substitute(word,'^.','\l&','') + else + return substitute(word,'\C\(_\)\=\(.\)','\=submatch(1)==""?tolower(submatch(2)) : toupper(submatch(2))','g') + endif +endfunction + +function! s:snakecase(word) + let word = substitute(a:word,'::','/','g') + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g') + let word = substitute(word,'[.-]','_','g') + let word = tolower(word) + return word +endfunction + +function! s:uppercase(word) + return toupper(s:snakecase(a:word)) +endfunction + +function! s:dashcase(word) + return substitute(s:snakecase(a:word),'_','-','g') +endfunction + +function! s:spacecase(word) + return substitute(s:snakecase(a:word),'_',' ','g') +endfunction + +function! s:dotcase(word) + return substitute(s:snakecase(a:word),'_','.','g') +endfunction + +function! s:titlecase(word) + return substitute(s:spacecase(a:word), '\(\<\w\)','\=toupper(submatch(1))','g') +endfunction + +call extend(Abolish, { + \ 'camelcase': s:function('s:camelcase'), + \ 'mixedcase': s:function('s:mixedcase'), + \ 'snakecase': s:function('s:snakecase'), + \ 'uppercase': s:function('s:uppercase'), + \ 'dashcase': s:function('s:dashcase'), + \ 'dotcase': s:function('s:dotcase'), + \ 'spacecase': s:function('s:spacecase'), + \ 'titlecase': s:function('s:titlecase') + \ }, 'keep') + +function! s:create_dictionary(lhs,rhs,opts) + let dictionary = {} + let i = 0 + let expanded = s:expand_braces({a:lhs : a:rhs}) + for [lhs,rhs] in items(expanded) + if get(a:opts,'case',1) + let dictionary[s:mixedcase(lhs)] = s:mixedcase(rhs) + let dictionary[tolower(lhs)] = tolower(rhs) + let dictionary[toupper(lhs)] = toupper(rhs) + endif + let dictionary[lhs] = rhs + endfor + let i += 1 + return dictionary +endfunction + +function! s:expand_braces(dict) + let new_dict = {} + for [key,val] in items(a:dict) + if key =~ '{.*}' + let redo = 1 + let [all,kbefore,kmiddle,kafter;crap] = matchlist(key,'\(.\{-\}\){\(.\{-\}\)}\(.*\)') + let [all,vbefore,vmiddle,vafter;crap] = matchlist(val,'\(.\{-\}\){\(.\{-\}\)}\(.*\)') + ["","","",""] + if all == "" + let [vbefore,vmiddle,vafter] = [val, ",", ""] + endif + let targets = split(kmiddle,',',1) + let replacements = split(vmiddle,',',1) + if replacements == [""] + let replacements = targets + endif + for i in range(0,len(targets)-1) + let new_dict[kbefore.targets[i].kafter] = vbefore.replacements[i%len(replacements)].vafter + endfor + else + let new_dict[key] = val + endif + endfor + if exists("redo") + return s:expand_braces(new_dict) + else + return new_dict + endif +endfunction + +" }}}1 +" Abolish Dispatcher {{{1 + +function! s:SubComplete(A,L,P) + if a:A =~ '^[/?]\k\+$' + let char = strpart(a:A,0,1) + return join(map(s:words(),'char . v:val'),"\n") + elseif a:A =~# '^\k\+$' + return join(s:words(),"\n") + endif +endfunction + +function! s:Complete(A,L,P) + " Vim bug: :Abolish - calls this function with a:A equal to 0 + if a:A =~# '^[^/?-]' && type(a:A) != type(0) + return join(s:words(),"\n") + elseif a:L =~# '^\w\+\s\+\%(-\w*\)\=$' + return "-search\n-substitute\n-delete\n-buffer\n-cmdline\n" + elseif a:L =~# ' -\%(search\|substitute\)\>' + return "-flags=" + else + return "-buffer\n-cmdline" + endif +endfunction + +let s:commands = {} +let s:commands.abstract = s:object.clone() + +function! s:commands.abstract.dispatch(bang,line1,line2,count,args) + return self.clone().go(a:bang,a:line1,a:line2,a:count,a:args) +endfunction + +function! s:commands.abstract.go(bang,line1,line2,count,args) + let self.bang = a:bang + let self.line1 = a:line1 + let self.line2 = a:line2 + let self.count = a:count + return self.process(a:bang,a:line1,a:line2,a:count,a:args) +endfunction + +function! s:dispatcher(bang,line1,line2,count,args) + let i = 0 + let args = copy(a:args) + let command = s:commands.abbrev + while i < len(args) + if args[i] =~# '^-\w\+$' && has_key(s:commands,matchstr(args[i],'-\zs.*')) + let command = s:commands[matchstr(args[i],'-\zs.*')] + call remove(args,i) + break + endif + let i += 1 + endwhile + try + return command.dispatch(a:bang,a:line1,a:line2,a:count,args) + catch /^Abolish: / + echohl ErrorMsg + echo v:errmsg + echohl NONE + return "" + endtry +endfunction + +" }}}1 +" Subvert Dispatcher {{{1 + +function! s:subvert_dispatcher(bang,line1,line2,count,args) + try + return s:parse_subvert(a:bang,a:line1,a:line2,a:count,a:args) + catch /^Subvert: / + echohl ErrorMsg + echo v:errmsg + echohl NONE + return "" + endtry +endfunction + +function! s:parse_subvert(bang,line1,line2,count,args) + if a:args =~ '^\%(\w\|$\)' + let args = (a:bang ? "!" : "").a:args + else + let args = a:args + endif + let separator = '\v((\\)@= 2 && split[1] =~# '^[A-Za-z]* ' + let flags = matchstr(split[1],'^[A-Za-z]*') + let rest = matchstr(join(split[1:],separator),' \zs.*') + return s:grep_command(rest,a:bang,flags,split[0]) + elseif len(split) >= 2 && separator == ' ' + return s:grep_command(join(split[1:],' '),a:bang,"",split[0]) + else + return s:parse_substitute(a:bang,a:line1,a:line2,a:count,split) + endif +endfunction + +function! s:normalize_options(flags) + if type(a:flags) == type({}) + let opts = a:flags + let flags = get(a:flags,"flags","") + else + let opts = {} + let flags = a:flags + endif + if flags =~# 'w' + let opts.boundaries = 2 + elseif flags =~# 'v' + let opts.boundaries = 1 + elseif !has_key(opts,'boundaries') + let opts.boundaries = 0 + endif + let opts.case = (flags !~# 'I' ? get(opts,'case',1) : 0) + let opts.flags = substitute(flags,'\C[avIiw]','','g') + return opts +endfunction + +" }}}1 +" Searching {{{1 + +function! s:subesc(pattern) + return substitute(a:pattern,'[][\\/.*+?~%()&]','\\&','g') +endfunction + +function! s:sort(a,b) + if a:a ==? a:b + return a:a == a:b ? 0 : a:a > a:b ? 1 : -1 + elseif strlen(a:a) == strlen(a:b) + return a:a >? a:b ? 1 : -1 + else + return strlen(a:a) < strlen(a:b) ? 1 : -1 + endif +endfunction + +function! s:pattern(dict,boundaries) + if a:boundaries == 2 + let a = '<' + let b = '>' + elseif a:boundaries + let a = '%(<|_@<=|[[:lower:]]@<=[[:upper:]]@=)' + let b = '%(>|_@=|[[:lower:]]@<=[[:upper:]]@=)' + else + let a = '' + let b = '' + endif + return '\v\C'.a.'%('.join(map(sort(keys(a:dict),function('s:sort')),'s:subesc(v:val)'),'|').')'.b +endfunction + +function! s:egrep_pattern(dict,boundaries) + if a:boundaries == 2 + let a = '\<' + let b = '\>' + elseif a:boundaries + let a = '(\<\|_)' + let b = '(\>\|_\|[[:upper:]][[:lower:]])' + else + let a = '' + let b = '' + endif + return a.'('.join(map(sort(keys(a:dict),function('s:sort')),'s:subesc(v:val)'),'\|').')'.b +endfunction + +function! s:c() + call histdel('search',-1) + return "" +endfunction + +function! s:find_command(cmd,flags,word) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:word,"",opts) + " This is tricky. If we use :/pattern, the search drops us at the + " beginning of the line, and we can't use position flags (e.g., /foo/e). + " If we use :norm /pattern, we leave ourselves vulnerable to "press enter" + " prompts (even with :silent). + let cmd = (a:cmd =~ '[?!]' ? '?' : '/') + let @/ = s:pattern(dict,opts.boundaries) + if opts.flags == "" || !search(@/,'n') + return "norm! ".cmd."\" + elseif opts.flags =~ ';[/?]\@!' + call s:throw("E386: Expected '?' or '/' after ';'") + else + return "exe 'norm! ".cmd.cmd.opts.flags."\'|call histdel('search',-1)" + return "" + endif +endfunction + +function! s:grep_command(args,bang,flags,word) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:word,"",opts) + if &grepprg == "internal" + let lhs = "'".s:pattern(dict,opts.boundaries)."'" + elseif &grepprg =~# '^rg\|^ag' + let lhs = "'".s:egrep_pattern(dict,opts.boundaries)."'" + else + let lhs = "-E '".s:egrep_pattern(dict,opts.boundaries)."'" + endif + return "grep".(a:bang ? "!" : "")." ".lhs." ".a:args +endfunction + +let s:commands.search = s:commands.abstract.clone() +let s:commands.search.options = {"word": 0, "variable": 0, "flags": ""} + +function! s:commands.search.process(bang,line1,line2,count,args) + call s:extractopts(a:args,self.options) + if self.options.word + let self.options.flags .= "w" + elseif self.options.variable + let self.options.flags .= "v" + endif + let opts = s:normalize_options(self.options) + if len(a:args) > 1 + return s:grep_command(join(a:args[1:]," "),a:bang,opts,a:args[0]) + elseif len(a:args) == 1 + return s:find_command(a:bang ? "!" : " ",opts,a:args[0]) + else + call s:throw("E471: Argument required") + endif +endfunction + +" }}}1 +" Substitution {{{1 + +function! Abolished() + return get(g:abolish_last_dict,submatch(0),submatch(0)) +endfunction + +function! s:substitute_command(cmd,bad,good,flags) + let opts = s:normalize_options(a:flags) + let dict = s:create_dictionary(a:bad,a:good,opts) + let lhs = s:pattern(dict,opts.boundaries) + let g:abolish_last_dict = dict + return a:cmd.'/'.lhs.'/\=Abolished()'."/".opts.flags +endfunction + +function! s:parse_substitute(bang,line1,line2,count,args) + if get(a:args,0,'') =~ '^[/?'']' + let separator = matchstr(a:args[0],'^.') + let args = split(join(a:args,' '),separator,1) + call remove(args,0) + else + let args = a:args + endif + if len(args) < 2 + call s:throw("E471: Argument required") + elseif len(args) > 3 + call s:throw("E488: Trailing characters") + endif + let [bad,good,flags] = (args + [""])[0:2] + if a:count == 0 + let cmd = "substitute" + else + let cmd = a:line1.",".a:line2."substitute" + endif + return s:substitute_command(cmd,bad,good,flags) +endfunction + +let s:commands.substitute = s:commands.abstract.clone() +let s:commands.substitute.options = {"word": 0, "variable": 0, "flags": "g"} + +function! s:commands.substitute.process(bang,line1,line2,count,args) + call s:extractopts(a:args,self.options) + if self.options.word + let self.options.flags .= "w" + elseif self.options.variable + let self.options.flags .= "v" + endif + let opts = s:normalize_options(self.options) + if len(a:args) <= 1 + call s:throw("E471: Argument required") + else + let good = join(a:args[1:],"") + let cmd = a:bang ? "." : "%" + return s:substitute_command(cmd,a:args[0],good,self.options) + endif +endfunction + +" }}}1 +" Abbreviations {{{1 + +function! s:badgood(args) + let words = filter(copy(a:args),'v:val !~ "^-"') + call filter(a:args,'v:val =~ "^-"') + if empty(words) + call s:throw("E471: Argument required") + elseif !empty(a:args) + call s:throw("Unknown argument: ".a:args[0]) + endif + let [bad; words] = words + return [bad, join(words," ")] +endfunction + +function! s:abbreviate_from_dict(cmd,dict) + for [lhs,rhs] in items(a:dict) + exe a:cmd lhs rhs + endfor +endfunction + +let s:commands.abbrev = s:commands.abstract.clone() +let s:commands.abbrev.options = {"buffer":0,"cmdline":0,"delete":0} +function! s:commands.abbrev.process(bang,line1,line2,count,args) + let args = copy(a:args) + call s:extractopts(a:args,self.options) + if self.options.delete + let cmd = "unabbrev" + let good = "" + else + let cmd = "noreabbrev" + endif + if !self.options.cmdline + let cmd = "i" . cmd + endif + if self.options.delete + let cmd = "silent! ".cmd + endif + if self.options.buffer + let cmd = cmd . " " + endif + let [bad, good] = s:badgood(a:args) + if substitute(bad, '[{},]', '', 'g') !~# '^\k*$' + call s:throw("E474: Invalid argument (not a keyword: ".string(bad).")") + endif + if !self.options.delete && good == "" + call s:throw("E471: Argument required".a:args[0]) + endif + let dict = s:create_dictionary(bad,good,self.options) + call s:abbreviate_from_dict(cmd,dict) + if a:bang + let i = 0 + let str = "Abolish ".join(args," ") + let file = g:abolish_save_file + if !isdirectory(fnamemodify(file,':h')) + call mkdir(fnamemodify(file,':h'),'p') + endif + + if filereadable(file) + let old = readfile(file) + else + let old = ["\" Exit if :Abolish isn't available.","if !exists(':Abolish')"," finish","endif",""] + endif + call writefile(old + [str],file) + endif + return "" +endfunction + +let s:commands.delete = s:commands.abbrev.clone() +let s:commands.delete.options.delete = 1 + +" }}}1 +" Maps {{{1 + +function! s:unknown_coercion(letter,word) + return a:word +endfunction + +call extend(Abolish.Coercions, { + \ 'c': Abolish.camelcase, + \ 'm': Abolish.mixedcase, + \ 's': Abolish.snakecase, + \ '_': Abolish.snakecase, + \ 'u': Abolish.uppercase, + \ 'U': Abolish.uppercase, + \ '-': Abolish.dashcase, + \ 'k': Abolish.dashcase, + \ '.': Abolish.dotcase, + \ ' ': Abolish.spacecase, + \ 't': Abolish.titlecase, + \ "function missing": s:function("s:unknown_coercion") + \}, "keep") + +function! s:coerce(type) abort + if a:type !~# '^\%(line\|char\|block\)' + let s:transformation = a:type + let &opfunc = matchstr(expand(''), '\w*') + return 'g@' + endif + let selection = &selection + let clipboard = &clipboard + try + set selection=inclusive clipboard-=unnamed clipboard-=unnamedplus + let regbody = getreg('"') + let regtype = getregtype('"') + let c = v:count1 + let begin = getcurpos() + while c > 0 + let c -= 1 + if a:type ==# 'line' + let move = "'[V']" + elseif a:type ==# 'block' + let move = "`[\`]" + else + let move = "`[v`]" + endif + silent exe 'normal!' move.'y' + let word = @@ + let @@ = s:send(g:Abolish.Coercions,s:transformation,word) + if word !=# @@ + let changed = 1 + exe 'normal!' move.'p' + endif + endwhile + call setreg('"',regbody,regtype) + call setpos("'[",begin) + call setpos(".",begin) + finally + let &selection = selection + let &clipboard = clipboard + endtry +endfunction + +nnoremap (abolish-coerce) coerce(nr2char(getchar())) +vnoremap (abolish-coerce) coerce(nr2char(getchar())) +nnoremap (abolish-coerce-word) coerce(nr2char(getchar())).'iw' + +" }}}1 + +if !exists("g:abolish_no_mappings") || ! g:abolish_no_mappings + nmap cr (abolish-coerce-word) +endif + +command! -nargs=+ -bang -bar -range=0 -complete=custom,s:Complete Abolish + \ :exec s:dispatcher(0,,,,[]) +command! -nargs=1 -bang -bar -range=0 -complete=custom,s:SubComplete Subvert + \ :exec s:subvert_dispatcher(0,,,,) +if exists(':S') != 2 + command -nargs=1 -bang -bar -range=0 -complete=custom,s:SubComplete S + \ :exec s:subvert_dispatcher(0,,,,) +endif + +" vim:set ft=vim sw=2 sts=2: diff --git a/sources_non_forked/vim-addon-mw-utils/.gitignore b/sources_non_forked/vim-addon-mw-utils/.gitignore new file mode 100644 index 00000000..926ccaaf --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/.gitignore @@ -0,0 +1 @@ +doc/tags diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim b/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim new file mode 100644 index 00000000..d14d404b --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/buf_utils.vim @@ -0,0 +1,24 @@ +" buf_identifier is either a buf_nr or a filename +" If any window shows the buffer move to the buffer +" If not show it in current window (by c-w s c^ you can always +" reshow the last buffer +" +" Example: buf_utils#GotoBuf("/tmp/tfile.txt", {'create': 1}) +" returns: The command which was used to switch to the buffer +fun! buf_utils#GotoBuf(buf_identifier, opts) + let buf_nr = bufnr(a:buf_identifier) + if buf_nr == -1 && ( get(a:opts, 'create', 0) || has_key(a:opts, 'create_cmd')) + exec get(a:opts,'create_cmd','e').' '.fnameescape(a:buf_identifier) + return "e" + else + let win_nr = bufwinnr(buf_nr) + if win_nr == -1 + exec 'b '.buf_nr + return "b" + else + exec win_nr.'wincmd w' + return "w" + endif + wincmd w" + endif +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim b/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim new file mode 100644 index 00000000..3fc3ce46 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/cached_file_contents.vim @@ -0,0 +1,104 @@ +" cached_file_contents.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.3.0 + +"exec vam#DefineAndBind('s:c','g:cache_dir_options','{}') +if !exists('g:cache_dir_options') | let g:cache_dir_options = {} | endif | let s:c = g:cache_dir_options + +let s:c['cache_dir'] = get(s:c, 'cache_dir', expand('$HOME').'/.vim-cache') +let s:c['scanned_files'] = get(s:c, 'scanned_files', {}) +let s:scanned_files = s:c['scanned_files'] + + +let s:define_cache_file = "let this_dir = s:c['cache_dir'].'/cached-file-contents' | let cache_file = expand(this_dir.'/'.substitute(string([func_as_string, a:file]),'[[\\]{}:/\\,''\"# ]\\+','_','g'))" + +" read a file, run function to extract contents and cache the result returned +" by that function in memory. Optionally the result can be cached on disk as +" because VimL can be slow! +" +" file : the file to be read +" func: { 'func': function which will be called by funcref#Call +" , 'version' : if this version changes cache will be invalidate automatically +" , 'ftime_check': optional, default 1. if set to 0 cache isn't updated when file changes and file is in cache +" } +" +" default: what to return if file doesn't exist +" think twice about adding lines. This function is called many times. +function! cached_file_contents#CachedFileContents(file, func, ...) abort + let ignore_ftime = a:0 > 0 ? a:1 : 0 + " using string for default so that is evaluated when needed only + let use_file_cache = get(a:func, 'use_file_cache', 0) + + " simple kind of normalization. necessary when using file caching + " this seems to be slower: + " let file = fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + " / = assume its an absolute path + " let file = a:file[0] == '/' ? a:file : expand(a:file, ':p') + let file = a:file[0] == '/' ? a:file : fnamemodify(a:file, ':p') " simple kind of normalization. necessary when using file caching + let func_as_string = string(a:func['func']) + + if (!has_key(s:scanned_files, func_as_string)) + let s:scanned_files[func_as_string] = {} + endif + let dict = s:scanned_files[func_as_string] + if use_file_cache && !has_key(dict, a:file) + exec s:define_cache_file + if filereadable(cache_file) + let dict[file] = eval(readfile(cache_file,'b')[0]) + endif + endif + if has_key(dict, a:file) + let d = dict[a:file] + if use_file_cache + \ && (ignore_ftime || getftime(a:file) <= d['ftime']) + \ && d['version'] == a:func['version'] + return dict[a:file]['scan_result'] + endif + endif + let scan_result = funcref#Call(a:func['func'], [a:file] ) + let dict[a:file] = {"ftime": getftime(a:file), 'version': a:func['version'], "scan_result": scan_result } + if use_file_cache + if !exists('cache_file') | exec s:define_cache_file | endif + if !isdirectory(this_dir) | call mkdir(this_dir,'p',0700) | endif + call writefile([string(dict[a:file])], cache_file) + endif + return scan_result +endfunction + +fun! cached_file_contents#ClearScanCache() + let s:c['scanned_files'] = {} + + " Don't run rm -fr. Ask user to run it. It cache_dir may have been set to + " $HOME ! (should nevere be the case but who knows + echoe "run manually in your shell: rm -fr ".shellescape(s:c['cache_dir'])."/*" +endf + +fun! cached_file_contents#Test() + + " usually you use a global option so that the function can be reused + let my_interpreting_func = {'func' : funcref#Function('return len(readfile(ARGS[0]))'), 'version': 2, 'use_file_cache':1} + let my_interpreting_func2 = {'func' : funcref#Function('return ARGS[0]') , 'version': 2, 'use_file_cache':1} + + let tmp = tempname() + call writefile(['some text','2nd line'], tmp) + + let r = [ cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + \ , cached_file_contents#CachedFileContents(tmp, my_interpreting_func2) ] + if r != [2, tmp] + throw "test failed 1, got ".string(r) + endif + unlet r + + sleep 3 + + " now let's change contents + call writefile(['some text','2nd line','3rd line'], tmp) + + let r = cached_file_contents#CachedFileContents(tmp, my_interpreting_func) + if 3 != r + throw "test failed 2, got ".string(r) + endif + + echo "test passed" +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim b/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim new file mode 100644 index 00000000..d8af33ae --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/env_reload.vim @@ -0,0 +1,12 @@ +" in sh/bash you can type export to get a list of environment variables +" This function assigns those env vars to Vim. +" Does not delete env vars yet +" Example: env_reload#ReloadEnv(system("sh -c 'export'") +fun! env_reload#ReloadEnv(bash_export_command_output) + for i in split(a:bash_export_command_output,"\n") + let m = matchlist(i, 'export \([^=]\+\)="\(.*\)"') + if empty(m) | continue | endif + " don't care about quoted values right now. + exec 'let $'.m[1].'='.string(m[2]) + endfor +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim b/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim new file mode 100644 index 00000000..20eec54a --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/funcref.vim @@ -0,0 +1,95 @@ +" funcref.vim +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2010-01-03. +" @Revision: 0.1.0 + +" documentation see doc/funcref.txt + +" usage: +" funcref#Function("filename#Function") +" optionally pass arguments: +" funcref#Function("filename#Function",{'args': [2]}) +" optionally define self: +" funcref#Function("filename#Function",{'self': object}) +function! funcref#Function(name,...) + let d = a:0 > 0 ? a:1 : {} + let d['faked_function_reference'] = a:name + return d +endfunction + +" args : same as used for call(f,[args], self) +" f must be either +" - a string which can be evaled (use "return 'value'" to return a value) +" - a Vim function reference created by function('..') +" - a faked function reference created by funcref#Function(..) +" +" the last "self" argument can be overriden by the function reference +" You can pass arguments in a closure like style +function! funcref#Call(...) + let args = copy(a:000) + + " add parameters: + if (len(args) < 2) + call add(args, []) + endif + + + let isDict = type(args[0]) == type({}) + + " prepend parameters which were passed by faked function reference: + if isDict && has_key(args[0], 'args') + let args[1] = args[0]['args']+args[1] + endif + + " always pass self. this way you can call functions from dictionaries not + " refering to self + if (len(args) < 3) + call add(args, {}) + endif + + " the funcref overrides self: + if isDict && has_key(args[0], 'self') + let args[2] = args[0]['self'] + endif + + if type(a:1) == 2 + " funcref: function must have been laoded + return call(function('call'), args) + elseif isDict && has_key(args[0], 'faked_function_reference') + let Fun = args[0]['faked_function_reference'] + if type(Fun) == type('') + \ && (Fun[:len('return ')-1] == 'return ' + \ || Fun[:len('call ')-1] == 'call ' + \ || Fun[:len('if ')-1] == 'if ' + \ || Fun[:len('let ')-1] == 'let ' + \ || Fun[:len('echo ')-1] == 'echo ' + \ || Fun[:len('exec ')-1] == 'exec ' + \ || Fun[:len('debug ')-1] == 'debug ') + " it doesn't make sense to list all vim commands here + " So if you want to execute another action consider using + " funcref#Function('exec '.string('aw')) or such + + " function is a String, call exec + let ARGS = args[1] + let SELF = args[2] + exec Fun + else + " pseudo function, let's load it.. + if type(Fun) == 1 + if !exists('*'.Fun) + " lazily load function + let file = substitute(substitute(Fun,'#[^#]*$','',''),'#','/','g') + exec 'runtime /autoload/'.file.'.vim' + endif + let Fun2 = function(Fun) + else + let Fun2 = Fun + endif + let args[0] = Fun + return call(function('call'), args) + endif + else + " no function, return the value + return args[0] + endif +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim new file mode 100644 index 00000000..9a0f79a2 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob.vim @@ -0,0 +1,27 @@ +exec vam#DefineAndBind('s:c','g:glob_like', '{}') + +" ignore vcs stuff, Don't think you want those.. +let s:c['regex_ignore_directory'] = '\<\%([_.]darcs\|\.git\|.svn\|.hg\|.cvs\|.bzr\)\>' +let s:c['glob_cache'] = get(s:c, 'glob_cache', {}) +let s:glob_cache = s:c['glob_cache'] + +fun! glob#Glob(pattern, ...) + let pattern = a:pattern + if pattern[0] == '~' + let pattern = $HOME.pattern[1:] + endif + let opts = a:0 > 0 ? a:1 : {} + " never cache current directory. You're very likely to edit files in it. + + let c = getcwd() + let cachable = get(opts, 'cachable', 0) && pattern[:len(c)-1] != c + if cachable && has_key(s:glob_cache, pattern) + return s:glob_cache[pattern] + endif + + " FIXME: don't recurse into \.git directory (thus reimplement glob in vimL!) + let r = filter(split(glob(pattern),"\n"),'v:val !~ '.string(s:c['regex_ignore_directory'])) + if cachable | let s:glob_cache[pattern] = r | endif + return r +endf + diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim new file mode 100644 index 00000000..e93820c2 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/glob_linux.vim @@ -0,0 +1,43 @@ + +" TODO refactor: create glob function +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"\\.git\\\\.hg\\node_modules\\\\.pyc" ) +" noremap \og :callglob_linux#FileByGlobCurrentDir('**/*'.input('glob open '),"default" ) +function! glob_linux#FileByGlobCurrentDir(glob, exclude_pattern, ...) + let opts = a:0 > 0 ? a:1 : {} + if a:exclude_pattern == "default" + let exclude_pattern = '\.git\|\.hg\|node_modules\|\.pyc' + else + let exclude_pattern = a:exclude_pattern + endif + + " let files = split(glob(a:glob),"\n") + let g = a:glob + let replace = {'**': '.*','*': '[^/\]*','.': '\.'} + let g = substitute(g, '\(\*\*\|\*\|\.\)', '\='.string(replace).'[submatch(1)]','g') + + let exclude = exclude_pattern == '' ? '' : ' | grep -v -e '.shellescape(exclude_pattern) + + let cmd = get(opts, 'cmd_find', 'find'). ' . | grep -e '.shellescape(g).exclude + let files = split(system(cmd),"\n") + " for nom in a:excludes + " call filter(files,nom) + " endfor + if len(files) > 1000 + echoe "more than ".2000." files - would be too slow. Open the file in another way" + else + if empty(files) + echoe "no file found" + elseif len(files) == 1 + exec 'e '.fnameescape(files[0]) + else + let g:abc=7 + call tovl#ui#filter_list#ListView({ + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec "e ".fnameescape(ARGS[0])'), + \ 'items' : files, + \ 'cmds' : ['wincmd J'] + \ }) + endif + endif +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim new file mode 100644 index 00000000..052bbe04 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tiny_cmd.vim @@ -0,0 +1,19 @@ +" vim suffers: + +exec vam#DefineAndBind('s:c','g:vim_tiny_cmd', '{}') + +fun! tiny_cmd#Put(a) + let new = get(s:c,'next',0) +1 + let s:c['next'] = new + let s:c[new] = a:a + return new +endf + +fun! tiny_cmd#Get(nr) + return s:c[a:nr] +endf + +" Get and remove item +fun! tiny_cmd#Pop(nr) + let r = s:c[a:nr] | unlet s:c[a:nr] | return r +endf diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim new file mode 100644 index 00000000..217dca11 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/scratch_buffer.vim @@ -0,0 +1,103 @@ +" old code + +augroup TOVLWrite +augroup end + +" =========== scratch buffer ========================================= +" a scratch buffer is a temporary buffer where the user can enter some text +" It can be used to get commit messages, edit configuration options and so on + +function! tovl#scratch_buffer#KeepIntactLineNr() + let i = 0 + while getline(i)!= b:keepIntact && i < line('$') + let i = i+1 + endwhile + if i > line('$') + return -1 + else + return i + endif +endfunction + +" opens a buffer and runs an action when the buffer is written +" keys: +" name : the name of the buffer +" onWrite : will be called on write +" onWrite is responsible for setlocal nomodified to indicate that +" saving has been successful +" help : callback returning additional information lines +" getContent : callback returning lines +" cmds : extra commands to be run (optional) +" (maybe you prefer adding them the default way afer the +" ScratchBuffer call. They'll be rerun on GetContents +" sp_cmd : the command to use to create the new buffer. Defaults to :e +" buftype : ... +" modifiable : 1 / 0 defaults to 1 +function! tovl#scratch_buffer#ScratchBuffer(opts) + let a:opts['name'] = get(a:opts,'name', 'strach_buffer_without_name') + exec get(a:opts, 'sp_cmd', 'e').' '.escape(a:opts['name'],' ') + let b:settings = a:opts + let b:settings['modifiable'] = get(a:opts,'modifiable', 1) + setlocal buftype=acwrite + command! -buffer -nargs=0 Help call tovl#scratch_buffer#Help() + + " setup write notification + au TOVLWrite BufWriteCmd call tovl#scratch_buffer#Write() + + if has_key(a:opts,'getContent') + command! -buffer -nargs=0 GetContents call tovl#scratch_buffer#GetContents() + GetContents + if !b:settings['modifiable'] + setlocal nomodifiable + endif + endif + "let u=&undolevels + "setlocal undolevels=-1 + "exec 'setlocal undolevels='.u + + " mark buffer as not modified + setlocal nomodified + + au BufReadCmd GetContents + + " run addittional commands + for cmd in get(a:opts,'cmds',[]) + exec cmd + endfor + silent echo get(a:opts,'echo_help', "type :Help for help") +endfunction + +" =========== utility functions ====================================== + +function! tovl#scratch_buffer#Write() + if has_key(b:settings, 'onWrite') + call funcref#Call(b:settings['onWrite']) + else + echo "don't know how to write. Option hasn't been passed" + endif +endfunction + +function! tovl#scratch_buffer#GetContents() + setlocal modifiable + " empty buffer + %g!//d + call append(0, funcref#Call(b:settings['getContent'])) + if !b:settings['modifiable'] + setlocal nomodifiable + endif + for cmd in get(b:settings,'cmds',[]) + exec cmd + endfor +endfunction + +function! tovl#scratch_buffer#Help() + let help = ["use :e! to reload contents, ZZ or :w(q) to write and quit" + \ ,"" + \ ,"Help for this scratch buffer:" + \ ,"=======================================================","",""] + \ + funcref#Call(get(b:settings, 'help', [])) + call tovl#scratch_buffer#ScratchBuffer({ + \ 'name' : "return Help of ".b:settings['name'], + \ 'getContent' : help + \ }) +endfunction diff --git a/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim new file mode 100644 index 00000000..74b2ab49 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/autoload/tovl/ui/filter_list.vim @@ -0,0 +1,473 @@ +" OLD CODE ! +" I should contribute the multiple filter feature to tlib + +" filter list displays a list of items +" you can white / black filter them by regular expressions (similar to the +" tlib TToC command +" However you can edit the filters afterwards and select the cols which should +" be shown + +fun! tovl#ui#filter_list#ListTest() + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 1, + \ 'Continuation' : funcref#Function('echo string(ARGS[0])'), + \ 'items' : [ {"aa" : "a\nAAAAAAAAAAA", 'bb' : "bbbbbbbbbbbbb\nB" }, + \ {"aa" : "2a\n2AAAAAAAAAAAA", "bb" : "2 bbbbbbbbbbbbb\n2B"}, + \ {"aa" : "XXX", "bb" : "YY"} ], + \ }) + +endfun + +fun! s:Intersection(a, b) + return filter(copy(a:a), 'index(a:b, v:val) >= 0') +endf + +fun! tovl#ui#filter_list#ListTestGotoLineCurrentBuf() + let nr=1 + let lines = [] + for l in getline(0,line('$')) + call add(lines, {'nr': nr, 'line' :l}) + let nr = nr +1 + endfor + call tovl#ui#filter_list#ListView({ + \ 'aligned' : 0, + \ 'keys' : ['nr','line'], + \ 'number' : 1, + \ 'selectByIdOrFilter' : 1, + \ 'Continuation' : funcref#Function('exec ARGS[0]["nr"]'), + \ 'items' : lines, + \ }) +endfun + +" opens a new filtered list +" keys of opts parameters: +" Continuation: This function will be called with the selected items +" items: { key : (string or dict) } +" items willl be modified. use copy(youritems) as argument to prevent +" this. An item is either a string or a dict +" (eg {'file' : .., 'line': ... , 'msg' : .. ) +" keys: list of keys to be shown (optional) +" filter: list of inital filters which must be applied +" contains [ { filter: .. , keep : .. }, ] see FilterItems() below +" aligned: default 0 +" sp_cmd: the command to be used to create the new buffer (default ':e') +" init : 0 / 1 (default 1): wether to show the view right now +" number: 0 /1 (default 1): number items ? +" selectByIdOrFilter: 1: start in getchar() loop so that the user can select +" the item even faster +" auto: only do this if all items fit on screen +" (recommend) +" cmds: extra cmds to be run +" cursorAt : at which item to put the cursor? +" +" If you don't like the default view you can override UpdateDisplay +" +" Usage examples of this list control: +" - db results +" - replacement of the quickfix window +" - select a buffer etc +fun! tovl#ui#filter_list#ListView(opts) + " ActivateAddons theonevimlib + let d = {} + let d.items = a:opts.items + let d.cursorAt = get(a:opts, 'cursorAt', 0) + let d.aligned = get(a:opts, 'aligned', 0) + let d.sep = ' ' + let d.filter = get(a:opts, 'filter', []) + " using sp because of bd! (FIXME) + let d.sp_cmd = get(a:opts, 'sp_cmd', 'sp') + let d.allKeys = {} + let d.closeOnContinuation = get(a:opts,'closeOnContinuation',1) + " don't recommend OnSingleMatch, use OnSingleMatchCR instead + let d.continueOnSingleMatch = get(a:opts, 'continueOnSingleMatch',0) + let d.continueOnSingleMatchCR = get(a:opts, 'continueOnSingleMatchCR',1) + let d.selectByIdOrFilter = get(a:opts, 'selectByIdOrFilter', 0) + let d.linesToItems = {} + let d.number = get(a:opts, 'number', 1) + let d.cmds = get(a:opts, 'cmds', []) + let d.syn_cmds = get(a:opts, 'syn_cmds', []) + + if has_key(a:opts,'keys') | let d.keys = a:opts.keys | endif + if has_key(a:opts,'Continuation') | let d.Continuation = a:opts.Continuation | endif + + " cache already filtered items in case we want to view really long results + " contains [ { filter : { regex: .. , keep : .. } , items : .. , cursorAt :}, + " { filter : { ... } , items: .. , cursorAt : } + let d.cached = [] + " id of buffer + let d.buffer = -1 + let d.modeText = '' + + fun d.HelpText() + return [ "you've entered the the help of the powerful filtered view buffer", + \ "", + \ "type f to start filtering items by regex", + \ "type F to start dropping items by regex", + \ "k / K will ask you for the key to apply the filter to first", + \ "apply the filter by and press again to select item", + \ "", + \ "use :ShowAppliedFilters to list active filters", + \ "use :ToggleAlignment to toggle alignment", + \ "", + \ "TODO: Implement sorting, implement interface to change keys (displayed columns)" + \ ] + endfun + + " create new scratch buffer + " preprocess items calculating line count and maxwidth for all items + fun d.NewBufferAndInit() + let self.bufferId = bufnr(bufname('%')) + for idx in range(0,len(self.items)-1) + if type(self.items[idx]) != 4 + " no dict yet, make it one + let self.items[idx] = {'string_line' : self.items[idx]} + endif + let new = {} + for [k,v] in items(self.items[idx]) + let lines = split(v,"\n") + let self.items[idx][k] = { 'text' : v, 'rows' : len(lines), 'cols' : max(map(copy(lines),'len(v:val)')), 'lines' : lines } + let self.allKeys[k] = 1 + unlet k v + endfor + endfor + call tovl#scratch_buffer#ScratchBuffer({ + \ 'help' : funcref#Function(self.HelpText,{ 'self' : self }), + \ 'sp_cmd' : self.sp_cmd, + \ 'cmds' : self.cmds + \ }) + " I assume we have some kind of formatting anyway. Thus breaking lines is bad! + set nowrap + setlocal cursorline + let b:filtered_view = self + command! -buffer -nargs=0 ToggleAlignment call b:filtered_view.ToggleAlignment() + command! -buffer -nargs=0 ShowAppliedFilters call b:filtered_view.ShowAppliedFilters() + command! -buffer -nargs=0 RemoveFilters call b:filtered_view.RemoveFilters() + noremap f :call b:filtered_view.FilterFromKeyboard(1,'') + " noremap f :call b:filtered_view.FilterFromKeyboard(1) + noremap F :call b:filtered_view.FilterFromKeyboard(0,'') + if has_key(self,'Continuation') + nnoremap :call b:filtered_view.Continue() + endif + "noremap k + "noremap K + + let [items, cursorAt] = self.FilteredItems() + " len(items) is an approximation because one item can have multiple + " lines.. However adding the lines first to check takes too much time + if self.selectByIdOrFilter == 1 || (self.selectByIdOrFilter == 'auto' && winheight('%') > len(items) ) + call self.SelectByIdOrFilter() + else + " user should choose how to proceed + call self.UpdateDisplay() + endif + endfun + + " user interface + fun d.ToggleAlignment() + let self.aligned = !self.aligned + call self.UpdateDisplay() + endfun + fun d.ShowAppliedFilters() + for i in self.filter | echo string(i) | endfor + endfun + fun d.RemoveFilters() + let self.filter = [] + call self.UpdateDisplay() + endfun + fun d.Continue() + let item = self.CurrentItem() + call self.DoContinue(item) + endfun + fun d.DoContinue(v) + if self.closeOnContinuation | bw! | endif + call funcref#Call(self.Continuation,[a:v]) + endfun + + fun d.MapToOriginal(v) + if has_key(a:v, 'string_line') + return a:v.string_line.text + else + let d = {} + for [k,v] in items(a:v) + let d[k] = v.text + unlet k v + endfor + return d + endif + endfun + + fun d.CurrentItem() + let idx=line('.')-len(self.headerLines) + while idx >= 0 + if has_key(self.linesToItems, idx) + return self.MapToOriginal(self.FilteredItems()[0][self.linesToItems[idx]]) + else + let idx = idx -1 + endif + endwhile + throw "internal error, couldn't determine selected item!" + endfun + + " updates the filter cache and returns the final filtered items + fun d.FilteredItems() + " update cache + let idx = 0 + let [items, cursorAt] = [self.items, self.cursorAt] + for idx in range(0, len(self.filter)-1) + if idx +1 > len(self.cached) || self.cached[idx]['filter'] != self.filter[idx] + let self.cached = self.cached[:idx-1] + let [items, cursorAt] = self.FilterItem(copy(items), self.filter[idx], cursorAt) + call add(self.cached, { 'cursorAt' : cursorAt, 'items' : items, 'filter' : self.filter[idx]}) + else + let ci = self.cached[idx] + let [items, cursorAt] = [ci['items'], ci['cursorAt']] + endif + endfor + return [items, cursorAt] + endfun + + " calling this will return a set of lines which are expected to be the new + " buffer contents. The self.linesToItems dict is updated + fun d.UpdateDisplay() + + if empty(self.filter) + let self.statusline= 'no filter applied, :Help for help' + else + let self.statusline = len(self.filter).' '.string(self.filter[-1]) + endif + + let self.linesToItems = {} + let [items, cursorAt] = self.FilteredItems() + "let num_width = printf('%.0f', trunc(log10(len(items))+1)) + let num_width = 4 + if self.aligned + " get column width.. (probably will not work with unicde characters.. I + " don't have a better solution) + let maxlens={} + for i in items + for [k,v] in items(i) + if get(maxlens,k,0) < v.cols + let maxlens[k] = v.cols + endif + endfor + endfor + endif + + " format lines + let self.headerLines = [self.modeText] + let lines = copy(self.headerLines) + let lines_count = 0 + if self.number + let fmt_startA = '%'.num_width.'s)' + let fmt_startB = '%'.num_width.'s' + else + let fmt_startA = '' | let fmt_startB = '' + endif + let cursorAtLine = 1 " sane default + for idx in range(0,len(items)-1) + let self.linesToItems[lines_count + 1] = idx + let i = items[idx] + let keys = has_key(self,'keys') + \ ? s:Intersection(self.keys, keys(i)) + \ : keys(i) + let fmt = '' + let args = [i] + let cols = [] + for k in keys + let fmt .= self.sep.'%-'.(self.aligned ? maxlens[k] : i[k]['cols']).'s' + call add(cols, i[k]) + endfor + for row in range(0, max([1] + map(copy(cols),'v:val["rows"]'))-1) + let fmt_args = row == 0 ? [fmt_startA.fmt] : [fmt_startB.fmt] + if self.number + call add(fmt_args, row == 0 ? idx : '') + endif + for c in cols + call add(fmt_args, c.rows <= row ? '' : c.lines[row]) + endfor + call add(lines, call('printf', fmt_args)) + let lines_count += 1 + endfor + if idx == cursorAt + let cursorAtLine = lines_count + endif + endfor + " update stauts line to show last applied filter + " disabled cause it causes trouble on :wincmd w + " setlocal statusline=%!b:filtered_view.statusline + + " syntax + syn clear + for s in self.syn_cmds | exec s | endfor + let id = 0 + " highlight filter regex in buffer as well + let syn_ids = [ 'Underlined', 'Todo', 'Error', 'Type', 'Statement' ] + for f in self.filter + if !f.keep || !has_key(f, 'regex') | continue | endif + if f.regex != '' + try + exec 'syn match '.syn_ids[id % len(syn_ids)].' '.string(f.regex) + catch /.*/ + " ignore errors such as \ without following characters. Thus just + " ignore and wait for the next character + endtry + endif + let id = id +1 + endfor + if len(lines) > winheight('%') + call extend(lines, self.headerLines) + endif + normal ggdG + call append(0, lines) + " place cursor + exec (cursorAtLine+1) + " move cursor into the middle of the window + normal zz + endf + + " filter = keys : + " filter = string to be executed containing Val + " keep = 1 keep on match + " = 0 drop on match + " key (optional) + " cursorAt: at which item to put the cursor + " if that item is deleted it will be placed at the item above + " optional: key of dict if dict + fun d.FilterItem(items, filter, cursorAt) + let filter = 'Val =~ '.string(a:filter.regex) + let keep = a:filter.keep + let cursorAt = a:cursorAt + + for idx in reverse(range(0, len(a:items)-1)) + let i = a:items[idx] + if has_key(a:filter,'key') + let key = a:filter.key + if has_key(i, key) + " key given, only filter by this column + let Val = i[key]['text'] + exec 'let any = '.filter + else + let any = 0 + endif + else + let any = 0 + " no key given, try all + for x in values(i) + let Val = x['text'] + exec 'let any = '.filter + if any | break | endif + endfor + endif + if any != keep + call remove(a:items, idx) + if idx <= cursorAt + let cursorAt = cursorAt -1 + endif + endif + endfor + return [a:items, cursorAt] + endfun + + " if the user enters a number select by index else start filtering.. + fun d.SelectByIdOrFilter() + let idx='' + let items = self.FilteredItems()[0] + try + let self.modeText = '[0-9]* : select by index| : escape getchar() loop, any char: start filtering' + call self.UpdateDisplay() | redraw + while 1 + let c=getchar() + if index([13,10],c) >= 0 + return self.DoContinue(self.MapToOriginal(items[idx])) + elseif index([27], c) >=0 + " esc, abort + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" || index(map(range(0,10),'v:val.""'),c) >= 0 + if c == "\" + let idx = idx[:-2] + else + let idx .= c + endif + if idx < len(items) && idx.'0' > len(items) || idx == 0 && len(items) < 10 + " only match + return self.DoContinue(self.MapToOriginal(items[idx])) + endif + else + return self.FilterFromKeyboard(1,c) + endif + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + " gets a regular expresion filter by keybaord and updates the display while + " you're typing. The regex ist shown in the statusline + fun d.FilterFromKeyboard(keep, start, ...) + let self.modeText = 'press ESC to exit getchar() loop' + call self.UpdateDisplay() | redraw + + try + let key_text = a:0 > 0 ? 'key : '.a:1 : '' + let filter_bak = self.filter + let filter = copy(self.filter) + let start = a:start + let filter_new = '' + while 1 + if start != '' + " use c= last char to force updating display etc + let filter_new = start[:-2] + let c = start[-1:] + let start = '' + else + let c=getchar() + endif + if index([13,10],c) >= 0 + " c-j or return, accept new filter + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatchCR + call self.DoContinue(self.MapToOriginal(items[0])) + endif + return + elseif index([27], c) >=0 + " esc, abort + let self.filter = filter_bak + call self.UpdateDisplay() + return + else + if type(c) == 0 + let c = nr2char(c) + endif + if c == "\" + let filter_new = filter_new[:-2] + else + let filter_new .= c + endif + let d = {'keep' : a:keep, 'regex' : filter_new } + if a:0 > 0 + let d['key'] = a:1 + endif + let self.filter = copy(filter_bak) + call add(self.filter, d) + let items = self.FilteredItems() + if len(items) == 1 && has_key(self, 'Continuation') && self.continueOnSingleMatch + call self.DoContinue(self.MapToOriginal(items[0])) + return + endif + call self.UpdateDisplay() | redraw + endif + endwhile + finally + let self.modeText = '' + endtry + endfun + + if get(a:opts,'init',1) + call d.NewBufferAndInit() + endif +endfun diff --git a/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt b/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt new file mode 100644 index 00000000..a47a8cf8 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/cached_file_contents.txt @@ -0,0 +1,7 @@ +*cached_file_contents* read contents of a file then cache extracted data + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + + see cached_file_contents#Test() diff --git a/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt b/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt new file mode 100644 index 00000000..cb366d0e --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/funcref.txt @@ -0,0 +1,35 @@ +*funcref* create lazier function references. Pass arguments to create closure + like function calls + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Use *funcref#Function* to create a special dict called +*faked-function-reference* which can be called by *funcref#Call* +> + { 'faked_function_reference': 'file#FuncName' } +< passing some arguments and / or self: > + { 'faked_function_reference': 'MyFunc', 'args': [1,2], 'self' : { a object ] } +< You can also create lambda like functions which will be evaled: > + { 'faked_function_reference': 'return ARGS[1]' } + +REASONS ~ + Creating a Vim funcref pointing to an autoload function will make Vim source + that file. This is not lazy enough. (Seems to be no longer true? Has this changed?) + + A Vim function reference neither allows attaching arguments nor self. + + Don't care about case of variables. Normally when using Vim function + references you have to use variable names starting with an upper case letter + (E704) + +Example: ~ +> + let f = funcref#Function('return ARGS[0].ARGS[1].SELF["key"]',{'args':[3], 'self':{'key': 'value'} }) + echo funcref#Call(f, [2]) + " prints "32value" + + echo funcref#Call('no value') +< + echo funcref#Call(f, [2]) diff --git a/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt b/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt new file mode 100644 index 00000000..bc6e0028 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/doc/tiny_cmd.txt @@ -0,0 +1,18 @@ +*tiny-cmd* make long commands short so that they hopefully no longer trigger "press Enter .. [ok]" + Author: Marc Weber, marco-oweber@gmx.de + +----------------------------------------------------------------------- +HOWTO~ + +Problem: > + exec 'map :silent! let g:g="'.repeat('foobar ',200).'"' +Now run the mapping by pressing and you notice what I'm talking about + +Solution (Example): + + +Example usage: > + let nr = tiny_cmd#Put('let g:g="'.repeat('foobar ',200).'"') + exec 'map :exec tiny_cmd#Get('.nr.')' +< +Use Pop instead of Get if you use this command once only diff --git a/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt b/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt new file mode 100644 index 00000000..0b20bb38 --- /dev/null +++ b/sources_non_forked/vim-addon-mw-utils/vim-addon-mw-utils-addon-info.txt @@ -0,0 +1,9 @@ +{ + "name" : "vim-addon-mw-utils", + "version" : "0.0", + "author" : "Marc Weber ", + "maintainer" : "Marc Weber ", + "repository" : {"type": "git", "url": "git://github.com/MarcWeber/vim-addon-manager-known-repositories.git"}, + "dependencies" : {}, + "description" : "various utils such as caching interpreted contents of files or advanced glob like things" +} diff --git a/sources_non_forked/vim-bundle-mako/README.md b/sources_non_forked/vim-bundle-mako/README.md new file mode 100644 index 00000000..1867831c --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/README.md @@ -0,0 +1,23 @@ +This project is a colleciton of vim scripts that relate to the Mako templating +engine for python. Most of thse are not at all written by me, just packaged +here from the vim-script site. The purpose is to make them easy to use with +pathogen.vim. + +Useful configuration variables: + +* `g:mako_detect_lang_from_ext`: when set to 1 (the default), the ftdetect + script will attempt to figure out the "outer" filetype of the file by + stripping the ".mako" extension (eg: index.html.mako will be treated as HTML, + while script.cpp.mako will be treated as C++). Set to 0 to prevent this + detection. +* `g:mako_default_outer_lang`: if ftdetect cannot detect the "outer" filetype of + the file, this sets the default filetype used. If not set, defaults to "html". +* `g:mako_extension`: set to the default string (with leading dot). Default is ".mako" + +About mako: http://www.makotemplates.org/ + +Externally sourced scripts: + +* [indent/mako.vim](http://www.vim.org/scripts/script.php?script_id=2663) 0.4 by Scott Torborg +* [syntax/mako.vim](http://www.vim.org/scripts/script.php?script_id=1858) 0.6.1 by Armin Ronacher + diff --git a/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim new file mode 100644 index 00000000..49b7be04 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/ftdetect/mako.vim @@ -0,0 +1,14 @@ +if !exists("g:mako_detect_lang_from_ext") + let g:mako_detect_lang_from_ext = 1 +endif +if !exists("g:mako_extension") + let g:mako_extension = ".mako" +endif +if g:mako_detect_lang_from_ext + exe 'au BufNewFile *.*' . g:mako_extension . ' execute "do BufNewFile filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype' + " it's important to get this before any of the normal BufRead autocmds execute + " for this file, otherwise a mako tag at the start of the file can cause the + " filetype to be set to mason + exe 'au BufReadPre *.*' . g:mako_extension . ' execute "do BufRead filetypedetect " . expand(":r") | let b:mako_outer_lang = &filetype' +endif +exe 'au BufRead,BufNewFile *' . g:mako_extension . ' set filetype=mako' diff --git a/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim new file mode 100644 index 00000000..565defc7 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/ftplugin/mako.vim @@ -0,0 +1,19 @@ +" Vim filetype plugin file +" Language: Mako +" Maintainer: Randy Stauner +" Last Change: 2019-09-06 +" Version: 0.2 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=:## +setlocal commentstring=##%s + +if exists("loaded_matchit") + let b:match_ignorecase = 1 + let b:match_words = "<:>," . + \ "<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>," . + \ "<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>," . + \ "<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>" +endif diff --git a/sources_non_forked/vim-bundle-mako/indent/mako.vim b/sources_non_forked/vim-bundle-mako/indent/mako.vim new file mode 100644 index 00000000..f1f9482a --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/indent/mako.vim @@ -0,0 +1,428 @@ +" Vim indent file +" Language: Mako +" Author: Scott Torborg +" Version: 0.4 +" License: Do What The Fuck You Want To Public License (WTFPL) +" +" --------------------------------------------------------------------------- +" +" DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +" Version 2, December 2004 +" +" Copyright (C) 2004 Sam Hocevar +" +" Everyone is permitted to copy and distribute verbatim or modified +" copies of this license document, and changing it is allowed as long +" as the name is changed. +" +" DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +" +" 0. You just DO WHAT THE FUCK YOU WANT TO. +" +" --------------------------------------------------------------------------- +" +" This script does more useful indenting for Mako HTML templates. It indents +" inside of control blocks, defs, etc. Note that this indenting style will +" sacrifice readability of the output text for the sake of readability of the +" template. +" +" We'll use HTML indenting globally, python inside <% %> blocks. Inspired by +" the excellent PHP + HTML indentation files such as php.vim by Pim Snel. +" +" Changelog: +" 0.4 - 5 March 2010 +" - Added license information +" 0.3 - 15 September 2009 +" - Added explicit indenting for ## comments, fixed unindenting count, +" thanks to Mike Lewis (@MikeRLewis) for this +" 0.2 - 15 June 2009 +" - Fixed issue where opening and closing mako tags on the same line +" would cause incorrect indenting +" 0.1 - 06 June 2009 +" - Initial public release of mako indent file + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal nosmartindent +setlocal noautoindent +setlocal nocindent +setlocal nolisp +setlocal expandtab +setlocal softtabstop=2 +setlocal shiftwidth=2 + +setlocal indentexpr=GetMakoIndent() +setlocal indentkeys+=*,<>>,,end,: + +" Only define the function once. +if exists("*GetMakoIndent") + finish +endif + +if exists('g:html_indent_tags') + unlet g:html_indent_tags +endif + +function IsInsidePythonBlock(startline) + " Loop until we get a line that's either <% or %> + let lnum = a:startline + while getline(lnum) !~ '\(%>\|<%\)$' && lnum > 0 + let lnum = lnum - 1 + endwhile + + " lnum points to the last control. If it's a <% then we're inside an + " embedded python block, otherwise we're not. + return getline(lnum) =~ '<%$' +endfunction + +function GetMakoIndent() + " Find a non-empty line above the current line + let lnum = prevnonblank(v:lnum - 1) + + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let line = getline(lnum) " last line + let cline = getline(v:lnum) " current line + let pline = getline(lnum - 1) " previous to last line + let ind = indent(lnum) + if line =~ '^\s*##' + return indent(lnum) + end + + let restore_ic=&ic + let &ic=1 " ignore case + + let ind = HtmlIndentSum(lnum, -1) + let ind = HtmlIndentSum(lnum, -1) + let ind = ind + HtmlIndentSum(v:lnum, 0) + + let &ic=restore_ic + + let ind = indent(lnum) + (&sw * ind) + + " Indent after %anything: or <%anything NOT ending in /> + if line =~ '^\s*%.*:\s*$' + let ind = ind + &sw + endif + + " Unindent before %end* or $' + let scanlnum = lnum + " Scan backwards until we find the beginning of this python block. + while getline(scanlnum) !~ '<%$' && scanlnum > 0 + let scanlnum = scanlnum - 1 + endwhile + let ind = indent(scanlnum) + endif + + " If we're inside a python block and the previous line ends in a colon, + " indent. + if IsInsidePythonBlock(lnum - 1) + " Indent after : + if line =~ '\:$' + let ind = ind + &sw + endif + endif + + return ind +endfunction + + +" [-- helper function to assemble tag list --] +fun! HtmlIndentPush(tag) + if exists('g:html_indent_tags') + let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag + else + let g:html_indent_tags = a:tag + endif +endfun + +fun! MakoIndentPush(tag) + if exists('g:mako_indent_tags') + let g:mako_indent_tags = g:mako_indent_tags.'\|'.a:tag + else + let g:mako_indent_tags = a:tag + endif +endfun + +" [-- --] +call HtmlIndentPush('a') +call HtmlIndentPush('abbr') +call HtmlIndentPush('address') +call HtmlIndentPush('applet') +call HtmlIndentPush('article') +call HtmlIndentPush('aside') +call HtmlIndentPush('audio') +call HtmlIndentPush('b') +call HtmlIndentPush('bdi') +call HtmlIndentPush('bdo') +call HtmlIndentPush('blockquote') +call HtmlIndentPush('button') +call HtmlIndentPush('canvas') +call HtmlIndentPush('caption') +call HtmlIndentPush('cite') +call HtmlIndentPush('code') +call HtmlIndentPush('colgroup') +call HtmlIndentPush('content') +call HtmlIndentPush('data') +call HtmlIndentPush('datalist') +call HtmlIndentPush('del') +call HtmlIndentPush('details') +call HtmlIndentPush('dfn') +call HtmlIndentPush('dialog') +call HtmlIndentPush('dir') +call HtmlIndentPush('div') +call HtmlIndentPush('dl') +call HtmlIndentPush('element') +call HtmlIndentPush('em') +call HtmlIndentPush('fieldset') +call HtmlIndentPush('figcaption') +call HtmlIndentPush('figure') +call HtmlIndentPush('footer') +call HtmlIndentPush('form') +call HtmlIndentPush('h1') +call HtmlIndentPush('h2') +call HtmlIndentPush('h3') +call HtmlIndentPush('h4') +call HtmlIndentPush('h5') +call HtmlIndentPush('h6') +call HtmlIndentPush('header') +call HtmlIndentPush('hgroup') +call HtmlIndentPush('i') +call HtmlIndentPush('iframe') +call HtmlIndentPush('ins') +call HtmlIndentPush('kbd') +call HtmlIndentPush('label') +call HtmlIndentPush('legend') +call HtmlIndentPush('li') +call HtmlIndentPush('main') +call HtmlIndentPush('map') +call HtmlIndentPush('mark') +call HtmlIndentPush('MediaStream') +call HtmlIndentPush('menu') +call HtmlIndentPush('menuitem') +call HtmlIndentPush('meter') +call HtmlIndentPush('nav') +call HtmlIndentPush('noembed') +call HtmlIndentPush('noscript') +call HtmlIndentPush('object') +call HtmlIndentPush('ol') +call HtmlIndentPush('optgroup') +call HtmlIndentPush('option') +call HtmlIndentPush('output') +call HtmlIndentPush('picture') +call HtmlIndentPush('pre') +call HtmlIndentPush('progress') +call HtmlIndentPush('q') +call HtmlIndentPush('rb') +call HtmlIndentPush('rp') +call HtmlIndentPush('rt') +call HtmlIndentPush('rtc') +call HtmlIndentPush('ruby') +call HtmlIndentPush('s') +call HtmlIndentPush('samp') +call HtmlIndentPush('script') +call HtmlIndentPush('section') +call HtmlIndentPush('select') +call HtmlIndentPush('shadow') +call HtmlIndentPush('slot') +call HtmlIndentPush('small') +call HtmlIndentPush('span') +call HtmlIndentPush('strong') +call HtmlIndentPush('style') +call HtmlIndentPush('sub') +call HtmlIndentPush('summary') +call HtmlIndentPush('sup') +call HtmlIndentPush('table') +call HtmlIndentPush('template') +call HtmlIndentPush('textarea') +call HtmlIndentPush('time') +call HtmlIndentPush('title') +call HtmlIndentPush('tt') +call HtmlIndentPush('u') +call HtmlIndentPush('ul') +call HtmlIndentPush('var') +call HtmlIndentPush('video') + +" For some reason the default HTML indentation script doesn't consider these +" elements to be worthy of indentation. +call HtmlIndentPush('p') +call HtmlIndentPush('dt') +call HtmlIndentPush('dd') + + +" [-- --] +if !exists('g:html_indent_strict') + call HtmlIndentPush('body') + call HtmlIndentPush('head') + call HtmlIndentPush('html') + call HtmlIndentPush('tbody') +endif + + +" [-- --] +if !exists('g:html_indent_strict_table') + call HtmlIndentPush('th') + call HtmlIndentPush('td') + call HtmlIndentPush('tr') + call HtmlIndentPush('tfoot') + call HtmlIndentPush('thead') +endif + +" [-- --] +call HtmlIndentPush('abbr') +call HtmlIndentPush('acronym') +call HtmlIndentPush('applet') +call HtmlIndentPush('audio') +call HtmlIndentPush('basefont') +call HtmlIndentPush('bgsound') +call HtmlIndentPush('big') +call HtmlIndentPush('blink') +call HtmlIndentPush('center') +call HtmlIndentPush('command') +call HtmlIndentPush('content') +call HtmlIndentPush('dir') +call HtmlIndentPush('element') +call HtmlIndentPush('embed') +call HtmlIndentPush('font') +call HtmlIndentPush('frame') +call HtmlIndentPush('frameset') +call HtmlIndentPush('image') +call HtmlIndentPush('img') +call HtmlIndentPush('isindex') +call HtmlIndentPush('keygen') +call HtmlIndentPush('listing') +call HtmlIndentPush('marquee') +call HtmlIndentPush('menuitem') +call HtmlIndentPush('multicol') +call HtmlIndentPush('nextid') +call HtmlIndentPush('nobr') +call HtmlIndentPush('noembed') +call HtmlIndentPush('noframes') +call HtmlIndentPush('object') +call HtmlIndentPush('plaintext') +call HtmlIndentPush('shadow') +call HtmlIndentPush('spacer') +call HtmlIndentPush('strike') +call HtmlIndentPush('tt') +call HtmlIndentPush('xmp') + +" [-- --] +call MakoIndentPush('%def') +call MakoIndentPush('%block') +call MakoIndentPush('%call') +call MakoIndentPush('%doc') +call MakoIndentPush('%text') +call MakoIndentPush('%.\+:.\+') + +delfun HtmlIndentPush +delfun MakoIndentPush + +set cpo-=C + +" [-- get number of regex matches in a string --] +fun! MatchCount(expr, pat) + let mpos = 0 + let mcount = 0 + let expr = a:expr + while (mpos > -1) + let mend = matchend(expr, a:pat) + if mend > -1 + let mcount = mcount + 1 + endif + if mend == mpos + let mpos = mpos + 1 + else + let mpos = mend + endif + let expr = strpart(expr, mpos) + endwhile + return mcount +endfun + +" [-- count indent-increasing tags of line a:lnum --] +fun! HtmlIndentOpen(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)\('.g:html_indent_tags.'\)\>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-decreasing tags of line a:lnum --] +fun! HtmlIndentClose(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)/\('.g:html_indent_tags.'\)\>>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-increasing mako tags of line a:lnum --] +fun! MakoIndentOpen(lnum) + let s = substitute('x'.getline(a:lnum), + \ '.\{-}\(\(<\)\('.g:mako_indent_tags.'\)\>\)', "\1", 'g') + let s = substitute(s, "[^\1].*$", '', '') + return strlen(s) +endfun + +" [-- count indent-decreasing mako tags of line a:lnum --] +fun! MakoIndentClose(lnum) + let mcount = MatchCount(getline(a:lnum), '') + let mcount = mcount + MatchCount(getline(a:lnum), '<\('.g:mako_indent_tags.'\)[^>]*/>') + return mcount +endfun + +" [-- count indent-increasing '{' of (java|css) line a:lnum --] +fun! HtmlIndentOpenAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g')) +endfun + +" [-- count indent-decreasing '}' of (java|css) line a:lnum --] +fun! HtmlIndentCloseAlt(lnum) + return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g')) +endfun + +" [-- return the sum of indents respecting the syntax of a:lnum --] +fun! HtmlIndentSum(lnum, style) + let open = HtmlIndentOpen(a:lnum) + MakoIndentOpen(a:lnum) + let close = HtmlIndentClose(a:lnum) + MakoIndentClose(a:lnum) + if a:style == match(getline(a:lnum), '^\s*HtmlIndentOpenAlt(a:lnum) - HtmlIndentCloseAlt(a:lnum) + endif + endif + return 0 +endfun + +" vim: set ts=4 sw=4: diff --git a/sources_non_forked/vim-bundle-mako/syntax/mako.vim b/sources_non_forked/vim-bundle-mako/syntax/mako.vim new file mode 100644 index 00000000..83736995 --- /dev/null +++ b/sources_non_forked/vim-bundle-mako/syntax/mako.vim @@ -0,0 +1,103 @@ +" Vim syntax file +" Language: Mako +" Maintainer: Armin Ronacher +" URL: http://lucumr.pocoo.org/ +" Last Change: 2013-05-01 +" Version: 0.6.1+ +" +" Thanks to Brine Rue who noticed a bug in the +" delimiter handling. +" +" Known Limitations +" the <%text> block does not have correct attributes + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +if !exists("b:mako_outer_lang") + if exists("g:mako_default_outer_lang") + let b:mako_outer_lang = g:mako_default_outer_lang + else + let b:mako_outer_lang = "html" + endif +endif +if !exists("main_syntax") + let main_syntax = b:mako_outer_lang +endif + +"Source the outer syntax file +execute "ru! syntax/" . b:mako_outer_lang . ".vim" +if exists("b:current_syntax") + unlet b:current_syntax +endif + +if b:mako_outer_lang == "html" + " tell html.vim what syntax groups should take precedence (see :help html.vim) + syn cluster htmlPreproc add=makoLine,makoVariable,makoTag,makoDocComment,makoDefEnd,makoText,makoDelim,makoEnd,makoComment,makoEscape +endif + +"Put the python syntax file in @pythonTop +syn include @pythonTop syntax/python.vim + +" End keywords +syn keyword makoEnd contained endfor endwhile endif endtry enddef + +" Block rules +syn region makoLine matchgroup=makoDelim start=#^\s*%# end=#$# keepend contains=@pythonTop,makoEnd +syn region makoBlock matchgroup=makoDelim start=#<%!\?# end=#%># keepend contains=@pythonTop,makoEnd + +" Variables +syn region makoNested start="{" end="}" transparent display contained contains=makoNested,@pythonTop +syn region makoVariable matchgroup=makoDelim start=#\${# end=#}# contains=makoNested,@pythonTop + +" Comments +syn region makoComment start="^\s*##" end="$" +syn region makoDocComment matchgroup=makoDelim start="<%doc>" end="" keepend + +" Literal Blocks +syn region makoText matchgroup=makoDelim start="<%text[^>]*>" end="" + +" Attribute Sublexing +syn match makoAttributeKey containedin=makoTag contained "[a-zA-Z_][a-zA-Z0-9_]*=" +syn region makoAttributeValue containedin=makoTag contained start=/"/ skip=/\\"/ end=/"/ +syn region makoAttributeValue containedin=MakoTag contained start=/'/ skip=/\\'/ end=/'/ + +" Tags +syn region makoTag matchgroup=makoDelim start="<%\(def\|call\|page\|include\|namespace\|inherit\|block\|[a-zA-Z_][a-zA-Z0-9_]*:[a-zA-Z_][a-zA-Z0-9_]*\)\>" end="/\?>" +syn match makoDelim "" + +syn region makoJavaScript matchgroup=makoDelim start=+<%block .*js.*>+ keepend end=++ contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc,makoLine,makoBlock,makoVariable +syn region makoCssStyle matchgroup=makoDelim start=+<%block .*css.*>+ keepend end=++ contains=@htmlCss,htmlTag,htmlEndTag,htmlCssStyleComment,@htmlPreproc,makoLine,makoBlock,makoVariable + +" Newline Escapes +syn match makoEscape /\\$/ + +" Default highlighting links +if version >= 508 || !exists("did_mako_syn_inits") + if version < 508 + let did_mako_syn_inits = 1 + com -nargs=+ HiLink hi link + else + com -nargs=+ HiLink hi def link + endif + + HiLink makoDocComment makoComment + HiLink makoDefEnd makoDelim + + HiLink makoAttributeKey Type + HiLink makoAttributeValue String + HiLink makoText Normal + HiLink makoDelim Preproc + HiLink makoEnd Keyword + HiLink makoComment Comment + HiLink makoEscape Special + + delc HiLink +endif + +let b:current_syntax = b:mako_outer_lang diff --git a/sources_non_forked/vim-coffee-script/.gitignore b/sources_non_forked/vim-coffee-script/.gitignore new file mode 100644 index 00000000..1ff7b050 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/.gitignore @@ -0,0 +1,4 @@ +.*.sw[a-z] +.*.un~ +doc/tags + diff --git a/sources_non_forked/vim-coffee-script/Copying.md b/sources_non_forked/vim-coffee-script/Copying.md new file mode 100644 index 00000000..9520fb91 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Copying.md @@ -0,0 +1,54 @@ +All files except: + +ftdetect/vim-literate-coffeescript.vim +indent/litcoffee.vim +syntax/litcoffee.vim +test/test.coffee.md +test/test.litcoffee +test/test.png + +Issued under WTFPL: + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2010 to 2014 Mick Koch + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + + +These files issed under this license: + +ftdetect/vim-literate-coffeescript.vim +indent/litcoffee.vim +syntax/litcoffee.vim +test/test.coffee.md +test/test.litcoffee +test/test.png + +Copyright (c) 2013 Michael Smith + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sources_non_forked/vim-coffee-script/Makefile b/sources_non_forked/vim-coffee-script/Makefile new file mode 100644 index 00000000..e6ef4092 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Makefile @@ -0,0 +1,25 @@ +REF = HEAD +VERSION = $(shell git describe --always $(REF)) + +ARCHIVE = vim-coffee-script-$(VERSION).zip +ARCHIVE_DIRS = after autoload compiler doc ftdetect ftplugin indent syntax + +# Don't do anything by default. +all: + +# Make vim.org zipball. +archive: + git archive $(REF) -o $(ARCHIVE) -- $(ARCHIVE_DIRS) + +# Remove zipball. +clean: + -rm -f $(ARCHIVE) + +# Build the list of syntaxes for @coffeeAll. +coffeeAll: + @grep -E 'syn (match|region)' syntax/coffee.vim |\ + grep -v 'contained' |\ + awk '{print $$3}' |\ + uniq + +.PHONY: all archive clean hash coffeeAll diff --git a/sources_non_forked/vim-coffee-script/News.md b/sources_non_forked/vim-coffee-script/News.md new file mode 100644 index 00000000..9f3f1390 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/News.md @@ -0,0 +1,22 @@ +### Version 003 (October 10, 2014) + +Almost 3 years' worth of fixes and (hopefully) improvements. + +### Version 002 (December 5, 2011) + +Added binary numbers (0b0101) and fixed some bugs (#9, #62, #63, #65). + +### Version 001 (October 18, 2011) + +Removed deprecated `coffee_folding` option, added `coffee_compile_vert` option, +split out compiler, fixed indentation and syntax bugs, and added Haml support +and omnicompletion. + + - The coffee compiler is now a proper vim compiler that can be loaded with + `:compiler coffee`. + - The `coffee_compile_vert` option can now be set to split the CoffeeCompile + buffer vertically by default. + - CoffeeScript is now highlighted inside the `:coffeescript` filter in Haml. + - Omnicompletion (`:help compl-omni`) now uses JavaScript's dictionary to + complete words. + - We now have a fancy version number. diff --git a/sources_non_forked/vim-coffee-script/Readme.md b/sources_non_forked/vim-coffee-script/Readme.md new file mode 100644 index 00000000..053a71b8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Readme.md @@ -0,0 +1,591 @@ +This project adds [CoffeeScript] support to vim. It covers syntax, indenting, +compiling, and more. + +![Screenshot](http://i.imgur.com/j1BhpZQ.png) + +[CoffeeScript]: http://coffeescript.org/ + +## Table of Contents + +- Installation + - [Requirements](#requirements) + - [Install using Pathogen](#install-using-pathogen) + - [Install using Vundle](#install-using-vundle) + - [Install from a Zip File](#install-from-a-zip-file) +- Coffee Commands + - [Compile to JavaScript](#compile-to-javascript) + - [Compile CoffeeScript Snippets](#coffeecompile-compile-coffeescript-snippets) + - [Live Preview Compiling](#coffeewatch-live-preview-compiling) + - [Run CoffeeScript Snippets](#coffeerun-run-coffeescript-snippets) + - [Lint your CoffeeScript](#coffeelint-lint-your-coffeescript) +- Extras + - [Literate CoffeeScript](#literate-coffeescript) + - [CoffeeScript in HTML](#coffeescript-in-html) + - [CoffeeScript in Haml](#coffeescript-in-haml) +- Configuration + - [Custom Autocmds](#custom-autocmds) + - [Configuration Variables](#configuration-variables) + - [Configure Syntax Highlighting](#configure-syntax-highlighting) + - [Tune Vim for CoffeeScript](#tune-vim-for-coffeescript) + +## Requirements + + - vim 7.4 or later + - coffee 1.2.0 or later + +## Install using Pathogen + +This project uses rolling releases based on git commits, so pathogen is a +natural fit for it. If you're already using pathogen, you can skip to step 4. + +1. Install [pathogen.vim] into `~/.vim/autoload/` (see [pathogen's + readme][install-pathogen] for more information.) + +[pathogen.vim]: http://www.vim.org/scripts/script.php?script_id=2332 +[install-pathogen]: https://github.com/tpope/vim-pathogen#installation + +2. Enable pathogen in your vimrc. Here's a bare-minimum vimrc that enables + all the features of `vim-coffee-script`: + + ```vim + call pathogen#infect() + syntax enable + filetype plugin indent on + ``` + + If you already have a vimrc built up, just make sure it contains these calls, + in this order. + +3. Create the directory `~/.vim/bundle/`: + + mkdir ~/.vim/bundle + +4. Clone the `vim-coffee-script` repo into `~/.vim/bundle/`: + + git clone https://github.com/kchmck/vim-coffee-script.git ~/.vim/bundle/vim-coffee-script/ + +Updating takes two steps: + +1. Change into `~/.vim/bundle/vim-coffee-script/`: + + cd ~/.vim/bundle/vim-coffee-script + +2. Pull in the latest changes: + + git pull + +## Install using Vundle + +1. [Install Vundle] into `~/.vim/bundle/`. + +[Install Vundle]: https://github.com/gmarik/vundle#quick-start + +2. Configure your vimrc for Vundle. Here's a bare-minimum vimrc that enables all + the features of `vim-coffee-script`: + + + ```vim + set nocompatible + filetype off + + set rtp+=~/.vim/bundle/vundle/ + call vundle#rc() + + Plugin 'kchmck/vim-coffee-script' + + syntax enable + filetype plugin indent on + ``` + + If you're adding Vundle to a built-up vimrc, just make sure all these calls + are in there and that they occur in this order. + +3. Open vim and run `:PluginInstall`. + +To update, open vim and run `:PluginInstall!` (notice the bang!) + +## Install from a Zip File + +1. Download the latest zip file from [vim.org][zip]. + +2. Extract the archive into `~/.vim/`: + + unzip -od ~/.vim/ ARCHIVE.zip + + This should create the files `~/.vim/autoload/coffee.vim`, + `~/.vim/compiler/coffee.vim`, etc. + +You can update the plugin using the same steps. + +[zip]: http://www.vim.org/scripts/script.php?script_id=3590 + +## Compile to JavaScript + +A `coffee` wrapper for use with `:make` is enabled automatically for coffee +files if no other compiler is loaded. To enable it manually, run + + :compiler coffee + +The `:make` command is then configured to use the `coffee` compiler and +recognize its errors. I've included a quick reference here but be sure to check +out [`:help :make`][make] for a full reference of the command. + + ![make](http://i.imgur.com/scUXmxR.png) + + ![make Result](http://i.imgur.com/eGIjEdn.png) + +[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg + +Consider the full signature of a `:make` call as + + :[silent] make[!] [COFFEE-OPTIONS]... + +By default `:make` shows all compiler output and jumps to the first line +reported as an error. Compiler output can be hidden with a leading `:silent`: + + :silent make + +Line-jumping can be turned off by adding a bang: + + :make! + +`COFFEE-OPTIONS` given to `:make` are passed along to `coffee` (see also +[`coffee_make_options`](#coffee_make_options)): + + :make --bare --output /some/dir + +See the [full table of options](http://coffeescript.org/#usage) for a +list of all the options that `coffee` recognizes. + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_make_options`](#coffee_make_options) + +#### The quickfix window + +Compiler errors are added to the [quickfix] list by `:make`, but the quickfix +window isn't automatically shown. The [`:cwindow`][cwindow] command will pop up +the quickfix window if there are any errors: + + :make + :cwindow + +This is usually the desired behavior, so you may want to add an autocmd to your +vimrc to do this automatically: + + autocmd QuickFixCmdPost * nested cwindow | redraw! + +The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but +can removed for gVim. + +[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix +[cwindow]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cwindow + +#### Recompile on write + +To recompile a file when it's written, add a `BufWritePost` autocmd to your +vimrc: + + autocmd BufWritePost *.coffee silent make! + +#### Cake and Cakefiles + +A `cake` compiler is also available with the call + + :compiler cake + +You can then use `:make` as above to run your Cakefile and capture any `coffee` +errors: + + :silent make build + +It runs within the current directory, so make sure you're in the directory of +your Cakefile before calling it. + +*Configuration*: [`coffee_cake`](#coffee_cake), +[`coffee_cake_options`](#coffee_cake_options) + +## CoffeeCompile: Compile CoffeeScript Snippets + +CoffeeCompile shows how the current file or a snippet of CoffeeScript is +compiled to JavaScript. + + :[RANGE] CoffeeCompile [vert[ical]] [WINDOW-SIZE] + +Calling `:CoffeeCompile` without a range compiles the whole file: + + ![CoffeeCompile](http://i.imgur.com/0zFG0l0.png) + + ![CoffeeCompile Result](http://i.imgur.com/bpiAxaa.png) + +Calling it with a range, like in visual mode, compiles only the selected snippet +of CoffeeScript: + + ![CoffeeCompile Snippet](http://i.imgur.com/x3OT3Ay.png) + + ![Compiled Snippet](http://i.imgur.com/J02j4T8.png) + +Each file gets its own CoffeeCompile buffer, and the same buffer is used for all +future calls of `:CoffeeCompile` on that file. It can be quickly closed by +hitting `q` in normal mode. + +Using `vert` opens the CoffeeCompile buffer vertically instead of horizontally +(see also [`coffee_compile_vert`](#coffee_compile_vert)): + + :CoffeeCompile vert + +By default the CoffeeCompile buffer splits the source buffer in half, but this +can be overridden by passing in a `WINDOW-SIZE`: + + :CoffeeCompile 4 + +*Configuration*: [`coffee_compiler`](#coffee_compiler`), +[`coffee_compile_vert`](#coffee_compile_vert) + +#### Quick syntax checking + +If compiling a snippet results in a compiler error, CoffeeCompile adds that +error to the [quickfix] list. + +[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix + + ![Syntax Checking](http://i.imgur.com/RC8accF.png) + + ![Syntax Checking Result](http://i.imgur.com/gi1ON75.png) + +You can use this to quickly check the syntax of a snippet. + +## CoffeeWatch: Live Preview Compiling + +CoffeeWatch emulates using the Try CoffeeScript preview box on the [CoffeeScript +homepage][CoffeeScript]. + + ![CoffeeWatch](http://i.imgur.com/TRHdIMG.png) + + ![CoffeeWatch Result](http://i.imgur.com/rJbOeeS.png) + +CoffeeWatch takes the same options as CoffeeCompile: + + :CoffeeWatch [vert[ical]] [WINDOW-SIZE] + +After a source buffer is watched, leaving insert mode or saving the file fires +off a recompile of the CoffeeScript: + + ![Insert Mode](http://i.imgur.com/SBVcf4k.png) + + ![Recompile](http://i.imgur.com/pbPMog7.png) + +You can force recompilation by calling `:CoffeeWatch`. + +To get synchronized scrolling of the source buffer and CoffeeWatch buffer, set +[`'scrollbind'`](http://vimdoc.sourceforge.net/htmldoc/options.html#'scrollbind') +on each: + + :setl scrollbind + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_watch_vert`](#coffee_watch_vert) + +## CoffeeRun: Run CoffeeScript Snippets + +CoffeeRun compiles the current file or selected snippet and runs the resulting +JavaScript. + + ![CoffeeRun](http://i.imgur.com/YSkHUuQ.png) + + ![CoffeeRun Output](http://i.imgur.com/wZQbggN.png) + +The command has two forms: + + :CoffeeRun [PROGRAM-OPTIONS]... + +This form applies when no `RANGE` is given or when the given range is `1,$` +(first line to last line). It allows passing `PROGRAM-OPTIONS` to your compiled +program. The filename is passed directly to `coffee` so you must save the file +for your changes to take effect. + + :RANGE CoffeeRun [COFFEE-OPTIONS]... + +This form applies with all other ranges. It compiles and runs the lines within +the given `RANGE` and any extra `COFFEE-OPTIONS` are passed to `coffee`. + +*Configuration*: [`coffee_compiler`](#coffee_compiler), +[`coffee_run_vert`](#coffee_run_vert) + +## CoffeeLint: Lint your CoffeeScript + +CoffeeLint runs [coffeelint](http://www.coffeelint.org/) (version 1.4.0 or later +required) on the current file and adds any issues to the [quickfix] list. + + ![CoffeeLint](http://i.imgur.com/UN8Nr5N.png) + + ![CoffeeLint Result](http://i.imgur.com/9hSIj3W.png) + + :[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]... [ | cwindow] + +If a `RANGE` is given, only those lines are piped to `coffeelint`. Options given +in `COFFEELINT-OPTIONS` are passed to `coffeelint` (see also +[`coffee_lint_options`](#coffee_lint_options)): + + :CoffeeLint -f lint.json + +It behaves very similar to `:make`, described [above](#compile-to-javascript). + + :CoffeeLint! | cwindow + +*Configuration*: [`coffee_linter`](#coffee_linter), +[`coffee_lint_options`](#coffee_lint_options) + +## Literate CoffeeScript + +Literate CoffeeScript syntax and indent support is now built in! The `Coffee` +commands detect when they're running on a litcoffee file and pass the +`--literate` flag to their respective tools. + +Literate CoffeeScript syntax and indent support was written by @mintplant +(Michael Smith). A standalone repo +[exists](https://github.com/jwhitley/vim-literate-coffeescript), but you'll +need to copy the `ftplugin/litcoffee.vim` file or set up an autocmd to get the +`Coffee` commands to be automatically loaded for litcoffee files. + +## CoffeeScript in HTML + +CoffeeScript is highlighted and indented within + +```html + +``` + +blocks in html files. + +## CoffeeScript in Haml + +CoffeeScript is highlighted within the `:coffeescript` filter in haml files: + +```haml +:coffeescript + console.log "hullo" +``` + +At this time, coffee indenting doesn't work in these blocks. + +## Custom Autocmds + +You can [define commands][autocmd-explain] to be ran automatically on these +custom events. + +In all cases, the name of the command running the event (`CoffeeCompile`, +`CoffeeWatch`, or `CoffeeRun`) is matched by the [`{pat}`][autocmd] argument. +You can match all commands with a `*` or only specific commands by separating +them with a comma: `CoffeeCompile,CoffeeWatch`. + +[autocmd-explain]: http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3 +[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd + +#### CoffeeBufNew + +CoffeeBufNew is ran when a new scratch buffer is created. It's called from the +new buffer, so it can be used to do additional set up. + +```vim +augroup CoffeeBufNew + autocmd User * set wrap +augroup END +``` + +*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun + +#### CoffeeBufUpdate + +CoffeeBufUpdate is ran when a scratch buffer is updated with output from +`coffee`. It's called from the scratch buffer, so it can be used to alter the +compiled output. + +```vim +" Switch back to the source buffer after updating. +augroup CoffeeBufUpdate + autocmd User CoffeeCompile,CoffeeRun exec bufwinnr(b:coffee_src_buf) 'wincmd w' +augroup END +``` + +For example, to strip off the "Generated by" comment on the first line, put this +in your vimrc: + +```vim +function! s:RemoveGeneratedBy() + " If there was an error compiling, there's no comment to remove. + if v:shell_error + return + endif + + " Save cursor position. + let pos = getpos('.') + + " Remove first line. + set modifiable + 1 delete _ + set nomodifiable + + " Restore cursor position. + call setpos('.', pos) +endfunction + +augroup CoffeeBufUpdate + autocmd User CoffeeCompile,CoffeeWatch call s:RemoveGeneratedBy() +augroup END +``` + +*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun + +## Configuration Variables + +This is the full list of configuration variables available, with example +settings and default values. Use these in your vimrc to control the default +behavior. + +#### coffee\_indent\_keep\_current + +By default, the indent function matches the indent of the previous line if it +doesn't find a reason to indent or outdent. To change this behavior so it +instead keeps the [current indent of the cursor][98], use + + let coffee_indent_keep_current = 1 + +[98]: https://github.com/kchmck/vim-coffee-script/pull/98 + +*Default*: `unlet coffee_indent_keep_current` + +Note that if you change this after a coffee file has been loaded, you'll have to +reload the indent script for the change to take effect: + + unlet b:did_indent | runtime indent/coffee.vim + +#### coffee\_compiler + +Path to the `coffee` executable used by the `Coffee` commands: + + let coffee_compiler = '/usr/bin/coffee' + +*Default*: `'coffee'` (search `$PATH` for executable) + +#### coffee\_make\_options + +Options to pass to `coffee` with `:make`: + + let coffee_make_options = '--bare' + +*Default*: `''` (nothing) + +Note that `coffee_make_options` is embedded into `'makeprg'`, so `:compiler +coffee` must be ran after changing `coffee_make_options` for the changes to take +effect. + +#### coffee\_cake + +Path to the `cake` executable: + + let coffee_cake = '/opt/bin/cake' + +*Default*: `'cake'` (search `$PATH` for executable) + +#### coffee\_cake\_options + +Options to pass to `cake` with `:make`: + + let coffee_cake_options = 'build' + +*Default*: `''` (nothing) + +#### coffee\_linter + +Path to the `coffeelint` executable: + + let coffee_linter = '/opt/bin/coffeelint' + +*Default*: `'coffeelint'` (search `$PATH` for executable) + +#### coffee\_lint\_options + +Options to pass to `coffeelint`: + + let coffee_lint_options = '-f lint.json' + +*Default*: `''` (nothing) + +#### coffee\_compile\_vert + +Open the CoffeeCompile buffer with a vertical split instead of a horizontal +one: + + let coffee_compile_vert = 1 + +*Default*: `unlet coffee_compile_vert` + +#### coffee\_watch\_vert + +Open the CoffeeWatch buffer with a vertical split instead of a horizontal +one: + + let coffee_watch_vert = 1 + +*Default*: `unlet coffee_watch_vert` + +#### coffee\_run\_vert + +Open the CoffeeRun buffer with a vertical split instead of a horizontal +one: + + let coffee_run_vert = 1 + +*Default*: `unlet coffee_run_vert` + +## Configure Syntax Highlighting + +Add these lines to your vimrc to disable the relevant syntax group. + +#### Disable trailing whitespace error + +Trailing whitespace is highlighted as an error by default. This can be disabled +with: + + hi link coffeeSpaceError NONE + +#### Disable trailing semicolon error + +Trailing semicolons are considered an error (for help transitioning from +JavaScript.) This can be disabled with: + + hi link coffeeSemicolonError NONE + +#### Disable reserved words error + +Reserved words like `function` and `var` are highlighted as an error where +they're not allowed in CoffeeScript. This can be disabled with: + + hi link coffeeReservedError NONE + +## Tune Vim for CoffeeScript + +Changing these core settings can make vim more CoffeeScript friendly. + +#### Fold by indentation + +Folding by indentation works well for CoffeeScript functions and classes: + + ![Folding](http://i.imgur.com/gDgUBdO.png) + +To fold by indentation in CoffeeScript files, add this line to your vimrc: + + autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable + +With this, folding is disabled by default but can be quickly toggled per-file +by hitting `zi`. To enable folding by default, remove `nofoldenable`: + + autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent + +#### Two-space indentation + +To get standard two-space indentation in CoffeeScript files, add this line to +your vimrc: + + autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab diff --git a/sources_non_forked/vim-coffee-script/Thanks.md b/sources_non_forked/vim-coffee-script/Thanks.md new file mode 100644 index 00000000..8ddcf23f --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Thanks.md @@ -0,0 +1,44 @@ +Thanks to all bug reporters, and special thanks to those who have contributed +code: + + Brian Egan (brianegan): + Initial compiling support + + Ches Martin (ches): + Initial vim docs + + Chris Hoffman (cehoffman): + Add new keywoards from, to, and do + Highlight the - in negative integers + Add here regex highlighting, increase fold level for here docs + + David Wilhelm (bigfish): + CoffeeRun command + + Jay Adkisson (jayferd): + Support for eco templates + + Karl Guertin (grayrest) + Cakefiles are coffeescript + + Maciej Konieczny (narfdotpl): + Fix funny typo + + Matt Sacks (mattsa): + Javascript omni-completion + coffee_compile_vert option + + Nick Stenning (nickstenning): + Fold by indentation for coffeescript + + Simon Lipp (sloonz): + Trailing spaces are not error on lines containing only spaces + + Stéphan Kochen (stephank): + Initial HTML CoffeeScript highlighting + + Sven Felix Oberquelle (Svelix): + Haml CoffeeScript highlighting + + Wei Dai (clvv): + Fix the use of Vim built-in make command. diff --git a/sources_non_forked/vim-coffee-script/Todo.md b/sources_non_forked/vim-coffee-script/Todo.md new file mode 100644 index 00000000..3d4ffaa8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/Todo.md @@ -0,0 +1 @@ +- Don't highlight bad operator combinations diff --git a/sources_non_forked/vim-coffee-script/after/indent/html.vim b/sources_non_forked/vim-coffee-script/after/indent/html.vim new file mode 100644 index 00000000..0823e689 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/indent/html.vim @@ -0,0 +1,33 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Load the coffee and html indent functions. +silent! unlet b:did_indent +runtime indent/coffee.vim +let s:coffeeIndentExpr = &l:indentexpr + +" Load html last so it can overwrite coffee settings. +silent! unlet b:did_indent +runtime indent/html.vim +let s:htmlIndentExpr = &l:indentexpr + +" Inject our wrapper indent function. +setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum) + +function! GetCoffeeHtmlIndent(curlinenum) + " See if we're inside a coffeescript block. + let scriptlnum = searchpair('', 'bWn') + let prevlnum = prevnonblank(a:curlinenum) + + " If we're in the script block and the previous line isn't the script tag + " itself, use coffee indenting. + if scriptlnum && scriptlnum != prevlnum + exec 'return ' s:coffeeIndentExpr + endif + + " Otherwise use html indenting. + exec 'return ' s:htmlIndentExpr +endfunction diff --git a/sources_non_forked/vim-coffee-script/after/syntax/haml.vim b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim new file mode 100644 index 00000000..3e186cdc --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/syntax/haml.vim @@ -0,0 +1,23 @@ +" Language: CoffeeScript +" Maintainer: Sven Felix Oberquelle +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + + +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + +" Inherit coffee from html so coffeeComment isn't redefined and given higher +" priority than hamlInterpolation. +syn cluster hamlCoffeescript contains=@htmlCoffeeScript +syn region hamlCoffeescriptFilter matchgroup=hamlFilter +\ start="^\z(\s*\):coffee\z(script\)\?\s*$" +\ end="^\%(\z1 \| *$\)\@!" +\ contains=@hamlCoffeeScript,hamlInterpolation +\ keepend + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/after/syntax/html.vim b/sources_non_forked/vim-coffee-script/after/syntax/html.vim new file mode 100644 index 00000000..a78ba88d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/after/syntax/html.vim @@ -0,0 +1,20 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:current_syntax') + let s:current_syntax_save = b:current_syntax +endif + +" Syntax highlighting for text/coffeescript script tags +syn include @htmlCoffeeScript syntax/coffee.vim +syn region coffeeScript start=##me=s-1 keepend +\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc +\ containedin=htmlHead + +if exists('s:current_syntax_save') + let b:current_syntax = s:current_syntax_save + unlet s:current_syntax_save +endif diff --git a/sources_non_forked/vim-coffee-script/autoload/coffee.vim b/sources_non_forked/vim-coffee-script/autoload/coffee.vim new file mode 100644 index 00000000..8d727951 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/autoload/coffee.vim @@ -0,0 +1,54 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Set up some common global/buffer variables. +function! coffee#CoffeeSetUpVariables() + " Path to coffee executable + if !exists('g:coffee_compiler') + let g:coffee_compiler = 'coffee' + endif + + " Options passed to coffee with make + if !exists('g:coffee_make_options') + let g:coffee_make_options = '' + endif + + " Path to cake executable + if !exists('g:coffee_cake') + let g:coffee_cake = 'cake' + endif + + " Extra options passed to cake + if !exists('g:coffee_cake_options') + let g:coffee_cake_options = '' + endif + + " Path to coffeelint executable + if !exists('g:coffee_linter') + let g:coffee_linter = 'coffeelint' + endif + + " Options passed to CoffeeLint + if !exists('g:coffee_lint_options') + let g:coffee_lint_options = '' + endif + + " Pass the litcoffee flag to tools in this buffer if a litcoffee file is open. + " Let the variable be overwritten so it can be updated if a different filetype + " is set. + if &filetype == 'litcoffee' + let b:coffee_litcoffee = '--literate' + else + let b:coffee_litcoffee = '' + endif +endfunction + +function! coffee#CoffeeSetUpErrorFormat() + CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l, + \Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m, + \SyntaxError:\ In\ %f\\,\ %m, + \%f:%l:%c:\ error:\ %m, + \%-G%.%# +endfunction diff --git a/sources_non_forked/vim-coffee-script/compiler/cake.vim b/sources_non_forked/vim-coffee-script/compiler/cake.vim new file mode 100644 index 00000000..b49638e7 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/compiler/cake.vim @@ -0,0 +1,15 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('current_compiler') + finish +endif + +let current_compiler = 'cake' +call coffee#CoffeeSetUpVariables() + +exec 'CompilerSet makeprg=' . escape(g:coffee_cake . ' ' . +\ g:coffee_cake_options . ' $*', ' ') +call coffee#CoffeeSetUpErrorFormat() diff --git a/sources_non_forked/vim-coffee-script/compiler/coffee.vim b/sources_non_forked/vim-coffee-script/compiler/coffee.vim new file mode 100644 index 00000000..5a914578 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/compiler/coffee.vim @@ -0,0 +1,82 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" All this is needed to support compiling filenames with spaces, quotes, and +" such. The filename is escaped and embedded into the `makeprg` setting. +" +" Because of this, `makeprg` must be updated on every file rename. And because +" of that, `CompilerSet` can't be used because it doesn't exist when the +" rename autocmd is ran. So, we have to do some checks to see whether `compiler` +" was called locally or globally, and respect that in the rest of the script. + +if exists('current_compiler') + finish +endif + +let current_compiler = 'coffee' +call coffee#CoffeeSetUpVariables() + +" Pattern to check if coffee is the compiler +let s:pat = '^' . current_compiler + +" Get a `makeprg` for the current filename. +function! s:GetMakePrg() + return g:coffee_compiler . + \ ' -c' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . g:coffee_make_options . + \ ' $*' . + \ ' ' . fnameescape(expand('%')) +endfunction + +" Set `makeprg` and return 1 if coffee is still the compiler, else return 0. +function! s:SetMakePrg() + if &l:makeprg =~ s:pat + let &l:makeprg = s:GetMakePrg() + elseif &g:makeprg =~ s:pat + let &g:makeprg = s:GetMakePrg() + else + return 0 + endif + + return 1 +endfunction + +" Set a dummy compiler so we can check whether to set locally or globally. +exec 'CompilerSet makeprg=' . current_compiler +" Then actually set the compiler. +call s:SetMakePrg() +call coffee#CoffeeSetUpErrorFormat() + +function! s:CoffeeMakeDeprecated(bang, args) + echoerr 'CoffeeMake is deprecated! Please use :make instead, its behavior ' . + \ 'is identical.' + sleep 5 + exec 'make' . a:bang a:args +endfunction + +" Compile the current file. +command! -bang -bar -nargs=* CoffeeMake +\ call s:CoffeeMakeDeprecated(, ) + +" Set `makeprg` on rename since we embed the filename in the setting. +augroup CoffeeUpdateMakePrg + autocmd! + + " Update `makeprg` if coffee is still the compiler, else stop running this + " function. + function! s:UpdateMakePrg() + if !s:SetMakePrg() + autocmd! CoffeeUpdateMakePrg + endif + endfunction + + " Set autocmd locally if compiler was set locally. + if &l:makeprg =~ s:pat + autocmd BufWritePre,BufFilePost call s:UpdateMakePrg() + else + autocmd BufWritePre,BufFilePost call s:UpdateMakePrg() + endif +augroup END diff --git a/sources_non_forked/vim-coffee-script/doc/coffee-script.txt b/sources_non_forked/vim-coffee-script/doc/coffee-script.txt new file mode 100644 index 00000000..1b43cf3a --- /dev/null +++ b/sources_non_forked/vim-coffee-script/doc/coffee-script.txt @@ -0,0 +1,4 @@ +Please see the project readme for up-to-date docs: +https://github.com/kchmck/vim-coffee-script + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim new file mode 100644 index 00000000..4e5285d1 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftdetect/coffee.vim @@ -0,0 +1,18 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +autocmd BufNewFile,BufRead *.coffee set filetype=coffee +autocmd BufNewFile,BufRead *Cakefile set filetype=coffee +autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee +autocmd BufNewFile,BufRead *._coffee set filetype=coffee +autocmd BufNewFile,BufRead *.cson set filetype=coffee + +function! s:DetectCoffee() + if getline(1) =~ '^#!.*\' + set filetype=coffee + endif +endfunction + +autocmd BufNewFile,BufRead * call s:DetectCoffee() diff --git a/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim b/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim new file mode 100644 index 00000000..7f666246 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftdetect/vim-literate-coffeescript.vim @@ -0,0 +1,8 @@ +" Language: Literate CoffeeScript +" Maintainer: Michael Smith +" URL: https://github.com/mintplant/vim-literate-coffeescript +" License: MIT + +autocmd BufNewFile,BufRead *.litcoffee set filetype=litcoffee +autocmd BufNewFile,BufRead *.coffee.md set filetype=litcoffee + diff --git a/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim b/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim new file mode 100644 index 00000000..3f9cd771 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftplugin/coffee.vim @@ -0,0 +1,405 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:did_ftplugin') + finish +endif + +let b:did_ftplugin = 1 +call coffee#CoffeeSetUpVariables() + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# commentstring=#\ %s +setlocal omnifunc=javascriptcomplete#CompleteJS +setlocal suffixesadd+=.coffee + +" Create custom augroups. +augroup CoffeeBufUpdate | augroup END +augroup CoffeeBufNew | augroup END + +" Enable coffee compiler if a compiler isn't set already. +if !len(&l:makeprg) + compiler coffee +endif + +" Switch to the window for buf. +function! s:SwitchWindow(buf) + exec bufwinnr(a:buf) 'wincmd w' +endfunction + +" Create a new scratch buffer and return the bufnr of it. After the function +" returns, vim remains in the scratch buffer so more set up can be done. +function! s:ScratchBufBuild(src, vert, size) + if a:size <= 0 + if a:vert + let size = winwidth(bufwinnr(a:src)) / 2 + else + let size = winheight(bufwinnr(a:src)) / 2 + endif + endif + + if a:vert + vertical belowright new + exec 'vertical resize' size + else + belowright new + exec 'resize' size + endif + + setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile nomodifiable + nnoremap q :hide + + return bufnr('%') +endfunction + +" Replace buffer contents with text and delete the last empty line. +function! s:ScratchBufUpdate(buf, text) + " Move to the scratch buffer. + call s:SwitchWindow(a:buf) + + " Double check we're in the scratch buffer before overwriting. + if bufnr('%') != a:buf + throw 'unable to change to scratch buffer' + endif + + setlocal modifiable + silent exec '% delete _' + silent put! =a:text + silent exec '$ delete _' + setlocal nomodifiable +endfunction + +" Parse the output of coffee into a qflist entry for src buffer. +function! s:ParseCoffeeError(output, src, startline) + " Coffee error is always on first line? + let match = matchlist(a:output, + \ '^\(\f\+\|\[stdin\]\):\(\d\):\(\d\): error: \(.\{-}\)' . "\n") + + if !len(match) + return + endif + + " Consider the line number from coffee as relative and add it to the beginning + " line number of the range the command was called on, then subtract one for + " zero-based relativity. + call setqflist([{'bufnr': a:src, 'lnum': a:startline + str2nr(match[2]) - 1, + \ 'type': 'E', 'col': str2nr(match[3]), 'text': match[4]}], 'r') +endfunction + +" Reset source buffer variables. +function! s:CoffeeCompileResetVars() + " Variables defined in source buffer: + " b:coffee_compile_buf: bufnr of output buffer + " Variables defined in output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_compile_pos: previous cursor position in output buffer + + let b:coffee_compile_buf = -1 +endfunction + +function! s:CoffeeWatchResetVars() + " Variables defined in source buffer: + " b:coffee_watch_buf: bufnr of output buffer + " Variables defined in output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_watch_pos: previous cursor position in output buffer + + let b:coffee_watch_buf = -1 +endfunction + +function! s:CoffeeRunResetVars() + " Variables defined in CoffeeRun source buffer: + " b:coffee_run_buf: bufnr of output buffer + " Variables defined in CoffeeRun output buffer: + " b:coffee_src_buf: bufnr of source buffer + " b:coffee_run_pos: previous cursor position in output buffer + + let b:coffee_run_buf = -1 +endfunction + +" Clean things up in the source buffers. +function! s:CoffeeCompileClose() + " Switch to the source buffer if not already in it. + silent! call s:SwitchWindow(b:coffee_src_buf) + call s:CoffeeCompileResetVars() +endfunction + +function! s:CoffeeWatchClose() + silent! call s:SwitchWindow(b:coffee_src_buf) + silent! autocmd! CoffeeAuWatch * + call s:CoffeeWatchResetVars() +endfunction + +function! s:CoffeeRunClose() + silent! call s:SwitchWindow(b:coffee_src_buf) + call s:CoffeeRunResetVars() +endfunction + +" Compile the lines between startline and endline and put the result into buf. +function! s:CoffeeCompileToBuf(buf, startline, endline) + let src = bufnr('%') + let input = join(getline(a:startline, a:endline), "\n") + + " Coffee doesn't like empty input. + if !len(input) + " Function should still return within output buffer. + call s:SwitchWindow(a:buf) + return + endif + + " Pipe lines into coffee. + let output = system(g:coffee_compiler . + \ ' -scb' . + \ ' ' . b:coffee_litcoffee . + \ ' 2>&1', input) + + " Paste output into output buffer. + call s:ScratchBufUpdate(a:buf, output) + + " Highlight as JavaScript if there were no compile errors. + if v:shell_error + call s:ParseCoffeeError(output, src, a:startline) + setlocal filetype= + else + " Clear the quickfix list. + call setqflist([], 'r') + setlocal filetype=javascript + endif +endfunction + +" Peek at compiled CoffeeScript in a scratch buffer. We handle ranges like this +" to prevent the cursor from being moved (and its position saved) before the +" function is called. +function! s:CoffeeCompile(startline, endline, args) + if a:args =~ '\' + echoerr 'CoffeeCompile watch is deprecated! Please use CoffeeWatch instead' + sleep 5 + call s:CoffeeWatch(a:args) + return + endif + + " Switch to the source buffer if not already in it. + silent! call s:SwitchWindow(b:coffee_src_buf) + + " Bail if not in source buffer. + if !exists('b:coffee_compile_buf') + return + endif + + " Build the output buffer if it doesn't exist. + if bufwinnr(b:coffee_compile_buf) == -1 + let src = bufnr('%') + + let vert = exists('g:coffee_compile_vert') || a:args =~ '\' + let size = str2nr(matchstr(a:args, '\<\d\+\>')) + + " Build the output buffer and save the source bufnr. + let buf = s:ScratchBufBuild(src, vert, size) + let b:coffee_src_buf = src + + " Set the buffer name. + exec 'silent! file [CoffeeCompile ' . src . ']' + + " Clean up the source buffer when the output buffer is closed. + autocmd BufWipeout call s:CoffeeCompileClose() + " Save the cursor when leaving the output buffer. + autocmd BufLeave let b:coffee_compile_pos = getpos('.') + + " Run user-defined commands on new buffer. + silent doautocmd CoffeeBufNew User CoffeeCompile + + " Switch back to the source buffer and save the output bufnr. This also + " triggers BufLeave above. + call s:SwitchWindow(src) + let b:coffee_compile_buf = buf + endif + + " Fill the scratch buffer. + call s:CoffeeCompileToBuf(b:coffee_compile_buf, a:startline, a:endline) + " Reset cursor to previous position. + call setpos('.', b:coffee_compile_pos) + + " Run any user-defined commands on the scratch buffer. + silent doautocmd CoffeeBufUpdate User CoffeeCompile +endfunction + +" Update the scratch buffer and switch back to the source buffer. +function! s:CoffeeWatchUpdate() + call s:CoffeeCompileToBuf(b:coffee_watch_buf, 1, '$') + call setpos('.', b:coffee_watch_pos) + silent doautocmd CoffeeBufUpdate User CoffeeWatch + call s:SwitchWindow(b:coffee_src_buf) +endfunction + +" Continually compile a source buffer. +function! s:CoffeeWatch(args) + silent! call s:SwitchWindow(b:coffee_src_buf) + + if !exists('b:coffee_watch_buf') + return + endif + + if bufwinnr(b:coffee_watch_buf) == -1 + let src = bufnr('%') + + let vert = exists('g:coffee_watch_vert') || a:args =~ '\' + let size = str2nr(matchstr(a:args, '\<\d\+\>')) + + let buf = s:ScratchBufBuild(src, vert, size) + let b:coffee_src_buf = src + + exec 'silent! file [CoffeeWatch ' . src . ']' + + autocmd BufWipeout call s:CoffeeWatchClose() + autocmd BufLeave let b:coffee_watch_pos = getpos('.') + + silent doautocmd CoffeeBufNew User CoffeeWatch + + call s:SwitchWindow(src) + let b:coffee_watch_buf = buf + endif + + " Make sure only one watch autocmd is defined on this buffer. + silent! autocmd! CoffeeAuWatch * + + augroup CoffeeAuWatch + autocmd InsertLeave call s:CoffeeWatchUpdate() + autocmd BufWritePost call s:CoffeeWatchUpdate() + augroup END + + call s:CoffeeWatchUpdate() +endfunction + +" Run a snippet of CoffeeScript between startline and endline. +function! s:CoffeeRun(startline, endline, args) + silent! call s:SwitchWindow(b:coffee_src_buf) + + if !exists('b:coffee_run_buf') + return + endif + + if bufwinnr(b:coffee_run_buf) == -1 + let src = bufnr('%') + + let buf = s:ScratchBufBuild(src, exists('g:coffee_run_vert'), 0) + let b:coffee_src_buf = src + + exec 'silent! file [CoffeeRun ' . src . ']' + + autocmd BufWipeout call s:CoffeeRunClose() + autocmd BufLeave let b:coffee_run_pos = getpos('.') + + silent doautocmd CoffeeBufNew User CoffeeRun + + call s:SwitchWindow(src) + let b:coffee_run_buf = buf + endif + + if a:startline == 1 && a:endline == line('$') + let output = system(g:coffee_compiler . + \ ' ' . b:coffee_litcoffee . + \ ' ' . fnameescape(expand('%')) . + \ ' ' . a:args) + else + let input = join(getline(a:startline, a:endline), "\n") + + if !len(input) + return + endif + + let output = system(g:coffee_compiler . + \ ' -s' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . a:args, input) + endif + + call s:ScratchBufUpdate(b:coffee_run_buf, output) + call setpos('.', b:coffee_run_pos) + + silent doautocmd CoffeeBufUpdate User CoffeeRun +endfunction + +" Run coffeelint on a file, and add any errors between startline and endline +" to the quickfix list. +function! s:CoffeeLint(startline, endline, bang, args) + let input = join(getline(a:startline, a:endline), "\n") + + if !len(input) + return + endif + + let output = system(g:coffee_linter . + \ ' -s --reporter csv' . + \ ' ' . b:coffee_litcoffee . + \ ' ' . g:coffee_lint_options . + \ ' ' . a:args . + \ ' 2>&1', input) + + " Convert output into an array and strip off the csv header. + let lines = split(output, "\n")[1:] + let buf = bufnr('%') + let qflist = [] + + for line in lines + let match = matchlist(line, '^stdin,\(\d\+\),\d*,\(error\|warn\),\(.\+\)$') + + " Ignore unmatched lines. + if !len(match) + continue + endif + + " The 'type' will result in either 'E' or 'W'. + call add(qflist, {'bufnr': buf, 'lnum': a:startline + str2nr(match[1]) - 1, + \ 'type': toupper(match[2][0]), 'text': match[3]}) + endfor + + " Replace the quicklist with our items. + call setqflist(qflist, 'r') + + " If not given a bang, jump to first error. + if !len(a:bang) + silent! cc 1 + endif +endfunction + +" Complete arguments for Coffee* commands. +function! s:CoffeeComplete(cmd, cmdline, cursor) + let args = ['vertical'] + + " If no partial command, return all possibilities. + if !len(a:cmd) + return args + endif + + let pat = '^' . a:cmd + + for arg in args + if arg =~ pat + return [arg] + endif + endfor +endfunction + +" Set initial state variables if they don't exist +if !exists('b:coffee_compile_buf') + call s:CoffeeCompileResetVars() +endif + +if !exists('b:coffee_watch_buf') + call s:CoffeeWatchResetVars() +endif + +if !exists('b:coffee_run_buf') + call s:CoffeeRunResetVars() +endif + +command! -buffer -range=% -bar -nargs=* -complete=customlist,s:CoffeeComplete +\ CoffeeCompile call s:CoffeeCompile(, , ) +command! -buffer -bar -nargs=* -complete=customlist,s:CoffeeComplete +\ CoffeeWatch call s:CoffeeWatch() +command! -buffer -range=% -bar -nargs=* CoffeeRun +\ call s:CoffeeRun(, , ) +command! -buffer -range=% -bang -bar -nargs=* CoffeeLint +\ call s:CoffeeLint(, , , ) diff --git a/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim b/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim new file mode 100644 index 00000000..febc730c --- /dev/null +++ b/sources_non_forked/vim-coffee-script/ftplugin/litcoffee.vim @@ -0,0 +1 @@ +runtime ftplugin/coffee.vim diff --git a/sources_non_forked/vim-coffee-script/indent/coffee.vim b/sources_non_forked/vim-coffee-script/indent/coffee.vim new file mode 100644 index 00000000..4f4570a8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/indent/coffee.vim @@ -0,0 +1,428 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +if exists('b:did_indent') + finish +endif + +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetCoffeeIndent(v:lnum) +" Make sure GetCoffeeIndent is run when these are typed so they can be +" indented or outdented. +setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally + +" If no indenting or outdenting is needed, either keep the indent of the cursor +" (use autoindent) or match the indent of the previous line. +if exists('g:coffee_indent_keep_current') + let s:DEFAULT_LEVEL = '-1' +else + let s:DEFAULT_LEVEL = 'indent(prevnlnum)' +endif + +" Only define the function once. +if exists('*GetCoffeeIndent') + finish +endif + +" Keywords that begin a block +let s:BEGIN_BLOCK_KEYWORD = '\C^\%(if\|unless\|else\|for\|while\|until\|' +\ . 'loop\|switch\|when\|try\|catch\|finally\|' +\ . 'class\)\>\%(\s*:\)\@!' + +" An expression that uses the result of a statement +let s:COMPOUND_EXPRESSION = '\C\%([^-]-\|[^+]+\|[^/]/\|[:=*%&|^<>]\)\s*' +\ . '\%(if\|unless\|for\|while\|until\|loop\|switch\|' +\ . 'try\|class\)\>' + +" Combine the two above +let s:BEGIN_BLOCK = s:BEGIN_BLOCK_KEYWORD . '\|' . s:COMPOUND_EXPRESSION + +" Operators that begin a block but also count as a continuation +let s:BEGIN_BLOCK_OP = '[([{:=]$' + +" Begins a function block +let s:FUNCTION = '[-=]>$' + +" Operators that continue a line onto the next line +let s:CONTINUATION_OP = '\C\%(\<\%(is\|isnt\|and\|or\)\>\|' +\ . '[^-]-\|[^+]+\|[^-=]>\|[^.]\.\|[<*/%&|^,]\)$' + +" Ancestor operators that prevent continuation indenting +let s:CONTINUATION = s:CONTINUATION_OP . '\|' . s:BEGIN_BLOCK_OP + +" A closing bracket by itself on a line followed by a continuation +let s:BRACKET_CONTINUATION = '^\s*[}\])]\s*' . s:CONTINUATION_OP + +" A continuation dot access +let s:DOT_ACCESS = '^\.' + +" Keywords that break out of a block +let s:BREAK_BLOCK_OP = '\C^\%(return\|break\|continue\|throw\)\>' + +" A condition attached to the end of a statement +let s:POSTFIX_CONDITION = '\C\S\s\+\zs\<\%(if\|unless\|when\|while\|until\)\>' + +" A then contained in brackets +let s:CONTAINED_THEN = '\C[(\[].\{-}\.\{-\}[)\]]' + +" An else with a condition attached +let s:ELSE_COND = '\C^\s*else\s\+\<\%(if\|unless\)\>' + +" A single-line else statement (without a condition attached) +let s:SINGLE_LINE_ELSE = '\C^else\s\+\%(\<\%(if\|unless\)\>\)\@!' + +" Pairs of starting and ending keywords, with an initial pattern to match +let s:KEYWORD_PAIRS = [ +\ ['\C^else\>', '\C\<\%(if\|unless\|when\|else\s\+\%(if\|unless\)\)\>', +\ '\C\'], +\ ['\C^catch\>', '\C\', '\C\'], +\ ['\C^finally\>', '\C\', '\C\'] +\] + +" Pairs of starting and ending brackets +let s:BRACKET_PAIRS = {']': '\[', '}': '{', ')': '('} + +" Max lines to look back for a match +let s:MAX_LOOKBACK = 50 + +" Syntax names for strings +let s:SYNTAX_STRING = 'coffee\%(String\|AssignString\|Embed\|Regex\|Heregex\|' +\ . 'Heredoc\)' + +" Syntax names for comments +let s:SYNTAX_COMMENT = 'coffee\%(Comment\|BlockComment\|HeregexComment\)' + +" Syntax names for strings and comments +let s:SYNTAX_STRING_COMMENT = s:SYNTAX_STRING . '\|' . s:SYNTAX_COMMENT + +" Compatibility code for shiftwidth() as recommended by the docs, but modified +" so there isn't as much of a penalty if shiftwidth() exists. +if exists('*shiftwidth') + let s:ShiftWidth = function('shiftwidth') +else + function! s:ShiftWidth() + return &shiftwidth + endfunction +endif + +" Get the linked syntax name of a character. +function! s:SyntaxName(lnum, col) + return synIDattr(synID(a:lnum, a:col, 1), 'name') +endfunction + +" Check if a character is in a comment. +function! s:IsComment(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_COMMENT +endfunction + +" Check if a character is in a string. +function! s:IsString(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING +endfunction + +" Check if a character is in a comment or string. +function! s:IsCommentOrString(lnum, col) + return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING_COMMENT +endfunction + +" Search a line for a regex until one is found outside a string or comment. +function! s:SearchCode(lnum, regex) + " Start at the first column and look for an initial match (including at the + " cursor.) + call cursor(a:lnum, 1) + let pos = search(a:regex, 'c', a:lnum) + + while pos + if !s:IsCommentOrString(a:lnum, col('.')) + return 1 + endif + + " Move to the match and continue searching (don't accept matches at the + " cursor.) + let pos = search(a:regex, '', a:lnum) + endwhile + + return 0 +endfunction + +" Search for the nearest previous line that isn't a comment. +function! s:GetPrevNormalLine(startlnum) + let curlnum = a:startlnum + + while curlnum + let curlnum = prevnonblank(curlnum - 1) + + " Return the line if the first non-whitespace character isn't a comment. + if !s:IsComment(curlnum, indent(curlnum) + 1) + return curlnum + endif + endwhile + + return 0 +endfunction + +function! s:SearchPair(startlnum, lookback, skip, open, close) + " Go to the first column so a:close will be matched even if it's at the + " beginning of the line. + call cursor(a:startlnum, 1) + return searchpair(a:open, '', a:close, 'bnW', a:skip, max([1, a:lookback])) +endfunction + +" Skip if a match +" - is in a string or comment +" - is a single-line statement that isn't immediately +" adjacent +" - has a postfix condition and isn't an else statement or compound +" expression +function! s:ShouldSkip(startlnum, lnum, col) + return s:IsCommentOrString(a:lnum, a:col) || + \ s:SearchCode(a:lnum, '\C\') && a:startlnum - a:lnum > 1 || + \ s:SearchCode(a:lnum, s:POSTFIX_CONDITION) && + \ getline(a:lnum) !~ s:ELSE_COND && + \ !s:SearchCode(a:lnum, s:COMPOUND_EXPRESSION) +endfunction + +" Search for the nearest and farthest match for a keyword pair. +function! s:SearchMatchingKeyword(startlnum, open, close) + let skip = 's:ShouldSkip(' . a:startlnum . ", line('.'), line('.'))" + + " Search for the nearest match. + let nearestlnum = s:SearchPair(a:startlnum, a:startlnum - s:MAX_LOOKBACK, + \ skip, a:open, a:close) + + if !nearestlnum + return [] + endif + + " Find the nearest previous line with indent less than or equal to startlnum. + let ind = indent(a:startlnum) + let lookback = s:GetPrevNormalLine(a:startlnum) + + while lookback && indent(lookback) > ind + let lookback = s:GetPrevNormalLine(lookback) + endwhile + + " Search for the farthest match. If there are no other matches, then the + " nearest match is also the farthest one. + let matchlnum = nearestlnum + + while matchlnum + let lnum = matchlnum + let matchlnum = s:SearchPair(matchlnum, lookback, skip, a:open, a:close) + endwhile + + return [nearestlnum, lnum] +endfunction + +" Strip a line of a trailing comment and surrounding whitespace. +function! s:GetTrimmedLine(lnum) + " Try to find a comment starting at the first column. + call cursor(a:lnum, 1) + let pos = search('#', 'c', a:lnum) + + " Keep searching until a comment is found or search returns 0. + while pos + if s:IsComment(a:lnum, col('.')) + break + endif + + let pos = search('#', '', a:lnum) + endwhile + + if !pos + " No comment was found so use the whole line. + let line = getline(a:lnum) + else + " Subtract 1 to get to the column before the comment and another 1 for + " column indexing -> zero-based indexing. + let line = getline(a:lnum)[:col('.') - 2] + endif + + return substitute(substitute(line, '^\s\+', '', ''), + \ '\s\+$', '', '') +endfunction + +" Get the indent policy when no special rules are used. +function! s:GetDefaultPolicy(curlnum) + " Check whether equalprg is being ran on existing lines. + if strlen(getline(a:curlnum)) == indent(a:curlnum) + " If not indenting an existing line, use the default policy. + return s:DEFAULT_LEVEL + else + " Otherwise let autoindent determine what to do with an existing line. + return '-1' + endif +endfunction + +function! GetCoffeeIndent(curlnum) + " Get the previous non-blank line (may be a comment.) + let prevlnum = prevnonblank(a:curlnum - 1) + + " Bail if there's no code before. + if !prevlnum + return -1 + endif + + " Bail if inside a multiline string. + if s:IsString(a:curlnum, 1) + let prevnlnum = prevlnum + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Get the code part of the current line. + let curline = s:GetTrimmedLine(a:curlnum) + " Get the previous non-comment line. + let prevnlnum = s:GetPrevNormalLine(a:curlnum) + + " Check if the current line is the closing bracket in a bracket pair. + if has_key(s:BRACKET_PAIRS, curline[0]) + " Search for a matching opening bracket. + let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, + \ "s:IsCommentOrString(line('.'), col('.'))", + \ s:BRACKET_PAIRS[curline[0]], curline[0]) + + if matchlnum + " Match the indent of the opening bracket. + return indent(matchlnum) + else + " No opening bracket found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Check if the current line is the closing keyword in a keyword pair. + for pair in s:KEYWORD_PAIRS + if curline =~ pair[0] + " Find the nearest and farthest matches within the same indent level. + let matches = s:SearchMatchingKeyword(a:curlnum, pair[1], pair[2]) + + if len(matches) + " Don't force indenting/outdenting as long as line is already lined up + " with a valid match + return max([min([indent(a:curlnum), indent(matches[0])]), + \ indent(matches[1])]) + else + " No starting keyword found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + endfor + + " Check if the current line is a `when` and not the first in a switch block. + if curline =~ '\C^when\>' && !s:SearchCode(prevnlnum, '\C\') + " Look back for a `when`. + while prevnlnum + if getline(prevnlnum) =~ '\C^\s*when\>' + " Indent to match the found `when`, but don't force indenting (for when + " indenting nested switch blocks.) + return min([indent(a:curlnum), indent(prevnlnum)]) + endif + + let prevnlnum = s:GetPrevNormalLine(prevnlnum) + endwhile + + " No matching `when` found (bad syntax), so bail. + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " If the previous line is a comment, use its indentation, but don't force + " indenting. + if prevlnum != prevnlnum + return min([indent(a:curlnum), indent(prevlnum)]) + endif + + let prevline = s:GetTrimmedLine(prevnlnum) + + " Always indent after these operators. + if prevline =~ s:BEGIN_BLOCK_OP + return indent(prevnlnum) + s:ShiftWidth() + endif + + " Indent if the previous line starts a function block, but don't force + " indenting if the line is non-blank (for empty function bodies.) + if prevline =~ s:FUNCTION + if strlen(getline(a:curlnum)) > indent(a:curlnum) + return min([indent(prevnlnum) + s:ShiftWidth(), indent(a:curlnum)]) + else + return indent(prevnlnum) + s:ShiftWidth() + endif + endif + + " Check if continuation indenting is needed. If the line ends in a slash, make + " sure it isn't a regex. + if prevline =~ s:CONTINUATION_OP && + \ !(prevline =~ '/$' && s:IsString(prevnlnum, col([prevnlnum, '$']) - 1)) + " Don't indent if the continuation follows a closing bracket. + if prevline =~ s:BRACKET_CONTINUATION + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + let prevprevnlnum = s:GetPrevNormalLine(prevnlnum) + + " Don't indent if not the first continuation. + if prevprevnlnum && s:GetTrimmedLine(prevprevnlnum) =~ s:CONTINUATION + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Continuation indenting seems to vary between programmers, so if the line + " is non-blank, don't override the indentation + if strlen(getline(a:curlnum)) > indent(a:curlnum) + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + + " Otherwise indent a level. + return indent(prevnlnum) + s:ShiftWidth() + endif + + " Check if the previous line starts with a keyword that begins a block. + if prevline =~ s:BEGIN_BLOCK + " Indent if the current line doesn't start with `then` and the previous line + " isn't a single-line statement. + if curline !~ '\C^\' && !s:SearchCode(prevnlnum, '\C\') && + \ prevline !~ s:SINGLE_LINE_ELSE + return indent(prevnlnum) + s:ShiftWidth() + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Indent a dot access if it's the first. + if curline =~ s:DOT_ACCESS + if prevline !~ s:DOT_ACCESS + return indent(prevnlnum) + s:ShiftWidth() + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Outdent if a keyword breaks out of a block as long as it doesn't have a + " postfix condition (and the postfix condition isn't a single-line statement.) + if prevline =~ s:BREAK_BLOCK_OP + if !s:SearchCode(prevnlnum, s:POSTFIX_CONDITION) || + \ s:SearchCode(prevnlnum, '\C\') && + \ !s:SearchCode(prevnlnum, s:CONTAINED_THEN) + " Don't force indenting. + return min([indent(a:curlnum), indent(prevnlnum) - s:ShiftWidth()]) + else + exec 'return' s:GetDefaultPolicy(a:curlnum) + endif + endif + + " Check if inside brackets. + let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, + \ "s:IsCommentOrString(line('.'), col('.'))", + \ '\[\|(\|{', '\]\|)\|}') + + " If inside brackets, indent relative to the brackets, but don't outdent an + " already indented line. + if matchlnum + return max([indent(a:curlnum), indent(matchlnum) + s:ShiftWidth()]) + endif + + " No special rules applied, so use the default policy. + exec 'return' s:GetDefaultPolicy(a:curlnum) +endfunction diff --git a/sources_non_forked/vim-coffee-script/indent/litcoffee.vim b/sources_non_forked/vim-coffee-script/indent/litcoffee.vim new file mode 100644 index 00000000..599cbea8 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/indent/litcoffee.vim @@ -0,0 +1,22 @@ +if exists('b:did_indent') + finish +endif + +runtime! indent/coffee.vim + +let b:did_indent = 1 + +setlocal indentexpr=GetLitCoffeeIndent() + +if exists('*GetLitCoffeeIndent') + finish +endif + +function GetLitCoffeeIndent() + if searchpair('^ \|\t', '', '$', 'bWnm') > 0 + return GetCoffeeIndent(v:lnum) + else + return -1 + endif +endfunc + diff --git a/sources_non_forked/vim-coffee-script/syntax/coffee.vim b/sources_non_forked/vim-coffee-script/syntax/coffee.vim new file mode 100644 index 00000000..bd8de587 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/syntax/coffee.vim @@ -0,0 +1,221 @@ +" Language: CoffeeScript +" Maintainer: Mick Koch +" URL: http://github.com/kchmck/vim-coffee-script +" License: WTFPL + +" Bail if our syntax is already loaded. +if exists('b:current_syntax') && b:current_syntax == 'coffee' + finish +endif + +" Include JavaScript for coffeeEmbed. +syn include @coffeeJS syntax/javascript.vim +silent! unlet b:current_syntax + +" Highlight long strings. +syntax sync fromstart + +" These are `matches` instead of `keywords` because vim's highlighting +" priority for keywords is higher than matches. This causes keywords to be +" highlighted inside matches, even if a match says it shouldn't contain them -- +" like with coffeeAssign and coffeeDot. +syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display +hi def link coffeeStatement Statement + +syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display +hi def link coffeeRepeat Repeat + +syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/ +\ display +hi def link coffeeConditional Conditional + +syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display +hi def link coffeeException Exception + +syn match coffeeKeyword /\<\%(new\|in\|of\|from\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|default\|await\)\>/ +\ display +" The `own` keyword is only a keyword after `for`. +syn match coffeeKeyword /\/ contained containedin=coffeeRepeat +\ display +hi def link coffeeKeyword Keyword + +syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display +hi def link coffeeOperator Operator + +" The first case matches symbol operators only if they have an operand before. +syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/ +\ display +syn match coffeeExtendedOp /\<\%(and\|or\)=/ display +hi def link coffeeExtendedOp coffeeOperator + +" This is separate from `coffeeExtendedOp` to help differentiate commas from +" dots. +syn match coffeeSpecialOp /[,;]/ display +hi def link coffeeSpecialOp SpecialChar + +syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display +hi def link coffeeBoolean Boolean + +syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display +hi def link coffeeGlobal Type + +" A special variable +syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display +hi def link coffeeSpecialVar Special + +" An @-variable +syn match coffeeSpecialIdent /@\%(\%(\I\|\$\)\%(\i\|\$\)*\)\?/ display +hi def link coffeeSpecialIdent Identifier + +" A class-like name that starts with a capital letter +syn match coffeeObject /\<\u\w*\>/ display +hi def link coffeeObject Structure + +" A constant-like name in SCREAMING_CAPS +syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display +hi def link coffeeConstant Constant + +" A variable name +syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeSpecialIdent, +\ coffeeObject,coffeeConstant + +" A non-interpolated string +syn cluster coffeeBasicString contains=@Spell,coffeeEscape +" An interpolated string +syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp + +" Regular strings +syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ +\ contains=@coffeeInterpString +syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ +\ contains=@coffeeBasicString +hi def link coffeeString String + +" A integer, including a leading plus or minus +syn match coffeeNumber /\%(\i\|\$\)\@/ display +syn match coffeeNumber /\<0[bB][01]\+\>/ display +syn match coffeeNumber /\<0[oO][0-7]\+\>/ display +syn match coffeeNumber /\<\%(Infinity\|NaN\)\>/ display +hi def link coffeeNumber Number + +" A floating-point number, including a leading plus or minus +syn match coffeeFloat /\%(\i\|\$\)\@/ +\ display +hi def link coffeeReservedError Error + +" A normal object assignment +syn match coffeeObjAssign /@\?\%(\I\|\$\)\%(\i\|\$\)*\s*\ze::\@!/ contains=@coffeeIdentifier display +hi def link coffeeObjAssign Identifier + +syn keyword coffeeTodo TODO FIXME XXX contained +hi def link coffeeTodo Todo + +syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo +hi def link coffeeComment Comment + +syn region coffeeBlockComment start=/####\@!/ end=/###/ +\ contains=@Spell,coffeeTodo +hi def link coffeeBlockComment coffeeComment + +" A comment in a heregex +syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained +\ contains=@Spell,coffeeTodo +hi def link coffeeHeregexComment coffeeComment + +" Embedded JavaScript +syn region coffeeEmbed matchgroup=coffeeEmbedDelim +\ start=/`/ skip=/\\\\\|\\`/ end=/`/ keepend +\ contains=@coffeeJS +hi def link coffeeEmbedDelim Delimiter + +syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained +\ contains=@coffeeAll +hi def link coffeeInterpDelim PreProc + +" A string escape sequence +syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display +hi def link coffeeEscape SpecialChar + +" A regex -- must not follow a parenthesis, number, or identifier, and must not +" be followed by a number +syn region coffeeRegex start=#\%(\%()\|\%(\i\|\$\)\@ +" URL: https://github.com/mintplant/vim-literate-coffeescript +" License: MIT + +if exists('b:current_syntax') && b:current_syntax == 'litcoffee' + finish +endif + +syn include @markdown syntax/markdown.vim +syn include @coffee syntax/coffee.vim + +" Partition the file into notCoffee and inlineCoffee. Each line will match +" exactly one of these regions. notCoffee matches with a zero-width +" look-behind. +syn region notCoffee start='^\%( \|\t\)\@> #{ == { { { } } } == } << " +" >> #{ == { abc: { def: 42 } } == } << " diff --git a/sources_non_forked/vim-coffee-script/test/test-ops.coffee b/sources_non_forked/vim-coffee-script/test/test-ops.coffee new file mode 100644 index 00000000..54be8dba --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test-ops.coffee @@ -0,0 +1,90 @@ +# Various operators +abc instanceof def +typeof abc +delete abc +abc::def + +abc + def +abc - def +abc * def +abc / def +abc % def +abc & def +abc | def +abc ^ def +abc >> def +abc << def +abc >>> def +abc ? def +abc && def +abc and def +abc || def +abc or def + +abc += def +abc -= def +abc *= def +abc /= def +abc %= def +abc &= def +abc |= def +abc ^= def +abc >>= def +abc <<= def +abc >>>= def +abc ?= def +abc &&= def +abc ||= def + +abc and= def +abc or= def + +abc.def.ghi +abc?.def?.ghi + +abc < def +abc > def +abc = def +abc == def +abc != def +abc <= def +abc >= def + +abc++ +abc-- +++abc +--abc + +# Nested operators +abc[def] = ghi +abc[def[ghi: jkl]] = 42 +@abc[def] = ghi + +abc["#{def = 42}"] = 42 +abc["#{def.ghi = 42}"] = 42 +abc["#{def[ghi] = 42}"] = 42 +abc["#{def['ghi']}"] = 42 + +# Object assignments +abc = + def: 123 + DEF: 123 + @def: 123 + Def: 123 + 'def': 123 + 42: 123 + +# Operators shouldn't be highlighted +vector= +wand= + +abc+++ +abc--- +abc ** def +abc &&& def +abc ^^ def +abc ===== def +abc <==== def +abc >==== def +abc +== def +abc =^= def diff --git a/sources_non_forked/vim-coffee-script/test/test-reserved.coffee b/sources_non_forked/vim-coffee-script/test/test-reserved.coffee new file mode 100644 index 00000000..b841760c --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test-reserved.coffee @@ -0,0 +1,27 @@ +# Should be an error +function = 42 +var = 42 + +# Shouldn't be an error +abc.with = 42 +function: 42 +var: 42 + +# Keywords shouldn't be highlighted +abc.function +abc.do +abc.break +abc.true + +abc::function +abc::do +abc::break +abc::true + +abc:: function +abc. function + +# Numbers should be highlighted +def.42 +def .42 +def::42 diff --git a/sources_non_forked/vim-coffee-script/test/test.coffee.md b/sources_non_forked/vim-coffee-script/test/test.coffee.md new file mode 100644 index 00000000..62b99b7d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.coffee.md @@ -0,0 +1,117 @@ +The **Scope** class regulates lexical scoping within CoffeeScript. As you +generate code, you create a tree of scopes in the same shape as the nested +function bodies. Each scope knows about the variables declared within it, +and has a reference to its parent enclosing scope. In this way, we know which +variables are new and need to be declared with `var`, and which are shared +with external scopes. + +Import the helpers we plan to use. + + {extend, last} = require './helpers' + + exports.Scope = class Scope + +The `root` is the top-level **Scope** object for a given file. + + @root: null + +Initialize a scope with its parent, for lookups up the chain, +as well as a reference to the **Block** node it belongs to, which is +where it should declare its variables, and a reference to the function that +it belongs to. + + constructor: (@parent, @expressions, @method) -> + @variables = [{name: 'arguments', type: 'arguments'}] + @positions = {} + Scope.root = this unless @parent + +Adds a new variable or overrides an existing one. + + add: (name, type, immediate) -> + return @parent.add name, type, immediate if @shared and not immediate + if Object::hasOwnProperty.call @positions, name + @variables[@positions[name]].type = type + else + @positions[name] = @variables.push({name, type}) - 1 + +When `super` is called, we need to find the name of the current method we're +in, so that we know how to invoke the same method of the parent class. This +can get complicated if super is being called from an inner function. +`namedMethod` will walk up the scope tree until it either finds the first +function object that has a name filled in, or bottoms out. + + namedMethod: -> + return @method if @method.name or !@parent + @parent.namedMethod() + +Look up a variable name in lexical scope, and declare it if it does not +already exist. + + find: (name) -> + return yes if @check name + @add name, 'var' + no + +Reserve a variable name as originating from a function parameter for this +scope. No `var` required for internal references. + + parameter: (name) -> + return if @shared and @parent.check name, yes + @add name, 'param' + +Just check to see if a variable has already been declared, without reserving, +walks up to the root scope. + + check: (name) -> + !!(@type(name) or @parent?.check(name)) + +Generate a temporary variable name at the given index. + + temporary: (name, index) -> + if name.length > 1 + '_' + name + if index > 1 then index - 1 else '' + else + '_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a' + +Gets the type of a variable. + + type: (name) -> + return v.type for v in @variables when v.name is name + null + +If we need to store an intermediate result, find an available name for a +compiler-generated variable. `_var`, `_var2`, and so on... + + freeVariable: (name, reserve=true) -> + index = 0 + index++ while @check((temp = @temporary name, index)) + @add temp, 'var', yes if reserve + temp + +Ensure that an assignment is made at the top of this scope +(or at the top-level scope, if requested). + + assign: (name, value) -> + @add name, {value, assigned: yes}, yes + @hasAssignments = yes + +Does this scope have any declared variables? + + hasDeclarations: -> + !!@declaredVariables().length + +Return the list of variables first declared in this scope. + + declaredVariables: -> + realVars = [] + tempVars = [] + for v in @variables when v.type is 'var' + (if v.name.charAt(0) is '_' then tempVars else realVars).push v.name + realVars.sort().concat tempVars.sort() + +Return the list of assignments that are supposed to be made at the top +of this scope. + + assignedVariables: -> + "#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned + diff --git a/sources_non_forked/vim-coffee-script/test/test.haml b/sources_non_forked/vim-coffee-script/test/test.haml new file mode 100644 index 00000000..ae19fba5 --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.haml @@ -0,0 +1,3 @@ +:coffeescript + class Hello + # test diff --git a/sources_non_forked/vim-coffee-script/test/test.html b/sources_non_forked/vim-coffee-script/test/test.html new file mode 100644 index 00000000..0da7b62d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.html @@ -0,0 +1,17 @@ + + + + + diff --git a/sources_non_forked/vim-coffee-script/test/test.litcoffee b/sources_non_forked/vim-coffee-script/test/test.litcoffee new file mode 100644 index 00000000..62b99b7d --- /dev/null +++ b/sources_non_forked/vim-coffee-script/test/test.litcoffee @@ -0,0 +1,117 @@ +The **Scope** class regulates lexical scoping within CoffeeScript. As you +generate code, you create a tree of scopes in the same shape as the nested +function bodies. Each scope knows about the variables declared within it, +and has a reference to its parent enclosing scope. In this way, we know which +variables are new and need to be declared with `var`, and which are shared +with external scopes. + +Import the helpers we plan to use. + + {extend, last} = require './helpers' + + exports.Scope = class Scope + +The `root` is the top-level **Scope** object for a given file. + + @root: null + +Initialize a scope with its parent, for lookups up the chain, +as well as a reference to the **Block** node it belongs to, which is +where it should declare its variables, and a reference to the function that +it belongs to. + + constructor: (@parent, @expressions, @method) -> + @variables = [{name: 'arguments', type: 'arguments'}] + @positions = {} + Scope.root = this unless @parent + +Adds a new variable or overrides an existing one. + + add: (name, type, immediate) -> + return @parent.add name, type, immediate if @shared and not immediate + if Object::hasOwnProperty.call @positions, name + @variables[@positions[name]].type = type + else + @positions[name] = @variables.push({name, type}) - 1 + +When `super` is called, we need to find the name of the current method we're +in, so that we know how to invoke the same method of the parent class. This +can get complicated if super is being called from an inner function. +`namedMethod` will walk up the scope tree until it either finds the first +function object that has a name filled in, or bottoms out. + + namedMethod: -> + return @method if @method.name or !@parent + @parent.namedMethod() + +Look up a variable name in lexical scope, and declare it if it does not +already exist. + + find: (name) -> + return yes if @check name + @add name, 'var' + no + +Reserve a variable name as originating from a function parameter for this +scope. No `var` required for internal references. + + parameter: (name) -> + return if @shared and @parent.check name, yes + @add name, 'param' + +Just check to see if a variable has already been declared, without reserving, +walks up to the root scope. + + check: (name) -> + !!(@type(name) or @parent?.check(name)) + +Generate a temporary variable name at the given index. + + temporary: (name, index) -> + if name.length > 1 + '_' + name + if index > 1 then index - 1 else '' + else + '_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a' + +Gets the type of a variable. + + type: (name) -> + return v.type for v in @variables when v.name is name + null + +If we need to store an intermediate result, find an available name for a +compiler-generated variable. `_var`, `_var2`, and so on... + + freeVariable: (name, reserve=true) -> + index = 0 + index++ while @check((temp = @temporary name, index)) + @add temp, 'var', yes if reserve + temp + +Ensure that an assignment is made at the top of this scope +(or at the top-level scope, if requested). + + assign: (name, value) -> + @add name, {value, assigned: yes}, yes + @hasAssignments = yes + +Does this scope have any declared variables? + + hasDeclarations: -> + !!@declaredVariables().length + +Return the list of variables first declared in this scope. + + declaredVariables: -> + realVars = [] + tempVars = [] + for v in @variables when v.type is 'var' + (if v.name.charAt(0) is '_' then tempVars else realVars).push v.name + realVars.sort().concat tempVars.sort() + +Return the list of assignments that are supposed to be made at the top +of this scope. + + assignedVariables: -> + "#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned + diff --git a/sources_non_forked/vim-colors-solarized/README.mkd b/sources_non_forked/vim-colors-solarized/README.mkd new file mode 100644 index 00000000..a163b029 --- /dev/null +++ b/sources_non_forked/vim-colors-solarized/README.mkd @@ -0,0 +1,267 @@ +--- +Title: Solarized Colorscheme for Vim +Description: Precision colors for machines and people +Author: Ethan Schoonover +Colors: light yellow +Created: 2011 Mar 15 +Modified: 2011 Apr 16 + +--- + +Solarized Colorscheme for Vim +============================= + +Developed by Ethan Schoonover + +Visit the [Solarized homepage] +------------------------------ + +See the [Solarized homepage] for screenshots, +details and colorscheme versions for Vim, Mutt, popular terminal emulators and +other applications. + +Screenshots +----------- + +![solarized dark](https://github.com/altercation/solarized/raw/master/img/solarized-vim.png) + +Downloads +--------- + +If you have come across this colorscheme via the [Vim-only repository] on +github, or the [vim.org script] page see the link above to the Solarized +homepage or visit the main [Solarized repository]. + +The [Vim-only repository] is kept in sync with the main [Solarized repository] +and is for installation convenience only (with [Pathogen] or [Vundle], for +instance). Issues, bug reports, changelogs are centralized at the main +[Solarized repository]. + +[Solarized homepage]: http://ethanschoonover.com/solarized +[Solarized repository]: https://github.com/altercation/solarized +[Vim-only repository]: https://github.com/altercation/vim-colors-solarized +[vimorg-script]: http://vim.org/script +[Pathogen]: https://github.com/tpope/vim-pathogen +[Vundle]: https://github.com/gmarik/vundle + +Installation +------------ + +### Option 1: Manual installation + +1. Move `solarized.vim` to your `.vim/colors` directory. After downloading the + vim script or package: + + $ cd vim-colors-solarized/colors + $ mv solarized.vim ~/.vim/colors/ + +### Option 2: Pathogen installation ***(recommended)*** + +1. Download and install Tim Pope's [Pathogen]. + +2. Next, move or clone the `vim-colors-solarized` directory so that it is + a subdirectory of the `.vim/bundle` directory. + + a. **Clone:** + + $ cd ~/.vim/bundle + $ git clone git://github.com/altercation/vim-colors-solarized.git + + b. **Move:** + + In the parent directory of vim-colors-solarized: + + $ mv vim-colors-solarized ~/.vim/bundle/ + +### Modify .vimrc + +After either Option 1 or Option 2 above, put the following two lines in your +.vimrc: + + syntax enable + set background=dark + colorscheme solarized + +or, for the light background mode of Solarized: + + syntax enable + set background=light + colorscheme solarized + +I like to have a different background in GUI and terminal modes, so I can use +the following if-then. However, I find vim's background autodetection to be +pretty good and, at least with MacVim, I can leave this background value +assignment out entirely and get the same results. + + if has('gui_running') + set background=light + else + set background=dark + endif + +See the [Solarized homepage] for screenshots which will help you +select either the light or dark background. + +### IMPORTANT NOTE FOR TERMINAL USERS: + +If you are going to use Solarized in Terminal mode (i.e. not in a GUI version +like gvim or macvim), **please please please** consider setting your terminal +emulator's colorscheme to used the Solarized palette. I've included palettes +for some popular terminal emulator as well as Xdefaults in the official +Solarized download available from [Solarized homepage]. If you use +Solarized *without* these colors, Solarized will need to be told to degrade its +colorscheme to a set compatible with the limited 256 terminal palette (whereas +by using the terminal's 16 ansi color values, you can set the correct, specific +values for the Solarized palette). + +If you do use the custom terminal colors, solarized.vim should work out of the +box for you. If you are using a terminal emulator that supports 256 colors and +don't want to use the custom Solarized terminal colors, you will need to use +the degraded 256 colorscheme. To do so, simply add the following line *before* +the `colorschem solarized` line: + + let g:solarized_termcolors=256 + +Again, I recommend just changing your terminal colors to Solarized values +either manually or via one of the many terminal schemes available for import. + +Advanced Configuration +---------------------- + +Solarized will work out of the box with just the two lines specified above but +does include several other options that can be set in your .vimrc file. + +Set these in your vimrc file prior to calling the colorscheme. +" + option name default optional + ------------------------------------------------ + g:solarized_termcolors= 16 | 256 + g:solarized_termtrans = 0 | 1 + g:solarized_degrade = 0 | 1 + g:solarized_bold = 1 | 0 + g:solarized_underline = 1 | 0 + g:solarized_italic = 1 | 0 + g:solarized_contrast = "normal"| "high" or "low" + g:solarized_visibility= "normal"| "high" or "low" + ------------------------------------------------ + +### Option Details + +* g:solarized_termcolors + + This is set to *16* by default, meaning that Solarized will attempt to use + the standard 16 colors of your terminal emulator. You will need to set + those colors to the correct Solarized values either manually or by + importing one of the many colorscheme available for popular terminal + emulators and Xdefaults. + +* g:solarized_termtrans + + If you use a terminal emulator with a transparent background and Solarized + isn't displaying the background color transparently, set this to 1 and + Solarized will use the default (transparent) background of the terminal + emulator. *urxvt* required this in my testing; iTerm2 did not. + + Note that on Mac OS X Terminal.app, solarized_termtrans is set to 1 by + default as this is almost always the best option. The only exception to + this is if the working terminfo file supports 256 colors (xterm-256color). + +* g:solarized_degrade + + For test purposes only; forces Solarized to use the 256 degraded color mode + to test the approximate color values for accuracy. + +* g:solarized_bold | g:solarized_underline | g:solarized_italic + + If you wish to stop Solarized from displaying bold, underlined or + italicized typefaces, simply assign a zero value to the appropriate + variable, for example: `let g:solarized_italic=0` + +* g:solarized_contrast + + Stick with normal! It's been carefully tested. Setting this option to high + or low does use the same Solarized palette but simply shifts some values up + or down in order to expand or compress the tonal range displayed. + +* g:solarized_visibility + + Special characters such as trailing whitespace, tabs, newlines, when + displayed using `:set list` can be set to one of three levels depending on + your needs. Default value is `normal` with `high` and `low` options. + +Toggle Background Function +-------------------------- + +Solarized comes with a Toggle Background plugin that by default will map to + if that mapping is available. If it is not available you will need to +either map the function manually or change your current mapping to +something else. + +To set your own mapping in your .vimrc file, simply add the following line to +support normal, insert and visual mode usage, changing the "" value to the +key or key combination you wish to use: + + call togglebg#map("") + +Note that you'll want to use a single function key or equivalent if you want +the plugin to work in all modes (normal, insert, visual). + +Code Notes +---------- + +Use folding to view the `solarized.vim` script with `foldmethod=marker` turned +on. + +I have attempted to modularize the creation of Vim colorschemes in this script +and, while it could be refactored further, it should be a good foundation for +the creation of any color scheme. By simply changing the sixteen values in the +GUI section and testing in gvim (or mvim) you can rapidly prototype new +colorschemes without diving into the weeds of line-item editing each syntax +highlight declaration. + +The Values +---------- + +L\*a\*b values are canonical (White D65, Reference D50), other values are +matched in sRGB space. + + SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB + --------- ------- ---- ------- ----------- ---------- ----------- ----------- + base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21 + base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26 + base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46 + base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51 + base0 #839496 12/6 brblue 244 #808080 60 -06 -03 131 148 150 186 13 59 + base1 #93a1a1 14/4 brcyan 245 #8a8a8a 65 -05 -02 147 161 161 180 9 63 + base2 #eee8d5 7/7 white 254 #d7d7af 92 -00 10 238 232 213 44 11 93 + base3 #fdf6e3 15/7 brwhite 230 #ffffd7 97 00 10 253 246 227 44 10 99 + yellow #b58900 3/3 yellow 136 #af8700 60 10 65 181 137 0 45 100 71 + orange #cb4b16 9/3 brred 166 #d75f00 50 50 55 203 75 22 18 89 80 + red #dc322f 1/1 red 160 #d70000 50 65 45 220 50 47 1 79 86 + magenta #d33682 5/5 magenta 125 #af005f 50 65 -05 211 54 130 331 74 83 + violet #6c71c4 13/5 brmagenta 61 #5f5faf 50 15 -45 108 113 196 237 45 77 + blue #268bd2 4/4 blue 33 #0087ff 55 -10 -45 38 139 210 205 82 82 + cyan #2aa198 6/6 cyan 37 #00afaf 60 -35 -05 42 161 152 175 74 63 + green #859900 2/2 green 64 #5f8700 60 -20 65 133 153 0 68 100 60 + +License +------- +Copyright (c) 2011 Ethan Schoonover + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/sources_non_forked/vim-colors-solarized/autoload/togglebg.vim b/sources_non_forked/vim-colors-solarized/autoload/togglebg.vim new file mode 100644 index 00000000..108511fe --- /dev/null +++ b/sources_non_forked/vim-colors-solarized/autoload/togglebg.vim @@ -0,0 +1,55 @@ +" Toggle Background +" Modified: 2011 Apr 29 +" Maintainer: Ethan Schoonover +" License: OSI approved MIT license + +if exists("g:loaded_togglebg") + finish +endif +let g:loaded_togglebg = 1 + +" noremap is a bit misleading here if you are unused to vim mapping. +" in fact, there is remapping, but only of script locally defined remaps, in +" this case TogBG. The +endsnippet + +snippet scriptsrc "HTML +endsnippet + +snippet select "Select Box" w + +endsnippet + +snippet small "" w +$1 +endsnippet + +snippet span "" w +${0:${VISUAL}} +endsnippet + +snippet span# " with ID & class" w +${0:${VISUAL}} +endsnippet + +snippet span. " with class" w +${0:${VISUAL}} +endsnippet + +snippet strong "" w +$1 +endsnippet + +snippet style "HTML +endsnippet + +snippet sub "" w +$1 +endsnippet + +snippet sup "" w +$1 +endsnippet + +snippet table "HTML " w +
+ ${0:${VISUAL}} +
+endsnippet + +snippet tbody "" +$1 +endsnippet + +snippet td "table cell" w +${0:${VISUAL}} +endsnippet + +snippet template "