Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
202 lines
7.0 KiB
VimL
202 lines
7.0 KiB
VimL
"=============================================================================
|
|
" dart.vim --- SpaceVim lang#dart layer
|
|
" Copyright (c) 2016-2023 Wang Shidong & Contributors
|
|
" Author: Wang Shidong < wsdjeg@outlook.com >
|
|
" URL: https://spacevim.org
|
|
" License: GPLv3
|
|
"=============================================================================
|
|
|
|
""
|
|
" @section lang#dart, layers-lang-dart
|
|
" @parentsection layers
|
|
" @subsection Intro
|
|
"
|
|
" The lang#dart layer provides code completion, documentation lookup, jump to
|
|
" definition, dart_repl integration for dart. It uses neomake as default
|
|
" syntax checker which is loaded in @section(layer-checkers). To enable this
|
|
" layer:
|
|
" >
|
|
" [[layers]]
|
|
" name = "lang#dart"
|
|
" <
|
|
"
|
|
" @subsection Layer options
|
|
"
|
|
" 1. `dart_sdk_path`: Set the path of dart sdk, by default, it is ''.
|
|
"
|
|
" @subsection Key bindings
|
|
" >
|
|
" Mode Key Function
|
|
" ---------------------------------------------
|
|
" normal SPC l r run current file
|
|
" <
|
|
"
|
|
" This layer also provides REPL support for hack, the key bindings are:
|
|
" >
|
|
" Key Function
|
|
" ---------------------------------------------
|
|
" SPC l s i Start a inferior REPL process
|
|
" SPC l s b send whole buffer
|
|
" SPC l s l send current line
|
|
" SPC l s s send selection text
|
|
" <
|
|
"
|
|
" This layer use deoplete-dart as default completion plugin for dart. If the
|
|
" @section(layer-lsp) is enabled for dart, This plugin will not be loaded.
|
|
"
|
|
"
|
|
|
|
if exists('s:flutter_job_id')
|
|
finish
|
|
endif
|
|
|
|
let s:flutter_job_id = 0
|
|
let s:dart_sdk_path = ''
|
|
|
|
let s:JOB = SpaceVim#api#import('job')
|
|
let s:NOTI = SpaceVim#api#import('notify')
|
|
|
|
function! SpaceVim#layers#lang#dart#plugins() abort
|
|
let plugins = []
|
|
call add(plugins, ['dart-lang/dart-vim-plugin', {'merged' : 0}])
|
|
if !SpaceVim#layers#lsp#check_filetype('dart')
|
|
call add(plugins, ['SpaceVim/deoplete-dart', {'merged' : 0}])
|
|
endif
|
|
return plugins
|
|
endfunction
|
|
|
|
|
|
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')
|
|
let g:deoplete#sources#dart#dart_sdk_path = s:dart_sdk_path
|
|
endfunction
|
|
|
|
function! SpaceVim#layers#lang#dart#set_variable(var) abort
|
|
let s:dart_sdk_path = get(a:var, 'dart_sdk_path', s:dart_sdk_path)
|
|
endfunction
|
|
|
|
function! s:language_specified_mappings() abort
|
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'],
|
|
\ 'call SpaceVim#plugins#runner#open()',
|
|
\ 'execute current file', 1)
|
|
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
|
\ 'call SpaceVim#plugins#repl#start("dart")',
|
|
\ 'start REPL process', 1)
|
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
|
\ 'call SpaceVim#plugins#repl#send("line")',
|
|
\ 'send line and keep code buffer focused', 1)
|
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
|
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
|
\ 'send buffer and keep code buffer focused', 1)
|
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
|
\ 'call SpaceVim#plugins#repl#send("selection")',
|
|
\ 'send selection and keep code buffer focused', 1)
|
|
if SpaceVim#layers#lsp#check_filetype('dart')
|
|
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
|
|
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
|
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
|
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.notify(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.notify('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.notify(line, 'Normal')
|
|
endfor
|
|
endfunction
|
|
|
|
function! s:on_stderr(id, data, event) abort
|
|
for line in filter(a:data, '!empty(v:val)')
|
|
call s:NOTI.notify(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
|
|
|
|
function! SpaceVim#layers#lang#dart#health() abort
|
|
call SpaceVim#layers#lang#dart#plugins()
|
|
call SpaceVim#layers#lang#dart#config()
|
|
return 1
|
|
endfunction
|