1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:10: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
au!
autocmd BufNewFile * call <SID>add_buffer_head()
autocmd FileType * call <SID>add_buffer_head()
augroup END
let s:ft_head_tp = {}
function! s:add_buffer_head() abort
if has_key(s:ft_head_tp, &ft)
call setline(1, s:ft_head_tp[&ft])
if has_key(s:ft_head_tp, &ft) && getline(1) == '' && line('$') == 1
let head = s:ft_head_tp[&ft]
call setline(1, head)
call cursor(len(head), 0)
endif
endfunction

View File

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

View File

@ -9,6 +9,7 @@
function! SpaceVim#layers#lang#sh#plugins() abort
let l:plugins = []
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
call add(l:plugins, ['Valodim/vim-zsh-completion', { 'on_ft' : 'zsh' }])
else
@ -24,10 +25,18 @@ function! SpaceVim#layers#lang#sh#config() abort
call SpaceVim#layers#edit#add_ft_head_tamplate('sh',
\ ['#!/usr/bin/env bash',
\ '']
\ '',
\ ''
\ ]
\ )
call SpaceVim#layers#edit#add_ft_head_tamplate('zsh', [
\ '#!/usr/bin/env zsh',
\ '',
\ ''
\ ])
call SpaceVim#layers#edit#add_ft_head_tamplate('fish', [
\ '#!/usr/bin/env fish',
\ '',
\ ''
\ ])
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
augroup END
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'))
endfunction
function! s:language_specified_mappings() abort
@ -49,7 +60,7 @@ function! s:language_specified_mappings() abort
endfunction
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()
endif
endfunction

View File

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