add vim-ale

This commit is contained in:
AJ ONeal
2021-03-22 04:11:07 +00:00
parent 7786656193
commit 7a14219d7d
4 changed files with 140 additions and 0 deletions

65
vim-ale/README.md Normal file
View File

@@ -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%]'
```

31
vim-ale/ale.vim Normal file
View File

@@ -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%]'

7
vim-ale/install.ps1 Normal file
View File

@@ -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"

37
vim-ale/install.sh Normal file
View File

@@ -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