Browse Source

nvim: ++dhall, haskell, git, dockerfile

Maxim Likhachev 4 years ago
parent
commit
ecff0a4533
  1. 43
      etc/soft/nvim/+ftplugin/dhall.vim
  2. 1
      etc/soft/nvim/+ftplugin/diff.vim
  3. 2
      etc/soft/nvim/+ftplugin/dockerfile.vim
  4. 3
      etc/soft/nvim/+ftplugin/git.vim
  5. 169
      etc/soft/nvim/+ftplugin/haskell.vim
  6. 11
      etc/soft/nvim/+plugins/dhall-vim/LICENSE
  7. 15
      etc/soft/nvim/+plugins/dhall-vim/README.md
  8. 13
      etc/soft/nvim/+plugins/dhall-vim/after/syntax/haskell.vim
  9. BIN
      etc/soft/nvim/+plugins/dhall-vim/dhall-syntax.png
  10. 39
      etc/soft/nvim/+plugins/dhall-vim/doc/dhall.txt
  11. 1
      etc/soft/nvim/+plugins/dhall-vim/ftdetect/dhall.vim
  12. 43
      etc/soft/nvim/+plugins/dhall-vim/ftplugin/dhall.vim
  13. 64
      etc/soft/nvim/+plugins/dhall-vim/syntax/dhall.vim
  14. 13
      etc/soft/nvim/after/syntax/haskell.vim
  15. 1
      etc/soft/nvim/ftdetect/detect.vim
  16. 1
      etc/soft/nvim/ftplugin/dhall/dhall.custom.vim
  17. 1
      etc/soft/nvim/ftplugin/diff/diff.custom.vim
  18. 1
      etc/soft/nvim/ftplugin/git/git.custom.vim
  19. 64
      etc/soft/nvim/syntax/dhall.vim
  20. 1
      etc/soft/nvim/vimrc

43
etc/soft/nvim/+ftplugin/dhall.vim

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
if exists('b:dhall_ftplugin')
finish
endif
let b:dhall_ftplugin = 1
setlocal commentstring=--\ %s
set smarttab
if exists('g:dhall_use_ctags')
if g:dhall_use_ctags == 1
autocmd BufWritePost *.dhall silent !ctags -R .
endif
endif
function! StripTrailingWhitespace()
let myline=line('.')
let mycolumn = col('.')
exec 'silent %s/ *$//'
call cursor(myline, mycolumn)
endfunction
if exists('g:dhall_strip_whitespace')
if g:dhall_strip_whitespace == 1
au BufWritePre *.dhall silent! call StripTrailingWhitespace()
endif
endif
function! DhallFormat()
let cursor = getpos('.')
exec 'normal! gg'
exec 'silent !dhall format ' . expand('%')
exec 'e'
call setpos('.', cursor)
endfunction
if exists('g:dhall_format')
if g:dhall_format == 1
au BufWritePost *.dhall call DhallFormat()
endif
endif
au BufNewFile,BufRead *.dhall setl shiftwidth=2

1
etc/soft/nvim/+ftplugin/diff.vim

@ -0,0 +1 @@ @@ -0,0 +1 @@
git.vim

2
etc/soft/nvim/+ftplugin/dockerfile.vim

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
command! DockerBuild execute ":split term://DOCKER_BUILDKIT=1 docker build ."
command! DockerBuild execute ":split term://DOCKER_BUILDKIT=1 docker build -f % ."
command! DockerDive execute ":split term://dive " . expand("<cword>")
command! DockerRun execute ":split term://docker run -it " . expand("<cword>")

3
etc/soft/nvim/+ftplugin/git.vim

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
hi diffAdded ctermfg=black ctermbg=157
hi diffChanged ctermbg=229
hi diffRemoved ctermfg=1 ctermbg=225

169
etc/soft/nvim/+ftplugin/haskell.vim

@ -1,7 +1,12 @@ @@ -1,7 +1,12 @@
set makeprg=ghc\ %\ -o\ %< " Компилятор
runtime syntax/custom/HaskellConceal.vim
set expandtab
set tabstop=8
set shiftwidth=8
set formatprg=stylish-haskell
runtime syntax/custom/HaskellConceal.vim
" =============================================================================
" Descriptions: Provide a function providing folding information for haskell
@ -129,3 +134,165 @@ setlocal foldexpr=HaskellFold(v:lnum) @@ -129,3 +134,165 @@ setlocal foldexpr=HaskellFold(v:lnum)
setlocal foldtext=HaskellFoldText()
setlocal foldmethod=expr
" =============================================================================
" vim-pointfree depends on
" [pointfree](https://hackage.haskell.org/package/pointfree), so make sure that
" it is installed and available in your $PATH.
"
" 'm00qek/vim-pointfree'
" =============================================================================
if exists('g:haskell_pointfree')
finish
endif
let g:haskell_pointfree = 1
function! HaskellPointfreeLineCoordinates()
return { 'line': line('.') }
endfunction
function! HaskellPointfreeLineApply(pointfree_window, coordinates)
let l:current_line = getline(a:firstline, a:lastline)
call HaskellPointfreeWindowClose(a:pointfree_window)
call setline(a:coordinates.line, l:current_line)
endfunction
function! HaskellPointfreeLineApply_command(window, coordinates)
return "HaskellPointfreeLineApply(" . a:window . ", " . string(a:coordinates). ")"
endfunction
function! HaskellPointfreeLineExpression(coordinates)
return join(getline(a:firstline, a:lastline), "\n")
endfunction
function! HaskellPointfreeVisualCoordinates()
let [start_line, start_column] = getpos("'<")[1:2]
let [end_line, end_column] = getpos("'>")[1:2]
return { 'start_line': start_line,
\ 'start_column': start_column,
\ 'end_line': end_line,
\ 'end_column': end_column
\ }
endfunction
function! HaskellPointfreeVisualApply(pointfree_window, coordinates)
let l:current_line = getline(a:firstline, a:lastline)[0]
let l:hreg = getreg("h")
call setreg("h", trim(l:current_line))
call HaskellPointfreeWindowClose(a:pointfree_window)
call setpos("'<", [ a:pointfree_window
\ , a:coordinates.start_line
\ , a:coordinates.start_column ])
call setpos("'>", [ a:pointfree_window
\ , a:coordinates.end_line
\ , a:coordinates.end_column ])
normal! gv"hp
call setreg("h", l:hreg)
endfunction
function! HaskellPointfreeVisualApply_command(window, coordinates)
return "HaskellPointfreeVisualApply(" . a:window . ", " . string(a:coordinates). ")"
endfunction
function! HaskellPointfreeVisualExpression(coordinates)
let lines = getline(a:coordinates.start_line, a:coordinates.end_line)
if len(lines) == 0
return ''
endif
let l:start = a:coordinates.start_column - 1
let l:end = a:coordinates.end_column - (&selection == 'inclusive' ? 1 : 2)
let lines[0] = lines[0][l:start :]
let lines[-1] = lines[-1][: l:end]
return join(lines, "\n")
endfunction
function! s:close_if_pointfree(winnr)
if &l:filetype == 'haskell.pointfree'
silent bdelete!
endif
endfunction
function! s:nmap(key, func)
execute 'nnoremap <silent> <buffer> ' . a:key . ' :call ' . a:func . '<CR>'
endfunction
function! HaskellPointfreeWindowClose(window)
silent windo call s:close_if_pointfree(winnr())
call win_gotoid(a:window)
endfunction
function! HaskellPointfreeWindowOpen(current_window, suggestions, writer)
execute 'silent botright 10new'
call setline(1, a:suggestions)
setlocal readonly nomodifiable
setlocal nonumber
let &l:filetype = 'haskell.pointfree'
setlocal syntax=haskell
call s:nmap('<CR>' , a:writer)
call s:nmap('<Esc>', 'HaskellPointfreeWindowClose(' . a:current_window . ")")
endfunction
function! s:pointfree(expression)
let l:suggestions = system('pointfree --verbose '.shellescape(a:expression))
let l:suggestions = split(l:suggestions, "\n")[3:]
if v:shell_error == 0
return [v:true, insert(l:suggestions, a:expression)]
endif
return [v:false, "Sorry, I couldn't pointfree your expression :("]
endfunction
function! s:pointfree_window(Expression, Writer, coordinates)
let l:current_window = win_getid()
let [l:success, l:suggestions] = s:pointfree(a:Expression(a:coordinates))
if l:success
call HaskellPointfreeWindowOpen(l:current_window,
\ l:suggestions,
\ a:Writer(l:current_window, a:coordinates))
else
echoerr l:suggestions
endif
endfunction
function! HaskellPointfreeOptmized(expression)
let [l:success, l:suggestions] = s:pointfree(a:expression)
if l:success
return l:suggestions[-1]
else
echoerr l:suggestions
endif
endfunction
function! HaskellPointfreeSelection()
call s:pointfree_window(function('HaskellPointfreeVisualExpression'),
\ function('HaskellPointfreeVisualApply_command'),
\ HaskellPointfreeVisualCoordinates())
endfunction
function! HaskellPointfreeSuggestions()
call s:pointfree_window(function('HaskellPointfreeLineExpression'),
\ function('HaskellPointfreeLineApply_command'),
\ HaskellPointfreeLineCoordinates())
endfunction
nnoremap <silent> <Leader>. :call HaskellPointfreeSuggestions()<CR>
vnoremap <silent> <Leader>. :call HaskellPointfreeSelection()<CR>
" =============================================================================

11
etc/soft/nvim/+plugins/dhall-vim/LICENSE

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
Copyright Vanessa McHale (c) 2018
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

15
etc/soft/nvim/+plugins/dhall-vim/README.md

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
# dhall-vim
This package provides syntax highlighting for
[Dhall](https://hackage.haskell.org/package/dhall), a configuration language.
## Installation
Using [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'vmchale/dhall-vim'
```
## Screenshot
![Syntax highlighting demonstration](https://github.com/vmchale/dhall-vim/raw/master/dhall-syntax.png)

13
etc/soft/nvim/+plugins/dhall-vim/after/syntax/haskell.vim

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
" store and remove current syntax value
let old_syntax = b:current_syntax
unlet b:current_syntax
syn include @dhall syntax/dhall.vim
unlet b:current_syntax
syn region dhallBlock matchgroup=quasiQuote start=/\[\$\?staticDhallExpression|/ end=/|\]/ contains=@dhall
hi def link quasiQuote Underlined
" restore current syntax value
let b:current_syntax = old_syntax

BIN
etc/soft/nvim/+plugins/dhall-vim/dhall-syntax.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

39
etc/soft/nvim/+plugins/dhall-vim/doc/dhall.txt

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
*dhall* Dhall syntax highlighting for Vim
____
=====================================================================
CONTENTS *DhallContents*
1. Config ......................................... ❘DhallConfig❘
2. License ....................................... ❘DhallLicense❘
======================================================================
Section 1: Config *DhallConfig*
----------------------------------------------------------------------
*'g:dhall_use_ctags'*
Values: 0, 1
Default: ''
Generate tags file for vim on write, using universal ctags. >
let g:dhall_use_ctags=1
<
*'g:dhall_format'*
Values: 0, 1
Default: ''
Format Dhall files on write >
let g:dhall_format=1
<
*'g:dhall_strip_whitespace'*
Values: 0, 1
Default: ''
To enable whitespace stripping >
let g:dhall_strip_whitespace=1
<
======================================================================
Section 2: License *DhallLicense*
This plugin is licensed under the BDS3 license.

1
etc/soft/nvim/+plugins/dhall-vim/ftdetect/dhall.vim

@ -0,0 +1 @@ @@ -0,0 +1 @@
autocmd BufNewFile,BufRead *.dhall set filetype=dhall

43
etc/soft/nvim/+plugins/dhall-vim/ftplugin/dhall.vim

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
if exists('b:dhall_ftplugin')
finish
endif
let b:dhall_ftplugin = 1
setlocal commentstring=--\ %s
set smarttab
if exists('g:dhall_use_ctags')
if g:dhall_use_ctags == 1
autocmd BufWritePost *.dhall silent !ctags -R .
endif
endif
function! StripTrailingWhitespace()
let myline=line('.')
let mycolumn = col('.')
exec 'silent %s/ *$//'
call cursor(myline, mycolumn)
endfunction
if exists('g:dhall_strip_whitespace')
if g:dhall_strip_whitespace == 1
au BufWritePre *.dhall silent! call StripTrailingWhitespace()
endif
endif
function! DhallFormat()
let cursor = getpos('.')
exec 'normal! gg'
exec 'silent !dhall format ' . expand('%')
exec 'e'
call setpos('.', cursor)
endfunction
if exists('g:dhall_format')
if g:dhall_format == 1
au BufWritePost *.dhall call DhallFormat()
endif
endif
au BufNewFile,BufRead *.dhall setl shiftwidth=2

64
etc/soft/nvim/+plugins/dhall-vim/syntax/dhall.vim

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
scriptencoding utf-8
if exists('b:current_syntax')
finish
endif
syntax match dhallInterpolation "\v\$\{([^\}]|\n)*\}"
syntax keyword dhallTodo TODO FIXME
syntax match dhallBrackets "[<>|]"
syntax match dhallOperator "+\|*\|#"
syntax match dhallOperator "//\|⫽"
syntax match dhallOperator "/\\\|∧"
syntax match dhallOperator "//\\\\\|⩓"
syntax match dhallNumber "\v[0-9]"
syntax match dhallNumber "\v\+[0-9]"
syntax match dhallIndex "\v\@[0-9]+" contains=dhallNumber
syntax match dhallLambda "∀\|λ\|→\|->\|\\"
syntax match dhallType "\v[A-Z][a-z0-9A-Z_]*"
syntax match dhallSpecialLabel "\v`[A-Z][a-z]*`"
syntax match dhallLabel "\v[A-Z][a-z]*/[a-z_][A-Za-z0-9\.\-]*"
syntax match dhallLabel "\v[a-z_][A-Za-z0-9\-]*"
syntax match dhallType "\v[a-zA-Z]+\.[A-Z][a-z0-9A-Z_]*"
syntax match dhallParens "(\|)\|\[\|\]\|,"
syntax match dhallRecord "{\|}\|:"
syntax keyword dhallKeyword let in forall constructors if then else merge env as with
syntax match dhallEsc +\\["\\abfnrtv$/]+
syntax match dhallSingleSpecial +'''+
syntax match dhallSingleSpecial +''${+
syntax match dhallComment '\v--.*$' contains=@Spell,dhallTodo
syntax region dhallMultilineComment start="{-" end="-}" contains=@Spell,dhallTodo,dhallMultilineComment
syntax match dhallUrl "https://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "http://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "/[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\.\./[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\./[a-zA-Z0-9/.\-_]*"
syntax region dhallString start=+''+ end=+''+ contains=@Spell,dhallInterpolation,dhallSingleSpecial
syntax region dhallString start=+"+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax region dhallString start=+"/+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax keyword dhallBool True False
syntax match dhallHash "sha256:[a-f0-9]+"
highlight link dhallSingleSpecial Special
highlight link dhallIndex Special
highlight link dhallSpecialLabel Operator
highlight link dhallEsc Special
highlight link dhallInterpolation Special
highlight link dhallTodo Todo
highlight link dhallBrackets Operator
highlight link dhallBool Underlined
highlight link dhallUrl String
highlight link dhallOperator Operator
highlight link dhallNumber Number
highlight link dhallLambda Special
highlight link dhallString String
highlight link dhallLabel Identifier
highlight link dhallRecord Special
highlight link dhallKeyword Keyword
highlight link dhallType Structure
highlight link dhallParens Special
highlight link dhallComment Comment
highlight link dhallMultilineComment Comment
highlight link dhallHash Keyword
let b:current_syntax = 'dhall'

13
etc/soft/nvim/after/syntax/haskell.vim

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
" store and remove current syntax value
let old_syntax = b:current_syntax
unlet b:current_syntax
syn include @dhall syntax/dhall.vim
unlet b:current_syntax
syn region dhallBlock matchgroup=quasiQuote start=/\[\$\?staticDhallExpression|/ end=/|\]/ contains=@dhall
hi def link quasiQuote Underlined
" restore current syntax value
let b:current_syntax = old_syntax

1
etc/soft/nvim/ftdetect/detect.vim

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
au BufRead,BufNewFile *.dhall setlocal filetype=dhall
au BufRead,BufNewFile *.gv setlocal filetype=graphviz
au BufRead,BufNewFile *.lisp,*.scm setlocal lisp
au BufRead,BufNewFile *.mutt setlocal filetype=muttrc

1
etc/soft/nvim/ftplugin/dhall/dhall.custom.vim

@ -0,0 +1 @@ @@ -0,0 +1 @@
../../+ftplugin/dhall.vim

1
etc/soft/nvim/ftplugin/diff/diff.custom.vim

@ -0,0 +1 @@ @@ -0,0 +1 @@
../../+ftplugin/diff.vim

1
etc/soft/nvim/ftplugin/git/git.custom.vim

@ -0,0 +1 @@ @@ -0,0 +1 @@
../../+ftplugin/git.vim

64
etc/soft/nvim/syntax/dhall.vim

@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
scriptencoding utf-8
if exists('b:current_syntax')
finish
endif
syntax match dhallInterpolation "\v\$\{([^\}]|\n)*\}"
syntax keyword dhallTodo TODO FIXME
syntax match dhallBrackets "[<>|]"
syntax match dhallOperator "+\|*\|#"
syntax match dhallOperator "//\|⫽"
syntax match dhallOperator "/\\\|∧"
syntax match dhallOperator "//\\\\\|⩓"
syntax match dhallNumber "\v[0-9]"
syntax match dhallNumber "\v\+[0-9]"
syntax match dhallIndex "\v\@[0-9]+" contains=dhallNumber
syntax match dhallLambda "∀\|λ\|→\|->\|\\"
syntax match dhallType "\v[A-Z][a-z0-9A-Z_]*"
syntax match dhallSpecialLabel "\v`[A-Z][a-z]*`"
syntax match dhallLabel "\v[A-Z][a-z]*/[a-z_][A-Za-z0-9\.\-]*"
syntax match dhallLabel "\v[a-z_][A-Za-z0-9\-]*"
syntax match dhallType "\v[a-zA-Z]+\.[A-Z][a-z0-9A-Z_]*"
syntax match dhallParens "(\|)\|\[\|\]\|,"
syntax match dhallRecord "{\|}\|:"
syntax keyword dhallKeyword let in forall constructors if then else merge env as with
syntax match dhallEsc +\\["\\abfnrtv$/]+
syntax match dhallSingleSpecial +'''+
syntax match dhallSingleSpecial +''${+
syntax match dhallComment '\v--.*$' contains=@Spell,dhallTodo
syntax region dhallMultilineComment start="{-" end="-}" contains=@Spell,dhallTodo,dhallMultilineComment
syntax match dhallUrl "https://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "http://[a-zA-Z0-9/.\-_\?\=\&]*"
syntax match dhallUrl "/[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\.\./[a-zA-Z0-9/.\-_]*"
syntax match dhallUrl "\./[a-zA-Z0-9/.\-_]*"
syntax region dhallString start=+''+ end=+''+ contains=@Spell,dhallInterpolation,dhallSingleSpecial
syntax region dhallString start=+"+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax region dhallString start=+"/+ end=+"+ contains=dhallInterpolation,dhallEsc
syntax keyword dhallBool True False
syntax match dhallHash "sha256:[a-f0-9]+"
highlight link dhallSingleSpecial Number
highlight link dhallIndex Number
highlight link dhallSpecialLabel Operator
highlight link dhallEsc Number
highlight link dhallInterpolation Statement
highlight link dhallTodo Todo
highlight link dhallBrackets Operator
highlight link dhallBool Boolean
highlight link dhallUrl Statement
highlight link dhallOperator Operator
highlight link dhallNumber Number
highlight link dhallLambda Number
highlight link dhallString String
highlight link dhallLabel Identifier
highlight link dhallRecord Number
highlight link dhallKeyword Function
highlight link dhallType Type
highlight link dhallParens Number
highlight link dhallComment Comment
highlight link dhallMultilineComment Comment
highlight link dhallHash Keyword
let b:current_syntax = 'dhall'

1
etc/soft/nvim/vimrc

@ -104,6 +104,7 @@ set listchars=tab:▸·,space:·,nbsp:␣,trail:+,eol:¶,precedes:«,extends:» @@ -104,6 +104,7 @@ set listchars=tab:▸·,space:·,nbsp:␣,trail:+,eol:¶,precedes:«,extends:»
" {{{-------------------------- Настройка отступов -----------------------------
filetype plugin indent on
set autoindent " Автоматическая расстановка отступов
set smartindent " Умная расстановка отступов
set cindent " Умная расстановка отступов

Loading…
Cancel
Save