1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:10:04 +08:00

Improve lang#dart layer (#3876)

This commit is contained in:
Wang Shidong 2020-10-10 09:51:46 +08:00 committed by GitHub
parent 8c9cda2690
commit 52f5f51e73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 127 additions and 88 deletions

View File

@ -1,8 +1,6 @@
[![SpaceVim](https://spacevim.org/logo.png)](https://spacevim.org)
[Wiki](https://github.com/SpaceVim/SpaceVim/wiki) \|
[Quick start guide](https://spacevim.org/quick-start-guide/) \|
[Documentation](https://spacevim.org/documentation/) \|
[Community](https://spacevim.org/community/) \|
[Sponsors](https://spacevim.org/sponsors/) \|
[Twitter](https://twitter.com/SpaceVim) \|
@ -12,7 +10,6 @@
[![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=master)](https://travis-ci.org/SpaceVim/SpaceVim)
[![Build status](https://ci.appveyor.com/api/projects/status/eh3t5oph70abp665/branch/master?svg=true)](https://ci.appveyor.com/project/wsdjeg/spacevim/branch/master)
[![Docker Build Status](https://img.shields.io/docker/build/spacevim/spacevim.svg)](https://hub.docker.com/r/spacevim/spacevim/)
[![codecov](https://codecov.io/gh/SpaceVim/SpaceVim/branch/master/graph/badge.svg)](https://codecov.io/gh/SpaceVim/SpaceVim/branch/master)
![Version](https://img.shields.io/badge/version-1.6.0--dev-8700FF.svg)
[![GPLv3 License](https://img.shields.io/badge/license-GPLv3-blue.svg)](LICENSE)
[![Doc](https://img.shields.io/badge/doc-%3Ah%20SpaceVim-orange.svg)](doc/SpaceVim.txt)
@ -30,54 +27,6 @@ The last release is [v1.5.0](https://spacevim.org/SpaceVim-release-v1.5.0/), che
- [Documentation](https://spacevim.org/documentation/): The full documentation about using SpaceVim.
- [Available Layers](https://spacevim.org/layers/): A list of all available layers included in SpaceVim.
## Features
This is a list of latest features implemented in SpaceVim:
**Iedit mode**
SpaceVim uses a powerful iedit mode to quick edit multiple occurrences of a symbol or selection. Two new modes:`iedit-Normal`/`iedit-Insert`.
The default color for iedit is `red`/`green` which is based on the current colorscheme.
![iedit mode](https://user-images.githubusercontent.com/13142418/44941560-be2a9800-add2-11e8-8fa5-e6118ff9ddcb.gif)
**Highlight cursor symbol**
SpaceVim supports highlighting of the current symbol on demand and adds
a transient state to easily navigate and rename this symbol.
![highlight cursor symbol](https://user-images.githubusercontent.com/13142418/36210381-e6dffde6-1163-11e8-9b35-0bf262e6f22b.gif)
[**Fly Grep in Vim**](https://spacevim.org/grep-on-the-fly-in-spacevim/)
With this feature, Vim will display the searching result as you type. Of course, it is running
asynchronously. Before using this feature, you need to install a searching tool. FlyGrep works
through search tools: `ag`, `rg`, `ack`, `pt` and `grep`, Choose one you like.
![searching project](https://user-images.githubusercontent.com/13142418/35278709-7856ed62-0010-11e8-8b1e-e6cc6374b0dc.gif)
[**Mnemonic key bindings navigation**](https://spacevim.org/mnemonic-key-bindings-navigation/)
You don't need to remember any key bindings, as the mapping guide will show up after the <kbd>SPC</kbd> is pressed.
The mapping guide is also available for `g`, `z`, and `s`.
![float_guide](https://user-images.githubusercontent.com/13142418/89091735-5de96a00-d3de-11ea-85e1-b0fc64537836.gif)
[**Help description for key bindings**](https://spacevim.org/help-description-for-key-bindings/)
Use <kbd>SPC h d k</kbd> to get the help description of a key binding, and `gd` to find definition of key bindings.
![describe key bindings](https://user-images.githubusercontent.com/13142418/35568829-e3c8e74c-058f-11e8-8fa8-c0e046d8add3.gif)
[**Asynchronous plugin manager**](https://spacevim.org/asynchronous-plugin-manager/)
Create an UI for [dein.vim](https://github.com/Shougo/dein.vim/) - the best asynchronous vim plugin manager
![UI for dein](https://user-images.githubusercontent.com/13142418/34907332-903ae968-f842-11e7-8ac9-07fcc9940a53.gif)
For more features, please read [SpaceVim's Blog](https://spacevim.org/blog/)
## Support SpaceVim
This project exists thanks to all the people who [contributed](CONTRIBUTING.md),
@ -90,14 +39,16 @@ Helping the community on the [Gitter Chat](https://gitter.im/SpaceVim/SpaceVim)
For more information please check our [development guidelines](https://spacevim.org/development/).
If you want to show your support financially you can buy a drink for the maintainer by clicking following icon.
If you use SpaceVim in your daily work and feel that it has made your life easier,
please consider buying me a coffee once in a while!
<a href='https://ko-fi.com/spacevim' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=f' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
## Credits & Thanks
- [@Gabirel](https://github.com/Gabirel) and his [Hack-SpaceVim](https://github.com/Gabirel/Hack-SpaceVim)
- [@everettjf](https://github.com/everettjf) and his [SpaceVimTutorial](https://everettjf.gitbooks.io/spacevimtutorial/content/)
- [Hack-SpaceVim](https://github.com/Gabirel/Hack-SpaceVim) by [@Gabirel](https://github.com/Gabirel)
- [SpaceVimTutorial](https://everettjf.gitbooks.io/spacevimtutorial/content/) by [@everettjf](https://github.com/everettjf)
- [10-minutes-to-SpaceVim](https://github.com/Jackiexiao/10-minutes-to-SpaceVim) by [@Jackiexiao](https://github.com/Jackiexiao)
- [vimdoc](https://github.com/google/vimdoc) generate doc file for SpaceVim
- Authors of all the plugins used in SpaceVim.

View File

@ -42,6 +42,15 @@
"
"
if exists('s:flutter_job_id')
finish
else
let s:flutter_job_id = 0
endif
let s:JOB = SpaceVim#api#import('job')
let s:NOTI =SpaceVim#api#import('notification')
function! SpaceVim#layers#lang#dart#plugins() abort
let plugins = []
call add(plugins, ['dart-lang/dart-vim-plugin', {'merged' : 0}])
@ -56,6 +65,7 @@ function! SpaceVim#layers#lang#dart#config() abort
call SpaceVim#plugins#runner#reg_runner('dart', 'dart %s')
call SpaceVim#mapping#space#regesit_lang_mappings('dart', function('s:language_specified_mappings'))
call SpaceVim#plugins#repl#reg('dart', ['pub', 'global', 'run', 'dart_repl'])
call add(g:spacevim_project_rooter_patterns, 'pubspec.yaml')
endfunction
function! s:language_specified_mappings() abort
@ -83,4 +93,93 @@ function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
endif
let g:_spacevim_mappings_space.l.f = {'name' : '+Flutter'}
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'r'], 'call call('
\ . string(s:_function('s:flutter_run')) . ', [])',
\ 'flutter-run', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'D'], 'call SpaceVim#plugins#runner#open("flutter doctor")',
\ 'flutter-doctor', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'd'], 'call SpaceVim#plugins#runner#open("flutter devices")',
\ 'flutter-devices', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'e'], 'call SpaceVim#plugins#runner#open("flutter emulators")',
\ 'flutter-emulators', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'l'], 'call call('
\ . string(s:_function('s:flutter_send')) . ', ["r"])',
\ 'flutter-reload', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 's'], 'call call('
\ . string(s:_function('s:flutter_send')) . ', ["R"])',
\ 'flutter-restart', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'q'], 'call call('
\ . string(s:_function('s:flutter_send')) . ', ["q"])',
\ 'flutter-quit', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'f', 'E'], 'call call('
\ . string(s:_function('s:flutter_emulators_launch')) . ', [])',
\ 'flutter-emulators-launch', 1)
endfunction
function! s:flutter_run() abort
if s:flutter_job_id ==# 0
" call s:NOTI.notification(line, 'Normal')
let s:flutter_job_id = s:JOB.start('flutter run',
\ {
\ 'on_stdout' : function('s:on_stdout'),
\ 'on_stderr' : function('s:on_stderr'),
\ 'on_exit' : function('s:on_exit'),
\ }
\ )
endif
endfunction
function! s:flutter_send(msg) abort
if s:flutter_job_id ==# 0
call s:NOTI.notification('Flutter is not running.', 'WarningMsg')
else
call s:JOB.send(s:flutter_job_id, a:msg)
endif
endfunction
function! s:on_stdout(id, data, event) abort
for line in filter(a:data, '!empty(v:val)')
call s:NOTI.notification(line, 'Normal')
endfor
endfunction
function! s:on_stderr(id, data, event) abort
for line in filter(a:data, '!empty(v:val)')
call s:NOTI.notification(line, 'WarningMsg')
endfor
endfunction
function! s:on_exit(...) abort
let s:flutter_job_id = 0
endfunction
function! s:flutter_emulators_launch() abort
call inputsave()
let emulators = input('emulators id:')
call inputrestore()
if !empty(emulators)
call s:JOB.start(['flutter', 'emulators', '--launch', emulators],
\ {
\ 'on_stdout' : function('s:on_stdout'),
\ 'on_stderr' : function('s:on_stderr'),
\ }
\ )
endif
endfunction
" function() wrapper
if v:version > 703 || v:version == 703 && has('patch1170')
function! s:_function(fstr) abort
return function(a:fstr)
endfunction
else
function! s:_SID() abort
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif

View File

@ -18,7 +18,6 @@ lang: zh
- [交互式编程](#交互式编程)
- [运行当前脚本](#运行当前脚本)
- [代码格式化](#代码格式化)
- [相关截图](#相关截图)
<!-- vim-markdown-toc -->
@ -80,17 +79,3 @@ pub global activate dart_repl
| 快捷键 | 功能描述 |
| ----------- | -------------- |
| `SPC b f` | 格式化当前文件 |
## 相关截图
**代码格式化:**
![format-dart-file-in-spacevim](https://user-images.githubusercontent.com/13142418/34455939-b094db54-ed4f-11e7-9df0-80cf5de1128d.gif)
**代码补全:**
![complete-dart-in-spacevim](https://user-images.githubusercontent.com/13142418/34455816-ee77182c-ed4c-11e7-8f63-402849f60405.png)
**异步执行:**
![dart-runner-in-spacevim](https://user-images.githubusercontent.com/13142418/34455403-1f6d4c3e-ed44-11e7-893f-09a6e64e27ed.png)

View File

@ -19,8 +19,6 @@ lang: zh
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| <img src="../../img/weixin.png" height="150" width="150"> | <img src="../../img/zhifubao.png" height="150" width="150"> |
比特币1DtuVeg81c2L9NEhDaVTAAbrCR3pN5xPFv
## 历史赞助
以下是所有的历史赞助,记住那些曾经爱心赞助的人们,非常感谢,你们的鼓励就是我坚持的动力(排名不分先后,如有遗漏疏忽,请务必告知)。

View File

@ -17,7 +17,7 @@ description: "This layer is for Dart development, provide autocompletion, syntax
- [Inferior REPL process](#inferior-repl-process)
- [Running current script](#running-current-script)
- [Code formatting](#code-formatting)
- [Screenshots](#screenshots)
- [Flutter integration](#flutter-integration)
<!-- vim-markdown-toc -->
@ -32,6 +32,7 @@ This layer is for Dart development.
- code formatting
- REPL
- code runner
- flutter integration
## Install
@ -46,7 +47,8 @@ To use this configuration layer, update custom configuration file with:
### Syntax checking && Code formatting
To enable syntax checking and code formatting in spacevim, you need to install [dart sdk](https://github.com/dart-lang/sdk).
To enable syntax checking and code formatting in spacevim,
you need to install [dart sdk](https://github.com/dart-lang/sdk).
### Install dart-repl
@ -76,20 +78,23 @@ To running a ruby script, you can press `SPC l r` to run current file without lo
### Code formatting
The code formatting is provided by `format` layer, and it will run `dartfmt` asynchronously.
| Key Bindings | Descriptions |
| ------------ | --------------------- |
| `SPC b f` | format current buffer |
## Screenshots
### Flutter integration
**code formatting:**
When edit dart file, the following key bindings are available for running flutter commands.
![format-dart-file-in-spacevim](https://user-images.githubusercontent.com/13142418/34455939-b094db54-ed4f-11e7-9df0-80cf5de1128d.gif)
**auto completion:**
![complete-dart-in-spacevim](https://user-images.githubusercontent.com/13142418/34455816-ee77182c-ed4c-11e7-8f63-402849f60405.png)
**code runner:**
![dart-runner-in-spacevim](https://user-images.githubusercontent.com/13142418/34455403-1f6d4c3e-ed44-11e7-893f-09a6e64e27ed.png)
| Key bindings | Descriptions |
| ------------ | -------------------------------- |
| `SPC l f D` | Display flutter doctor result |
| `SPC l f E` | Launch to a flutter emulators id |
| `SPC l f d` | Display flutter devices result |
| `SPC l f e` | Display flutter emulators list |
| `SPC l f l` | Reload flutter app |
| `SPC l f r` | Run `flutter run` command |
| `SPC l f s` | Restart flutter app |
| `SPC l f q` | Quit current flutter process |

View File

@ -13,12 +13,15 @@ description: "The companies or individuals contributing a monthly amount to help
<!-- vim-markdown-toc -->
SpaceVim is an open source project. Please consider supporting SpaceVim by:
SpaceVim is an open source project.
Currently, this project is maintained by [@wsdjeg](https://github.com/wsdjeg),
If you use SpaceVim in your daily work and feel that it has made your life easier,
please consider supporting SpaceVim by:
- [Become a backer on BountySource](https://salt.bountysource.com/teams/spacevim)
- [Become a backer on opencollective](https://opencollective.com/spacevim)
Also, you can buy us a coffee:
Also, you can buy me a coffee:
<a href='https://ko-fi.com/SpaceVim' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi4.png?v=f' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
@ -26,8 +29,6 @@ Also, you can buy us a coffee:
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| <img src="https://spacevim.org/img/weixin.png" height="150" width="150"> | <img src="https://spacevim.org/img/zhifubao.png" height="150" width="150"> |
Bitcoin: 1DtuVeg81c2L9NEhDaVTAAbrCR3pN5xPFv
## Backers
| Name | Description |