1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 06:40:05 +08:00

add fish script support (#3033)

This commit is contained in:
Wang Shidong 2019-09-04 22:56:45 +08:00 committed by GitHub
parent 4d6ebb590e
commit af1b4d1f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 22 deletions

View File

@ -608,12 +608,14 @@ endif
augroup spacevim_layer_edit augroup spacevim_layer_edit
au! au!
autocmd BufNewFile * call <SID>add_buffer_head() autocmd FileType * call <SID>add_buffer_head()
augroup END augroup END
let s:ft_head_tp = {} let s:ft_head_tp = {}
function! s:add_buffer_head() abort function! s:add_buffer_head() abort
if has_key(s:ft_head_tp, &ft) if has_key(s:ft_head_tp, &ft) && getline(1) == '' && line('$') == 1
call setline(1, s:ft_head_tp[&ft]) let head = s:ft_head_tp[&ft]
call setline(1, head)
call cursor(len(head), 0)
endif endif
endfunction endfunction

View File

@ -70,7 +70,9 @@ function! SpaceVim#layers#lang#python#config() abort
call SpaceVim#layers#edit#add_ft_head_tamplate('python', call SpaceVim#layers#edit#add_ft_head_tamplate('python',
\ ['#!/usr/bin/env python', \ ['#!/usr/bin/env python',
\ '# -*- coding: utf-8 -*-', \ '# -*- coding: utf-8 -*-',
\ ''] \ '',
\ ''
\ ]
\ ) \ )
if executable('ipython') if executable('ipython')
call SpaceVim#plugins#repl#reg('python', 'ipython --no-term-title') call SpaceVim#plugins#repl#reg('python', 'ipython --no-term-title')

View File

@ -9,6 +9,7 @@
function! SpaceVim#layers#lang#sh#plugins() abort function! SpaceVim#layers#lang#sh#plugins() abort
let l:plugins = [] let l:plugins = []
call add(l:plugins, ['chrisbra/vim-zsh', { 'on_ft' : 'zsh' }]) call add(l:plugins, ['chrisbra/vim-zsh', { 'on_ft' : 'zsh' }])
call add(l:plugins, ['dag/vim-fish', { 'merged' : 0 }])
if get(g:, 'spacevim_enable_ycm') == 1 if get(g:, 'spacevim_enable_ycm') == 1
call add(l:plugins, ['Valodim/vim-zsh-completion', { 'on_ft' : 'zsh' }]) call add(l:plugins, ['Valodim/vim-zsh-completion', { 'on_ft' : 'zsh' }])
else else
@ -24,10 +25,18 @@ function! SpaceVim#layers#lang#sh#config() abort
call SpaceVim#layers#edit#add_ft_head_tamplate('sh', call SpaceVim#layers#edit#add_ft_head_tamplate('sh',
\ ['#!/usr/bin/env bash', \ ['#!/usr/bin/env bash',
\ ''] \ '',
\ ''
\ ]
\ ) \ )
call SpaceVim#layers#edit#add_ft_head_tamplate('zsh', [ call SpaceVim#layers#edit#add_ft_head_tamplate('zsh', [
\ '#!/usr/bin/env zsh', \ '#!/usr/bin/env zsh',
\ '',
\ ''
\ ])
call SpaceVim#layers#edit#add_ft_head_tamplate('fish', [
\ '#!/usr/bin/env fish',
\ '',
\ '' \ ''
\ ]) \ ])
augroup spacevim_layer_lang_sh augroup spacevim_layer_lang_sh
@ -35,6 +44,8 @@ function! SpaceVim#layers#lang#sh#config() abort
autocmd FileType sh setlocal omnifunc=SpaceVim#plugins#bashcomplete#omnicomplete autocmd FileType sh setlocal omnifunc=SpaceVim#plugins#bashcomplete#omnicomplete
augroup END augroup END
call SpaceVim#mapping#gd#add('sh', function('s:go_to_def')) call SpaceVim#mapping#gd#add('sh', function('s:go_to_def'))
call SpaceVim#mapping#gd#add('zsh', function('s:go_to_def'))
call SpaceVim#mapping#gd#add('fish', function('s:go_to_def'))
call SpaceVim#mapping#space#regesit_lang_mappings('sh', function('s:language_specified_mappings')) call SpaceVim#mapping#space#regesit_lang_mappings('sh', function('s:language_specified_mappings'))
endfunction endfunction
function! s:language_specified_mappings() abort function! s:language_specified_mappings() abort
@ -49,7 +60,7 @@ function! s:language_specified_mappings() abort
endfunction endfunction
function! s:go_to_def() abort function! s:go_to_def() abort
if SpaceVim#layers#lsp#check_filetype('sh') if SpaceVim#layers#lsp#check_filetype(&filetype)
call SpaceVim#lsp#go_to_def() call SpaceVim#lsp#go_to_def()
endif endif
endfunction endfunction

View File

@ -599,6 +599,9 @@ function! s:winclose() abort " {{{
let s:gwin = -1 let s:gwin = -1
noautocmd execute s:winnr.'wincmd w' noautocmd execute s:winnr.'wincmd w'
call winrestview(s:winv) call winrestview(s:winv)
if exists('*nvim_open_win')
doautocmd WinEnter
endif
endif endif
call s:remove_cursor_highlight() call s:remove_cursor_highlight()
endfunction " }}} endfunction " }}}

View File

@ -18,7 +18,7 @@ lang: cn
## 模块简介 ## 模块简介
这一模块为 SpaceVim 提供了 Shell Script 开发支持。Shell Script 是指 Bash script 和 Zsh script。 这一模块为 SpaceVim 提供了 Shell Script 开发支持。Shell Script 是指 bash script、zsh script 和 fish script。
## 功能特性 ## 功能特性

View File

@ -18,7 +18,7 @@ description: "Shell script development layer, provides autocompletion, syntax ch
## Description ## Description
This layer is for shell script development. Shell script includes bash script and zsh script. This layer is for shell script development. Shell script includes bash, zsh and fish script.
## Features ## Features