Vim插件ale在windows下的安装配置与BUG解决

​​​​​​

ALE介绍

ale是一个异步的检测插件,项目的介绍如下:

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 makes use of NeoVim and Vim 8 job control functions and timers to run linters on the contents of text buffers and return errors as texts changed in Vim. This allows for displaying warnings and errors in files being edited in Vim before files have been saved back to a filesystem.

In other words, this plugin allows you to lint while you type.

ALE offers support for fixing code with command line tools in a non-blocking manner with the :ALEFix feature, supporting tools in many languages, like prettier, eslint, autopep8, and more.

Github地址:Check syntax in Vim asynchronously and fix files, with Language Server Protocol (LSP) support

ALE安装

ale支持多种安装方式,详情参考项目github地址,这里以Vundle方式安装:

  1. 安装好Vundle插件
  2. .vimrc文件的Vundle插件列表里添加如下:
Plugin 'dense-analysis/ale'
  1. 打开vim然后运行命令:PluginInstall或者:BundleInstall等待完成即可。
  2. 相应语言的linter,可以查看github上的支持列表,装好相应的linter,加入环境变量即可。

Note:

  1. 由于Vundle插件后台还是在调用git进行代码克隆,如果失败请设置代理或者手动克隆项目到Vundle安装文件夹下,默认为~/.vim/bundle/
  2. linux下的家目录为~,windows下的家目录为%HOME_PATH%,如果在windows下可以使用\\(whindows风格,必须是双反斜杠,取消转义)或者/(linux风格)作为目录分割符。

ALE配置

详情参考项目github地址,在Vim中输入命令:h ale可以查看各种相关内容,大部分配置使用默认的就可以了,这里给出一些简单显示配置(以下所有设置都在.vimrc文件中写入,新修改的设置默认需要重启Vim才生效)。

自定义侧边提示符号

原始的ale侧边提示是这样:

--表示警告,>>表示错误,这样不是那么醒目,可以进行自定义设置:

" 自定义error和warning图标
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'

重启打开Vim之后显示效果就变成这样了:

Note: 可以选择任何你喜欢的符号,出现乱码请检查Vim相关的编码设置以及字体是否支持该种符号。

自定义底部提示消息

默认的底部栏只显示出错消息:

可以设置添加更多的消息:

" 显示Linter名称,出错或警告等相关信息
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str 
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值