From: AJ ONeal Date: Mon, 22 Mar 2021 04:11:07 +0000 (+0000) Subject: add vim-ale X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=7a14219d7d51d9f4cfa22b2bd7ce2ed47639be6e;p=webi-installers%2F.git add vim-ale --- diff --git a/vim-ale/README.md b/vim-ale/README.md new file mode 100644 index 0000000..a4b226d --- /dev/null +++ b/vim-ale/README.md @@ -0,0 +1,65 @@ +--- +title: vim-ale +homepage: https://github.com/dense-analysis/ale +tagline: | + ALE: allows you to lint while you type. +--- + +To update (replacing the current version) run `webi vim-ale`. + +## Cheat Sheet + +> ALE (Asynchronous Lint Engine) is a plugin providing linting (syntax checking +> and semantic errors) in NeoVim 0.2.0+ and Vim 8 while you edit your text +> files, and acts as a Vim Language Server Protocol client. + +ALE is the spiritual successor to Syntastic. + +This installer includes a few reasonable defaults. + +### How to install and configure manually + +```bash +git clone --depth=1 https://github.com/dense-analysis/ale.git ~/.vim/pack/plugins/start/ale +``` + +`.vimrc`: + +```vim +" ALE: reasonable defaults from webinstall.dev/vim-ale +source ~/.vim/plugins/ale.vim +``` + +`.vim/plugins/ale.vim`: + +```txt +" turn on the syntax checker +syntax on + +" don't check syntax immediately on open or on quit +let g:ale_lint_on_enter = 0 +let g:ale_lint_on_save = 1 + +" error symbol to use in sidebar +let g:ale_sign_error = '☢️' +let g:ale_sign_warning = '⚡' + +" show number of errors +function! LinterStatus() abort + let l:counts = ale#statusline#Count(bufnr('')) + let l:all_errors = l:counts.error + l:counts.style_error + let l:all_non_errors = l:counts.total - l:all_errors + return l:counts.total == 0 ? 'OK' : printf( + \ '%d⨉ %d⚠ ', + \ all_non_errors, + \ all_errors + \) +endfunction +set statusline+=%= +set statusline+=\ %{LinterStatus()} + +" format error strings +let g:ale_echo_msg_error_str = 'E' +let g:ale_echo_msg_warning_str = 'W' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' +``` diff --git a/vim-ale/ale.vim b/vim-ale/ale.vim new file mode 100644 index 0000000..23c2f9d --- /dev/null +++ b/vim-ale/ale.vim @@ -0,0 +1,31 @@ +" turn on the syntax checker +syntax on + +" don't check immediately on open (or quit) +let g:ale_lint_on_enter = 0 +" check on save +let g:ale_lint_on_save = 1 + +" these emojis go in the sidebar for errors and warnings +" other considerations: '💥' '☠' '●' '.' +let g:ale_sign_error = '☢️' +let g:ale_sign_warning = '⚡' + +" show error count +function! LinterStatus() abort + let l:counts = ale#statusline#Count(bufnr('')) + let l:all_errors = l:counts.error + l:counts.style_error + let l:all_non_errors = l:counts.total - l:all_errors + return l:counts.total == 0 ? 'OK' : printf( + \ '%d⨉ %d⚠ ', + \ all_non_errors, + \ all_errors + \) +endfunction +set statusline+=%= +set statusline+=\ %{LinterStatus()} + +" how to show error message +let g:ale_echo_msg_error_str = 'E' +let g:ale_echo_msg_warning_str = 'W' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' diff --git a/vim-ale/install.ps1 b/vim-ale/install.ps1 new file mode 100644 index 0000000..5132639 --- /dev/null +++ b/vim-ale/install.ps1 @@ -0,0 +1,7 @@ +#!/usr/bin/env pwsh + +IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\pack\plugins\start")) { + New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force +} +Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\ale" -Recurse -ErrorAction Ignore +& git clone --depth=1 https://github.com/dense-analysis/ale.git "$Env:USERPROFILE\.vim\pack\plugins\start\ale" diff --git a/vim-ale/install.sh b/vim-ale/install.sh new file mode 100644 index 0000000..4cb252f --- /dev/null +++ b/vim-ale/install.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +function __init_vim_ale() { + set -e + set -u + + mkdir -p "$HOME/.vim/pack/plugins/start" + rm -rf "$HOME/.vim/pack/plugins/start/ale" + git clone --depth=1 https://github.com/dense-analysis/ale.git "$HOME/.vim/pack/plugins/start/ale" + + if [ ! -f "$HOME/.vimrc" ]; then + touch "$HOME/.vimrc" + fi + + mkdir -p ~/.vim/plugins + if ! [ -f "$HOME/.vim/plugins/ale.vim" ]; then + WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"} + curl -fsSL -o ~/.vim/plugins/ale.vim "$WEBI_HOST/packages/vim-ale/ale.vim" + fi + + if ! grep 'source.*plugins.ale.vim' -r ~/.vimrc >/dev/null 2>/dev/null; then + set +e + mkdir -p ~/.vim/plugins + printf '\n" ALE: reasonable defaults from webinstall.dev/vim-ale\n' >> ~/.vimrc + printf 'source ~/.vim/plugins/ale.vim\n' >> ~/.vimrc + set -e + echo "" + echo "add ~/.vim/plugins/ale.vim" + echo "updated ~/.vimrc with 'source ~/.vim/plugins/ale.vim'" + fi + + echo "" + echo "vim-ale enabled with reasonable defaults" + +} + +__init_vim_ale