Skip to content

Commit

Permalink
Add slime syntax, closes #252
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Dec 6, 2017
1 parent 9fe0090 commit 11f5325
Show file tree
Hide file tree
Showing 39 changed files with 2,292 additions and 3,432 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ If you need full functionality of any plugin, please use it directly with your p
- [emberscript](https://github.com/yalesov/vim-ember-script) (syntax, indent, ftplugin)
- [emblem](https://github.com/yalesov/vim-emblem) (syntax, indent, ftplugin)
- [erlang](https://github.com/vim-erlang/vim-erlang-runtime) (syntax, indent)
- [fish](https://github.com/dag/vim-fish) ()
- [fsharp](https://github.com/fsharp/vim-fsharp) ()
- [git](https://github.com/tpope/vim-git) ()
- [glsl](https://github.com/tikhomirov/vim-glsl) ()
- [gmpl](https://github.com/maelvalais/gmpl.vim) ()
- [fish](https://github.com/dag/vim-fish) (syntax, indent, compiler, autoload, ftplugin)
- [fsharp](https://github.com/fsharp/vim-fsharp) (syntax, indent)
- [git](https://github.com/tpope/vim-git) (syntax, indent, ftplugin)
- [glsl](https://github.com/tikhomirov/vim-glsl) (syntax, indent)
- [gmpl](https://github.com/maelvalais/gmpl.vim) (syntax)
- [gnuplot](https://github.com/vim-scripts/gnuplot-syntax-highlighting) (syntax)
- [go](https://github.com/fatih/vim-go) (syntax, compiler, indent)
- [groovy](https://github.com/vim-scripts/groovy.vim) (syntax)
Expand All @@ -83,7 +83,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [jsx](https://github.com/mxw/vim-jsx) (after)
- [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin)
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent)
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) ()
- [less](https://github.com/groenewege/vim-less) (syntax, indent, ftplugin)
- [liquid](https://github.com/tpope/vim-liquid) (syntax, indent, ftplugin)
- [livescript](https://github.com/gkz/vim-ls) (syntax, indent, compiler, ftplugin)
Expand Down Expand Up @@ -121,6 +121,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [scala](https://github.com/derekwyatt/vim-scala) (syntax, indent, compiler, ftplugin)
- [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, autoload, ftplugin)
- [slim](https://github.com/slim-template/vim-slim) (syntax, indent, ftplugin)
- [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent)
- [solidity](https://github.com/tomlion/vim-solidity) (syntax, indent, ftplugin)
- [stylus](https://github.com/wavded/vim-stylus) (syntax, indent, ftplugin)
- [swift](https://github.com/keith/swift.vim) (syntax, indent, ftplugin)
Expand Down
13 changes: 13 additions & 0 deletions after/syntax/html.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ if exists('s:current_syntax_save')
unlet s:current_syntax_save
endif

endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'glsl') == -1

" Language: OpenGL Shading Language
" Maintainer: Sergey Tikhomirov <sergey@tikhomirov.io>

syn include @GLSL syntax/glsl.vim
syn region ShaderScript
\ start="<script [^>]*type=\('\|\"\)x-shader/x-\(vertex\|fragment\)\('\|\"\)[^>]*>"
\ keepend
\ end="</script>"me=s-1
\ contains=@GLSL,htmlScriptTag,@htmlPreproc

endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'html5') == -1

Expand Down
13 changes: 0 additions & 13 deletions after/syntax/tex.vim

This file was deleted.

71 changes: 71 additions & 0 deletions autoload/fish.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1

function! fish#Indent()
let l:shiftwidth = shiftwidth()
let l:prevlnum = prevnonblank(v:lnum - 1)
if l:prevlnum ==# 0
return 0
endif
let l:indent = 0
let l:prevline = getline(l:prevlnum)
if l:prevline =~# '\v^\s*switch>'
let l:indent = l:shiftwidth * 2
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
let l:indent = l:shiftwidth
endif
let l:line = getline(v:lnum)
if l:line =~# '\v^\s*end>'
return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent)
elseif l:line =~# '\v^\s*%(case|else)>'
return indent(v:lnum) - l:shiftwidth
endif
return indent(l:prevlnum) + l:indent
endfunction

function! fish#Format()
if mode() =~# '\v^%(i|R)$'
return 1
else
let l:command = v:lnum.','.(v:lnum+v:count-1).'!fish_indent'
echo l:command
execute l:command
endif
endfunction

function! fish#Fold()
let l:line = getline(v:lnum)
if l:line =~# '\v^\s*%(begin|if|while|for|function|switch)>'
return 'a1'
elseif l:line =~# '\v^\s*end>'
return 's1'
else
return '='
end
endfunction

function! fish#Complete(findstart, base)
if a:findstart
return getline('.') =~# '\v^\s*$' ? -1 : 0
else
if empty(a:base)
return []
endif
let l:results = []
let l:completions =
\ system('fish -c "complete -C'.shellescape(a:base).'"')
let l:cmd = substitute(a:base, '\v\S+$', '', '')
for l:line in split(l:completions, '\n')
let l:tokens = split(l:line, '\t')
call add(l:results, {'word': l:cmd.l:tokens[0],
\'abbr': l:tokens[0],
\'menu': get(l:tokens, 1, '')})
endfor
return l:results
endif
endfunction

function! fish#errorformat()
return '%Afish: %m,%-G%*\\ ^,%-Z%f (line %l):%s'
endfunction

endif
1 change: 1 addition & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ PACKS="
scala:derekwyatt/vim-scala
scss:cakebaker/scss-syntax.vim
slim:slim-template/vim-slim
slime:slime-lang/vim-slime-syntax
solidity:tomlion/vim-solidity
stylus:wavded/vim-stylus
swift:keith/swift.vim
Expand Down
11 changes: 11 additions & 0 deletions compiler/fish.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1

if exists('current_compiler')
finish
endif
let current_compiler = 'fish'

CompilerSet makeprg=fish\ --no-execute\ %
execute 'CompilerSet errorformat='.escape(fish#errorformat(), ' ')

endif
60 changes: 60 additions & 0 deletions ftdetect/polyglot.vim
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,77 @@ augroup END

augroup filetypedetect
" fish:dag/vim-fish
autocmd BufRead,BufNewFile *.fish setfiletype fish

" Detect fish scripts by the shebang line.
autocmd BufRead *
\ if getline(1) =~# '\v^#!%(\f*/|/usr/bin/env\s*<)fish>' |
\ setlocal filetype=fish |
\ endif

" Move cursor to first empty line when using funced.
autocmd BufRead fish_funced_*_*.fish call search('^$')

" Fish histories are YAML documents.
autocmd BufRead,BufNewFile ~/.config/fish/fish_{read_,}history setfiletype yaml

" Universal variable storages should not be hand edited.
autocmd BufRead,BufNewFile ~/.config/fish/fishd.* setlocal readonly

" Mimic `funced` when manually creating functions.
autocmd BufNewFile ~/.config/fish/functions/*.fish
\ call append(0, ['function '.expand('%:t:r'),
\'',
\'end']) |
\ 2
augroup END

augroup filetypedetect
" fsharp:fsharp/vim-fsharp:_BASIC
" F#, fsharp
autocmd BufNewFile,BufRead *.fs,*.fsi,*.fsx set filetype=fsharp
augroup END

augroup filetypedetect
" git:tpope/vim-git
" Git
autocmd BufNewFile,BufRead *.git/{,modules/**/,worktrees/*/}{COMMIT_EDIT,TAG_EDIT,MERGE_,}MSG set ft=gitcommit
autocmd BufNewFile,BufRead *.git/config,.gitconfig,gitconfig,.gitmodules set ft=gitconfig
autocmd BufNewFile,BufRead */.config/git/config set ft=gitconfig
autocmd BufNewFile,BufRead *.git/modules/**/config set ft=gitconfig
autocmd BufNewFile,BufRead git-rebase-todo set ft=gitrebase
autocmd BufNewFile,BufRead .gitsendemail.* set ft=gitsendemail
autocmd BufNewFile,BufRead *.git/**
\ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
\ set ft=git |
\ endif

" This logic really belongs in scripts.vim
autocmd BufNewFile,BufRead,StdinReadPost *
\ if getline(1) =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' |
\ set ft=git |
\ endif
autocmd BufNewFile,BufRead *
\ if getline(1) =~ '^From \x\{40\} Mon Sep 17 00:00:00 2001$' |
\ set filetype=gitsendemail |
\ endif
augroup END

augroup filetypedetect
" gmpl:maelvalais/gmpl.vim
au BufRead,BufNewFile *.mod set filetype=gmpl
augroup END

augroup filetypedetect
" glsl:tikhomirov/vim-glsl
" Language: OpenGL Shading Language
" Maintainer: Sergey Tikhomirov <sergey@tikhomirov.io>

" Extensions supported by Khronos reference compiler (with one exception, ".glsl")
" https://github.com/KhronosGroup/glslang
autocmd! BufNewFile,BufRead *.vert,*.tesc,*.tese,*.glsl,*.geom,*.frag,*.comp set filetype=glsl

" vim:set sts=2 sw=2 :
augroup END

augroup filetypedetect
Expand Down Expand Up @@ -909,6 +964,11 @@ augroup filetypedetect
autocmd BufNewFile,BufRead *.slim setfiletype slim
augroup END

augroup filetypedetect
" slime:slime-lang/vim-slime-syntax
autocmd BufNewFile,BufRead *.slime set filetype=slime
augroup END

augroup filetypedetect
" solidity:tomlion/vim-solidity
au BufNewFile,BufRead *.sol setf solidity
Expand Down
43 changes: 43 additions & 0 deletions ftplugin/fish.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'fish') == -1

setlocal comments=:#
setlocal commentstring=#%s
setlocal define=\\v^\\s*function>
setlocal foldexpr=fish#Fold()
setlocal formatoptions+=ron1
setlocal formatoptions-=t
setlocal include=\\v^\\s*\\.>
setlocal iskeyword=@,48-57,-,_,.,/
setlocal suffixesadd^=.fish

" Use the 'j' format option when available.
if v:version ># 703 || v:version ==# 703 && has('patch541')
setlocal formatoptions+=j
endif

if executable('fish_indent')
setlocal formatexpr=fish#Format()
endif

if executable('fish')
setlocal omnifunc=fish#Complete
for s:path in split(system("fish -c 'echo $fish_function_path'"))
execute 'setlocal path+='.s:path
endfor
else
setlocal omnifunc=syntaxcomplete#Complete
endif

" Use the 'man' wrapper function in fish to include fish's man pages.
" Have to use a script for this; 'fish -c man' would make the the man page an
" argument to fish instead of man.
execute 'setlocal keywordprg=fish\ '.fnameescape(expand('<sfile>:p:h:h').'/bin/man.fish')

let b:match_words =
\ escape('<%(begin|function|if|switch|while|for)>:<end>', '<>%|)')

let b:endwise_addition = 'end'
let b:endwise_words = 'begin,function,if,switch,while,for'
let b:endwise_syngroups = 'fishKeyword,fishConditional,fishRepeat'

endif
45 changes: 45 additions & 0 deletions ftplugin/git.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'git') == -1

" Vim filetype plugin
" Language: generic git output
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Last Change: 2013 May 30

" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
finish
endif
let b:did_ftplugin = 1

if !exists('b:git_dir')
if expand('%:p') =~# '[\/]\.git[\/]modules[\/]'
" Stay out of the way
elseif expand('%:p') =~# '[\/]\.git[\/]worktrees'
let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>')
elseif expand('%:p') =~# '\.git\>'
let b:git_dir = matchstr(expand('%:p'),'.*\.git\>')
elseif $GIT_DIR != ''
let b:git_dir = $GIT_DIR
endif
if (has('win32') || has('win64')) && exists('b:git_dir')
let b:git_dir = substitute(b:git_dir,'\\','/','g')
endif
endif

if exists('*shellescape') && exists('b:git_dir') && b:git_dir != ''
if b:git_dir =~# '/\.git$' " Not a bare repository
let &l:path = escape(fnamemodify(b:git_dir,':h'),'\, ').','.&l:path
endif
let &l:path = escape(b:git_dir,'\, ').','.&l:path
let &l:keywordprg = 'git --git-dir='.shellescape(b:git_dir).' show'
else
setlocal keywordprg=git\ show
endif
if has('gui_running')
let &l:keywordprg = substitute(&l:keywordprg,'^git\>','git --no-pager','')
endif

setlocal includeexpr=substitute(v:fname,'^[^/]\\+/','','')
let b:undo_ftplugin = "setl keywordprg< path< includeexpr<"

endif
Loading

0 comments on commit 11f5325

Please sign in to comment.