Do a minimal config

This commit is contained in:
Julian Ospald 2018-06-16 01:21:55 +02:00
parent a356fa835c
commit 27715932d6
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
68 changed files with 2 additions and 26727 deletions

10
.gitignore vendored
View File

@ -1,10 +0,0 @@
/.VimballRecord
/.mypy_cache/
/.netrwbook
/.netrwhist
/.ycm_extra_conf.pyc
/doc/tags
/haskellmode.config
/hotkeys
/log.vim
/plugged/

View File

@ -1,154 +0,0 @@
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c',
'-isystem',
'../BoostParts',
'-isystem',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'/System/Library/Frameworks/Python.framework/Headers',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'./ClangCompleter',
'-isystem',
'./tests/gmock/gtest',
'-isystem',
'./tests/gmock/gtest/include',
'-isystem',
'./tests/gmock',
'-isystem',
'./tests/gmock/include'
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if compilation_database_folder:
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def FlagsForFile( filename ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = database.GetCompilationInfoForFile( filename )
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}

View File

@ -1,25 +0,0 @@
let g:ale_linters = {'c':['clang', 'clangtidy', 'cppcheck']}
" let g:ale_linters = {'c':['clang']}
"let g:ale_fixers = {
" \ 'c': ['clang-format'],
" \}
let g:ale_c_clangformat_options = '-style=file'
let g:ycm_goto_buffer_command = 'same-buffer'
nnoremap <F3> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> <F4> :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F7> :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> <F6> :call LanguageClient#textDocument_rename()<CR>
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'c': ['cquery', '--language-server', '--log-file=/tmp/cq.log'],
\ }
let g:LanguageClient_rootMarkers = {
\ 'c': ['.cquery', 'compile_commands.json', 'build'],
\ }
let g:LanguageClient_settingsPath = $HOME.'/.vim/cquery.json'

View File

@ -1,7 +0,0 @@
call CmdAlias('Piggie','Piggieback (figwheel-sidecar.repl-api/repl-env)')
let g:rainbow_active = 1
let g:ScreenImpl = 'Tmux'
let g:sexp_enable_insert_mode_mappings = 0

View File

@ -1,67 +0,0 @@
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
let g:go_auto_type_info = 0
" mappings
noremap <C-B> :TagbarToggle<CR>
inoremap <C-B> <C-O>:TagbarToggle<CR>
nmap <F3> :GoInfo<CR>
function! MakePublic()
let l:wordUnderCursor = expand('<cword>')
let l:upperCaseWord = substitute(l:wordUnderCursor, '[A-Za-z]', '\\U&', '')
execute 'GoRename ' l:upperCaseWord
endfunction
nmap <F6> :GoDocBrowser<CR><CR>
nmap <F7> :GoDoc<CR>
nmap <F8> :call MakePublic()<CR><CR>
" ALE
" let g:ale_linters = {'go':['gofmt', "go build"], 'c':['clang']}
let g:ale_linters = {'go':['go build', 'gometalinter', 'gofmt'], 'c':['clang']}
let g:ale_fixers = {
\ 'go': ['gofmt', 'goimports'],
\ 'c': ['clang-format'],
\ 'cpp': ['clang-format'],
\ 'js': ['eslint'],
\ 'python': ['yapf'],
\}
let g:ale_go_gobuild_options = "-gcflags='-e'"
let g:ale_go_gometalinter_options = '--fast'
" vim-go
let g:go_highlight_functions = 1
let g:go_highlight_space_tab_error = 1
let g:go_highlight_chan_whitespace_error = 1

View File

@ -1,139 +0,0 @@
setlocal ts=2 sw=2 expandtab
"set background=light
"set guifont=Neep\ Medium\ Semi-Condensed\ 18
syntax on
filetype plugin indent on
call CmdAlias('hasktags', '!/home/jule/.cabal/bin/hasktags -c .<CR>')
" haskell-vim
let g:haskell_classic_highlighting = 1
let g:haskell_indent_disable = 1
" let g:haskell_enable_quantification = 1
" let g:haskell_enable_recursivedo = 1
" let g:haskell_enable_arrowsyntax = 1
" let g:haskell_enable_pattern_synonyms = 1
" let g:haskell_enable_typeroles = 1
" let g:haskell_indent_if = 3
" let g:haskell_indent_case = 5
" let g:haskell_indent_let = 4
" let g:haskell_indent_where = 6
" let g:haskell_indent_do = 3
" let g:haskell_indent_in = 1
" haskellmode-vim
function! HaskellDocCurrentWord()
let word = expand("<cword>")
exe "IDoc " . word
endfunction
" done by LSP now
nmap <F7> :call HaskellDocCurrentWord()<CR><CR>
nmap <silent> <F3> :silent update <bar> HsimportModule<CR>
nmap <silent> <F4> :silent update <bar> HsimportSymbol<CR>
" liquid-types
let g:vim_annotations_offset = '/.liquid/'
" autocmd BufWritePost *.hs call s:check_and_lint()
" function! s:check_and_lint()
" let l:path = expand('%:p')
" let l:qflist = ghcmod#make('check', l:path)
" call extend(l:qflist, ghcmod#make('lint', l:path))
" call setqflist(l:qflist)
" cwindow
" if empty(l:qflist)
" echo "No errors found"
" endif
" endfunction
" LSP
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'haskell': ['hie', '--lsp', '-d', '-l', $HOME.'/lang-server.log'],
\ }
" we use ALE instead
let g:LanguageClient_diagnosticsEnable = 0
nnoremap <leader>lc :call LanguageClient_contextMenu()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <C-F6> :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> <F8> :call LanguageClient#textDocument_rename()<CR>
" deoplete
call deoplete#custom#option('sources',{
\ '_': ['buffer'],
\ 'haskell': ['neosnippet', 'buffer', 'file', 'LanguageClient']
\ })
" inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
call deoplete#enable()
let g:ghcmod_hlint_options = ['--ignore=Eta reduce $']
" ALE
let g:ale_enabled = 1
let g:ale_linters = {'haskell':['ghc-mod', 'hdevtools'], 'c':['clang']}
" let g:ale_fixers = {
" \ 'go': ['gofmt', 'goimports'],
" \}
let g:ale_haskell_hdevtools_options = "-g '-Wall' -g '-Wno-orphans'"
" completion
"
" neco-ghc
" let g:necoghc_enable_detailed_browse = 1
" let g:haskellmode_completion_ghc = 0
" let g:necoghc_enable_detailed_browse = 1
" autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
" let g:ycm_semantic_triggers = {'haskell' : ['.']}
" clear search
nmap <F2> :noh<CR>:GhcModTypeClear<CR>
imap <F2> <C-O>:noh<CR>:GhcModTypeClear<CR>
" unmap <F3>
" unmap <F4>
nmap <F6> :GhcModType<CR>
" for intero
" if has("nvim")
" let g:ale_enabled = 0
" " let g:intero_backend = {
" " \ 'command': 'cabal new-repl',
" " \ 'options': '',
" " \ 'cwd': expand('%:p:h'),
" " \}
" " Intero starts automatically. Set this if you'd like to prevent that.
" let g:intero_start_immediately = 1
" " Enable type information on hover (when holding cursor at point for ~1 second).
" let g:intero_type_on_hover = 1
" " Change the intero window size; default is 10.
" let g:intero_window_size = 15
" " Sets the intero window to split vertically; default is horizontal
" let g:intero_vertical_split = 1
" " OPTIONAL: Make the update time shorter, so the type info will trigger faster.
" set updatetime=1000
" map <silent> <leader>t <Plug>InteroGenericType
" endif

View File

@ -1,44 +0,0 @@
let g:tagbar_ctags_bin = '/usr/bin/universal-ctags'
let g:rust_doc#define_map_K = 0
let g:rust_doc#downloaded_rust_doc_dir = '~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu'
function! s:search_under_cursor(query) range
if a:query ==# ''
echomsg "rust-doc: No identifier is found under the cursor"
return
endif
call rust_doc#open_fuzzy(a:query)
endfunction
" keys
nnoremap <buffer><silent><F7> :<C-u>call <SID>search_under_cursor(expand('<cword>'))<CR>
vnoremap <buffer><silent><F7> "gy:call <SID>search_under_cursor(getreg('g'))<CR>
nnoremap <F3> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> <F4> :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F6> :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> <F8> :call LanguageClient#textDocument_rename()<CR>
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'] }
let g:LanguageClient_diagnosticsEnable = 0
let g:ale_linters = {'rust': ['rls']}
let g:ale_fixers = { 'rust': ['rustfmt'] }
let g:ale_fix_on_save = 0
let g:autofmt_autosave = 0
" deoplete
call deoplete#custom#option('sources',{
\ '_': ['buffer'],
\ 'rust': ['ultisnips', 'buffer', 'file', 'LanguageClient']
\ })
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
call deoplete#enable()

View File

@ -1,5 +0,0 @@
{
"initializationOptions": {
"cacheDirectory": "/tmp/cquery"
}
}

View File

@ -1,14 +0,0 @@
let g:ale_open_list = 0
let g:ale_set_quickfix = 0
let g:ale_set_loclist = 1
let g:ale_fix_on_save = 1
let g:ale_lint_delay = 100
highlight clear ALEWarningSign
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
let g:ale_sign_column_always = 1
let g:ale_quiet_messages = { 'sub_type': 'style' }
"Lint only on save
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 1

View File

@ -1,2 +0,0 @@
au BufNewFile,BufRead *.log setf log

View File

@ -1,152 +0,0 @@
nnoremap <SPACE> <Nop>
let g:mapleader = ' '
" easy config
nmap <S-F9> :e $HOME/.vimrc<CR>
nmap <S-F10> :so $HOME/.vimrc<CR>
" Force saving files that require root permission
command! SUDOwrite :execute 'w !sudo tee > /dev/null %' | edit!
" Bubble single lines
nmap <silent> <C-S-Up> :m-2<CR>==
nmap <silent> <C-S-Down> :m+<CR>==
imap <silent> <C-S-Up> <Esc>:m-2<CR>==gi
imap <silent> <C-S-Down> <Esc>:m+<CR>==gi
" Bubble multiple lines
vmap <silent> <C-S-Up> :m-2<CR>gv=gv
vmap <silent> <C-S-Down> :m'>+<CR>gv=gv
" Indent lines using <Left> and <Right>
vmap <C-S-Right> >gv
nmap <C-S-Right> >>
imap <C-S-Right> <Esc>>>i
vmap <C-S-Left> <gv
nmap <C-S-Left> <<
imap <C-S-Left> <Esc><<i
" moving through location list items
" noremap <S-Up> :lprevious<CR>
" noremap <S-Down> :lnext<CR>
" moving through buffers
" noremap <S-Left> :bn<CR>
" noremap <S-Right> :bp<CR>
noremap <leader>bd <Esc>:bd<CR>
noremap <leader>wc <Esc>:bd<CR>
noremap <leader>bo <Esc>:Bufonly<CR>
" Remap window commands
" map <leader>ws <Esc>:wincmd s<CR>
" map <leader>wv <Esc>:wincmd v<CR>
" map <leader>wc <Esc>:wincmd c<CR>
" map <leader>wn <Esc>:wincmd n<CR>
" map <leader>wo <Esc>:wincmd o<CR>
" map <leader>w+ <Esc>:wincmd _<CR>
" map <leader>w- <Esc>:wincmd <Bar><CR>
" map <leader>w= <Esc>:wincmd =<CR>
" nmap + :vertical resize +20<CR>
" nmap - :vertical resize -20<CR>
" map <C-S--> <Esc>:wincmd ><CR>
" map <C-Down> <Esc>:wincmd j<CR>
" map <C-j> <Esc>:wincmd j<CR>
" map <C-Up> <Esc>:wincmd k<CR>
" map <C-k> <Esc>:wincmd k<CR>
" map <C-Left> <Esc>:wincmd h<CR>
" map <C-h> <Esc>:wincmd h<CR>
" map <C-Right> <Esc>:wincmd l<CR>
" map <C-l> <Esc>:wincmd l<CR>
nnoremap <silent> <A-i> :wincmd K<CR>
nnoremap <silent> <A-k> :wincmd J<CR>
nnoremap <silent> <A-j> :wincmd H<CR>
nnoremap <silent> <A-l> :wincmd L<CR>
nnoremap <silent> <A-Up> :wincmd k<CR>
nnoremap <silent> <A-Down> :wincmd j<CR>
nnoremap <silent> <A-Left> :wincmd h<CR>
nnoremap <silent> <A-Right> :wincmd l<CR>
inoremap <silent> <A-Up> <Esc>:wincmd k<CR>
inoremap <silent> <A-Down> <Esc>:wincmd j<CR>
inoremap <silent> <A-Left> <Esc>:wincmd h<CR>
inoremap <silent> <A-Right> <Esc>:wincmd l<CR>
" tags
nmap <S-F3> :exec("tjump ".expand("<cword>"))<CR>
nmap <S-F4> :split<CR>:exec("tjump ".expand("<cword>"))<CR>
" trigger NERDTree, Tagbar $ Co.
nmap <leader>n <Esc>:NERDTreeToggle<CR>
nmap <leader>t <Esc>:TagbarToggle<CR>
" nmap <leader>f "zyaw :exe ":Ack ".@z.""<CR>
nmap <C-f> :CtrlP<CR>
nmap <C-t> :CtrlPTag<CR>
nmap <C-b> :CtrlPBuffer<CR>
" grep word under cursor
nnoremap <silent><leader>f :lgr! "\b<C-R><C-W>\b"<CR>:cw<CR>
" paste from system clipboard
inoremap <silent> <S-Insert> <ESC>:set paste<CR>"+p :set nopaste<CR>
" toggle spellcheck
nmap <silent> <S-F7> :setlocal spell! spelllang=en_us<CR>
" cursor jump
nnoremap <S-Up> 3k
inoremap <S-Up> <Esc>:-3<CR>i
vnoremap <S-Up> 3k
nnoremap <S-Down> 3j
inoremap <S-Down> <Esc>:+3<CR>i
vnoremap <S-Down> 3j
nnoremap <C-Up> 6k
inoremap <C-Up> <Esc>:-6<CR>i
vnoremap <C-Up> 6k
nnoremap <C-Down> 6j
inoremap <C-Down> <Esc>:+6<CR>i
vnoremap <C-Down> 6j
" scrolling
nnoremap <S-PageUp> 10<C-Y>
inoremap <S-PageUp> <Esc>10<C-Y>i
vnoremap <S-PageUp> 10<C-Y>
nnoremap <S-PageDown> 10<C-E>
inoremap <S-PageDown> <Esc>10<C-E>i
vnoremap <S-PageDown> 10<C-E>
" F keys
nmap <F2> :noh<CR>
imap <F2> <C-O>:noh<CR>
nmap <F3> :YcmCompleter GoToDeclaration<CR>
nmap <F4> :YcmCompleter GoTo<CR>
nmap <C-F4> :YcmCompleter GoTo<CR>:wincmd o<CR>
noremap <F5> :FufBuffer<CR>
nmap <F7> :call ManCurrentWord()<CR><CR>
nmap <F8> :call DevHelpCurrentWord()<CR><CR>
nnoremap <silent> <F10> :call NERDComment("n", "Toggle")<cr>
vnoremap <silent> <F10> <ESC>:call NERDComment("v", "Toggle")<cr>
" nmap <F4> <C-]>
" plugins etc
noremap <C-F> :NERDTreeToggle<CR>
noremap <C-B> :TagbarToggle<CR>
inoremap <C-B> <C-O>:TagbarToggle<CR>
" remap visual block
nnoremap <S-B> <c-v>
" write
noremap <C-s> :w<CR>
inoremap <C-s> <C-O>:w<CR>
" exit
noremap <C-q> :qa!<CR>
inoremap <C-q> <C-O>:qa!<CR>
" paste
nnoremap <C-V> "+gPl
vnoremap <C-V> :<C-U>call Paste("v")<CR>
inoremap <C-V> <C-O>:call Paste("i")<CR>
" select all
nnoremap <C-A> ggVG<CR>
inoremap <C-A> <C-O>:call Select()<CR>

View File

@ -1,379 +0,0 @@
" Vim syntax file
"
" Modification of vims Haskell syntax file:
" - match types using regular expression
" - highlight toplevel functions
" - use "syntax keyword" instead of "syntax match" where appropriate
" - functions and types in import and module declarations are matched
" - removed hs_highlight_more_types (just not needed anymore)
" - enable spell checking in comments and strings only
" - FFI highlighting
" - QuasiQuotation
" - top level Template Haskell slices
" - PackageImport
"
" TODO: find out which vim versions are still supported
"
" From Original file:
" ===================
"
" Language: Haskell
" Maintainer: Haskell Cafe mailinglist <haskell-cafe@haskell.org>
" Last Change: 2010 Feb 21
" Original Author: John Williams <jrw@pobox.com>
"
" Thanks to Ryan Crumley for suggestions and John Meacham for
" pointing out bugs. Also thanks to Ian Lynagh and Donald Bruce Stewart
" for providing the inspiration for the inclusion of the handling
" of C preprocessor directives, and for pointing out a bug in the
" end-of-line comment handling.
"
" Options-assign a value to these variables to turn the option on:
"
" hs_highlight_delimiters - Highlight delimiter characters--users
" with a light-colored background will
" probably want to turn this on.
" hs_highlight_boolean - Treat True and False as keywords.
" hs_highlight_types - Treat names of primitive types as keywords.
" hs_highlight_debug - Highlight names of debugging functions.
" hs_allow_hash_operator - Don't highlight seemingly incorrect C
" preprocessor directives but assume them to be
" operators
"
"
if version < 600
syn clear
elseif exists("b:current_syntax")
finish
endif
"syntax sync fromstart "mmhhhh.... is this really ok to do so?
syntax sync linebreaks=15 minlines=50 maxlines=500
syn match hsSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
syn match hsSpecialChar contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)"
syn match hsSpecialCharError contained "\\&\|'''\+"
sy region hsString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=hsSpecialChar,@Spell
sy match hsCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError
sy match hsCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError
" (Qualified) identifiers (no default highlighting)
syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>"
syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>"
" Infix operators--most punctuation characters and any (qualified) identifier
" enclosed in `backquotes`. An operator starting with : is a constructor,
" others are variables (e.g. functions).
syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*"
syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*"
syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`"
syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`"
" Toplevel Template Haskell support
"sy match hsTHTopLevel "^[a-z]\(\(.\&[^=]\)\|\(\n[^a-zA-Z0-9]\)\)*"
sy match hsTHIDTopLevel "^[a-z]\S*"
sy match hsTHTopLevel "^\$(\?" nextgroup=hsTHTopLevelName
sy match hsTHTopLevelName "[a-z]\S*" contained
" Reserved symbols--cannot be overloaded.
syn match hsDelimiter "(\|)\|\[\|\]\|,\|;\|_\|{\|}"
sy region hsInnerParen start="(" end=")" contained contains=hsInnerParen,hsConSym,hsType,hsVarSym
sy region hs_InfixOpFunctionName start="^(" end=")\s*[^:`]\(\W\&\S\&[^'\"`()[\]{}@]\)\+"re=s
\ contained keepend contains=hsInnerParen,hs_HlInfixOp
sy match hs_hlFunctionName "[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained
sy match hs_FunctionName "^[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained contains=hs_hlFunctionName
sy match hs_HighliteInfixFunctionName "`[a-z_][^`]*`" contained
sy match hs_InfixFunctionName "^\S[^=]*`[a-z_][^`]*`"me=e-1 contained contains=hs_HighliteInfixFunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter
sy match hs_HlInfixOp "\(\W\&\S\&[^`(){}'[\]]\)\+" contained contains=hsString
sy match hs_InfixOpFunctionName "^\(\(\w\|[[\]{}]\)\+\|\(\".*\"\)\|\('.*'\)\)\s*[^:]=*\(\W\&\S\&[^='\"`()[\]{}@]\)\+"
\ contained contains=hs_HlInfixOp,hsCharacter
sy match hs_OpFunctionName "(\(\W\&[^(),\"]\)\+)" contained
"sy region hs_Function start="^["'a-z_([{]" end="=\(\s\|\n\|\w\|[([]\)" keepend extend
sy region hs_Function start="^["'a-zA-Z_([{]\(\(.\&[^=]\)\|\(\n\s\)\)*=" end="\(\s\|\n\|\w\|[([]\)"
\ contains=hs_OpFunctionName,hs_InfixOpFunctionName,hs_InfixFunctionName,hs_FunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter
sy match hs_TypeOp "::"
sy match hs_DeclareFunction "^[a-z_(]\S*\(\s\|\n\)*::" contains=hs_FunctionName,hs_OpFunctionName,hs_TypeOp
" hi hs_TypeOp guibg=red
" hi hs_InfixOpFunctionName guibg=yellow
" hi hs_Function guibg=green
" hi hs_InfixFunctionName guibg=red
" hi hs_DeclareFunction guibg=red
sy keyword hsStructure data family class where instance default deriving
sy keyword hsTypedef type newtype
sy keyword hsInfix infix infixl infixr
sy keyword hsStatement do case of let in
sy keyword hsConditional if then else
"if exists("hs_highlight_types")
" Primitive types from the standard prelude and libraries.
sy match hsType "\<[A-Z]\(\S\&[^,.]\)*\>"
sy match hsType "()"
"endif
" Not real keywords, but close.
if exists("hs_highlight_boolean")
" Boolean constants from the standard prelude.
syn keyword hsBoolean True False
endif
syn region hsPackageString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained
sy match hsModuleName excludenl "\([A-Z]\w*\.\?\)*" contained
sy match hsImport "\<import\>\s\+\(qualified\s\+\)\?\(\<\(\w\|\.\)*\>\)"
\ contains=hsModuleName,hsImportLabel
\ nextgroup=hsImportParams,hsImportIllegal skipwhite
sy keyword hsImportLabel import qualified contained
sy match hsImportIllegal "\w\+" contained
sy keyword hsAsLabel as contained
sy keyword hsHidingLabel hiding contained
sy match hsImportParams "as\s\+\(\w\+\)" contained
\ contains=hsModuleName,hsAsLabel
\ nextgroup=hsImportParams,hsImportIllegal skipwhite
sy match hsImportParams "hiding" contained
\ contains=hsHidingLabel
\ nextgroup=hsImportParams,hsImportIllegal skipwhite
sy region hsImportParams start="(" end=")" contained
\ contains=hsBlockComment,hsLineComment, hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName
\ nextgroup=hsImportIllegal skipwhite
" hi hsImport guibg=red
"hi hsImportParams guibg=bg
"hi hsImportIllegal guibg=bg
"hi hsModuleName guibg=bg
"sy match hsImport "\<import\>\(.\|[^(]\)*\((.*)\)\?"
" \ contains=hsPackageString,hsImportLabel,hsImportMod,hsModuleName,hsImportList
"sy keyword hsImportLabel import contained
"sy keyword hsImportMod as qualified hiding contained
"sy region hsImportListInner start="(" end=")" contained keepend extend contains=hs_OpFunctionName
"sy region hsImportList matchgroup=hsImportListParens start="("rs=s+1 end=")"re=e-1
" \ contained
" \ keepend extend
" \ contains=hsType,hsLineComment,hsBlockComment,hs_hlFunctionName,hsImportListInner
" new module highlighting
syn region hsDelimTypeExport start="\<[A-Z]\(\S\&[^,.]\)*\>(" end=")" contained
\ contains=hsType
sy keyword hsExportModuleLabel module contained
sy match hsExportModule "\<module\>\(\s\|\t\|\n\)*\([A-Z]\w*\.\?\)*" contained contains=hsExportModuleLabel,hsModuleName
sy keyword hsModuleStartLabel module contained
sy keyword hsModuleWhereLabel where contained
syn match hsModuleStart "^module\(\s\|\n\)*\(\<\(\w\|\.\)*\>\)\(\s\|\n\)*"
\ contains=hsModuleStartLabel,hsModuleName
\ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel
syn region hsModuleCommentA start="{-" end="-}"
\ contains=hsModuleCommentA,hsCommentTodo,@Spell contained
\ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl
syn match hsModuleCommentA "--.*\n"
\ contains=hsCommentTodo,@Spell contained
\ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl
syn region hsModuleExports start="(" end=")" contained
\ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
\ contains=hsBlockComment,hsLineComment,hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName,hsExportModule
syn match hsModuleCommentB "--.*\n"
\ contains=hsCommentTodo,@Spell contained
\ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
syn region hsModuleCommentB start="{-" end="-}"
\ contains=hsModuleCommentB,hsCommentTodo,@Spell contained
\ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl
" end module highlighting
" FFI support
sy keyword hsFFIForeign foreign contained
"sy keyword hsFFIImportExport import export contained
sy keyword hsFFIImportExport export contained
sy keyword hsFFICallConvention ccall stdcall contained
sy keyword hsFFISafety safe unsafe contained
sy region hsFFIString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=hsSpecialChar
sy match hsFFI excludenl "\<foreign\>\(.\&[^\"]\)*\"\(.\)*\"\(\s\|\n\)*\(.\)*::"
\ keepend
\ contains=hsFFIForeign,hsFFIImportExport,hsFFICallConvention,hsFFISafety,hsFFIString,hs_OpFunctionName,hs_hlFunctionName
sy match hsNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
sy match hsFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
" Comments
sy keyword hsCommentTodo TODO FIXME XXX TBD contained
sy match hsLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsCommentTodo,@Spell
sy region hsBlockComment start="{-" end="-}" contains=hsBlockComment,hsCommentTodo,@Spell
sy region hsPragma start="{-#" end="#-}"
" Liquid Types
sy region hsLiquidAnnot start="{-@\s*" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy region hsLiquidAnnot start="{-@\s*\<invariant\>" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy region hsLiquidAnnot start="{-@\s*\<predicate\>" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy region hsLiquidAnnot start="{-@\s*\<assert\>" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy region hsLiquidAnnot start="{-@\s*\<type\>" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy region hsLiquidAnnot start="{-@\s*\<data\>" end="@-}" contains=hsLiquidKeyword,hsLiquidReftA,hsLiquidReftB,hsLiquidReftC
sy keyword hsLiquidKeyword assume assert invariant predicate type data contained
sy region hsLiquidReftA start="{\(\s\|\w\)" end=":" contained
sy region hsLiquidReftB start="|" end="}" contained
sy match hsLiquidReftC "\w*:" contained
" QuasiQuotation
sy region hsQQ start="\[\$" end="|\]"me=e-2 keepend contains=hsQQVarID,hsQQContent nextgroup=hsQQEnd
sy region hsQQNew start="\[\(.\&[^|]\&\S\)*|" end="|\]"me=e-2 keepend contains=hsQQVarIDNew,hsQQContent nextgroup=hsQQEnd
sy match hsQQContent ".*" contained
sy match hsQQEnd "|\]" contained
sy match hsQQVarID "\[\$\(.\&[^|]\)*|" contained
sy match hsQQVarIDNew "\[\(.\&[^|]\)*|" contained
if exists("hs_highlight_debug")
" Debugging functions from the standard prelude.
syn keyword hsDebug undefined error trace
endif
" C Preprocessor directives. Shamelessly ripped from c.vim and trimmed
" First, see whether to flag directive-like lines or not
if (!exists("hs_allow_hash_operator"))
syn match cError display "^\s*\(%:\|#\).*$"
endif
" Accept %: for # (C99)
syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCommentError
syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2
syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cCppSkip
syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cCppSkip
syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match cIncluded display contained "<[^>]*>"
syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cCppOut,cCppOut2,cCppSkip,cCommentStartError
syn region cDefine matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$"
syn region cPreProc matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend
syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=cCommentStartError,cSpaceError contained
syntax match cCommentError display "\*/" contained
syntax match cCommentStartError display "/\*"me=e-1 contained
syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained
if version >= 508 || !exists("did_hs_syntax_inits")
if version < 508
let did_hs_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink hs_hlFunctionName Function
HiLink hs_HighliteInfixFunctionName Function
HiLink hs_HlInfixOp Function
HiLink hs_OpFunctionName Function
HiLink hsTypedef Typedef
HiLink hsVarSym hsOperator
HiLink hsConSym hsOperator
if exists("hs_highlight_delimiters")
" Some people find this highlighting distracting.
HiLink hsDelimiter Delimiter
endif
HiLink hsModuleStartLabel Structure
HiLink hsExportModuleLabel Keyword
HiLink hsModuleWhereLabel Structure
HiLink hsModuleName Normal
HiLink hsImportIllegal Error
HiLink hsAsLabel hsImportLabel
HiLink hsHidingLabel hsImportLabel
HiLink hsImportLabel Include
HiLink hsImportMod Include
HiLink hsPackageString hsString
HiLink hsOperator Operator
HiLink hsInfix Keyword
HiLink hsStructure Structure
HiLink hsStatement Statement
HiLink hsConditional Conditional
HiLink hsSpecialCharError Error
HiLink hsSpecialChar SpecialChar
HiLink hsString String
HiLink hsFFIString String
HiLink hsCharacter Character
HiLink hsNumber Number
HiLink hsFloat Float
HiLink hsLiterateComment hsComment
HiLink hsBlockComment hsComment
HiLink hsLineComment hsComment
HiLink hsModuleCommentA hsComment
HiLink hsModuleCommentB hsComment
HiLink hsComment Comment
HiLink hsCommentTodo Todo
HiLink hsPragma SpecialComment
HiLink hsBoolean Boolean
" Liquid Types
HiLink hsLiquidAnnot SpecialComment "String
HiLink hsLiquidKeyword Operator "Float
HiLink hsLiquidReftA Include
HiLink hsLiquidReftB Include
HiLink hsLiquidReftC Include
if exists("hs_highlight_types")
HiLink hsDelimTypeExport hsType
HiLink hsType Type
endif
HiLink hsDebug Debug
HiLink hs_TypeOp hsOperator
HiLink cCppString hsString
HiLink cCommentStart hsComment
HiLink cCommentError hsError
HiLink cCommentStartError hsError
HiLink cInclude Include
HiLink cPreProc PreProc
HiLink cDefine Macro
HiLink cIncluded hsString
HiLink cError Error
HiLink cPreCondit PreCondit
HiLink cComment Comment
HiLink cCppSkip cCppOut
HiLink cCppOut2 cCppOut
HiLink cCppOut Comment
HiLink hsFFIForeign Keyword
HiLink hsFFIImportExport Structure
HiLink hsFFICallConvention Keyword
HiLink hsFFISafety Keyword
HiLink hsTHIDTopLevel Macro
HiLink hsTHTopLevelName Macro
HiLink hsQQVarID Keyword
HiLink hsQQVarIDNew Keyword
HiLink hsQQEnd Keyword
HiLink hsQQContent String
delcommand HiLink
endif
let b:current_syntax = "haskell"

View File

@ -1,105 +0,0 @@
" Protocol Buffers - Google's data interchange format
" Copyright 2008 Google Inc. All rights reserved.
" https://developers.google.com/protocol-buffers/
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are
" met:
"
" * Redistributions of source code must retain the above copyright
" notice, this list of conditions and the following disclaimer.
" * 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.
" * Neither the name of Google Inc. 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
" OWNER 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.
" This is the Vim syntax file for Google Protocol Buffers.
"
" Usage:
"
" 1. cp proto.vim ~/.vim/syntax/
" 2. Add the following to ~/.vimrc:
"
" augroup filetype
" au! BufRead,BufNewFile *.proto setfiletype proto
" augroup end
"
" Or just create a new file called ~/.vim/ftdetect/proto.vim with the
" previous lines on it.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case match
syn keyword pbTodo contained TODO FIXME XXX
syn cluster pbCommentGrp contains=pbTodo
syn keyword pbSyntax syntax import option
syn keyword pbStructure package message group oneof
syn keyword pbRepeat optional required repeated
syn keyword pbDefault default
syn keyword pbExtend extend extensions to max reserved
syn keyword pbRPC service rpc returns
syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
syn keyword pbType float double bool string bytes
syn keyword pbTypedef enum
syn keyword pbBool true false
syn match pbInt /-\?\<\d\+\>/
syn match pbInt /\<0[xX]\x+\>/
syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp
syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp
syn region pbString start=/"/ skip=/\\./ end=/"/
syn region pbString start=/'/ skip=/\\./ end=/'/
if version >= 508 || !exists("did_proto_syn_inits")
if version < 508
let did_proto_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink pbTodo Todo
HiLink pbSyntax Include
HiLink pbStructure Structure
HiLink pbRepeat Repeat
HiLink pbDefault Keyword
HiLink pbExtend Keyword
HiLink pbRPC Keyword
HiLink pbType Type
HiLink pbTypedef Typedef
HiLink pbBool Boolean
HiLink pbInt Number
HiLink pbFloat Float
HiLink pbComment Comment
HiLink pbString String
delcommand HiLink
endif
let b:current_syntax = "proto"

View File

@ -1,570 +0,0 @@
"=============================================================================
" Copyright (c) 2009-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
if exists('g:loaded_autoload_l9')
finish
endif
let g:loaded_autoload_l9 = 1
" }}}1
"=============================================================================
" COMPATIBILITY TEST {{{1
"
let s:L9_VERSION_CURRENT = 101
let s:L9_VERSION_PASSABLE = 101
" returns true if given version is compatible.
function l9#isCompatible(ver)
return
endfunction
let s:VERSION_FACTOR = str2float('0.01')
" returns false if the caller script should finish.
" a:vimVersion: if 0, don't check vim version
" a:l9Version: same rule as v:version
function l9#guardScriptLoading(path, vimVersion, l9Version, exprs)
let loadedVarName = 'g:loaded_' . substitute(a:path, '\W', '_', 'g')
if exists(loadedVarName)
return 0
elseif a:vimVersion > 0 && a:vimVersion > v:version
echoerr a:path . ' requires Vim version ' . string(a:vimVersion * s:VERSION_FACTOR)
return 0
elseif a:l9Version > 0 && (a:l9Version > s:L9_VERSION_CURRENT ||
\ a:l9Version < s:L9_VERSION_PASSABLE)
echoerr a:path . ' requires L9 library version ' . string(a:l9Version * s:VERSION_FACTOR)
return 0
endif
for expr in a:exprs
if !eval(expr)
echoerr a:path . ' requires: ' . expr
return 0
endif
endfor
let {loadedVarName} = 1
return 1
endfunction
"
function l9#getVersion()
return s:L9_VERSION_CURRENT
endfunction
" }}}1
"=============================================================================
" LIST {{{1
" Removes duplicates (unstable)
" This function doesn't change the list of argument.
function l9#unique(items)
let sorted = sort(a:items)
if len(sorted) < 2
return sorted
endif
let last = remove(sorted, 0)
let result = [last]
for item in sorted
if item != last
call add(result, item)
let last = item
endif
endfor
return result
endfunction
" Removes duplicates (stable)
" This function doesn't change the list of argument.
function l9#uniqueStably(items)
let result = []
for item in a:items
if count(result, item, &ignorecase) == 0
call add(result, item)
endif
endfor
return result
endfunction
" [ [0], [1,2], [3] ] -> [ 0, 1, 2, 3 ]
" This function doesn't change the list of argument.
function l9#concat(items)
let result = []
for l in a:items
let result += l
endfor
return result
endfunction
" [ [0,1,2], [3,4], [5,6,7,8] ] -> [ [0,3,5],[1,4,6] ]
" This function doesn't change the list of argument.
function l9#zip(items)
let result = []
for i in range(min(map(copy(a:items), 'len(v:val)')))
call add(result, map(copy(a:items), 'v:val[i]'))
endfor
return result
endfunction
" filter() with the maximum number of items
" This function doesn't change the list of argument.
function l9#filterWithLimit(items, expr, limit)
if a:limit <= 0
return filter(copy(a:items), a:expr)
endif
let result = []
let stride = a:limit * 3 / 2 " x1.5
for i in range(0, len(a:items) - 1, stride)
let result += filter(a:items[i : i + stride - 1], a:expr)
if len(result) >= a:limit
return remove(result, 0, a:limit - 1)
endif
endfor
return result
endfunction
" Removes if a:expr is evaluated as non-zero and returns removed items.
" This function change the list of argument.
function l9#removeIf(items, expr)
let removed = filter(copy(a:items), a:expr)
call filter(a:items, '!( ' . a:expr . ')')
return removed
endfunction
" }}}1
"=============================================================================
" NUMERIC {{{1
" }}}1
"=============================================================================
" STRING {{{1
" Snips a:str and add a:mask if the length of a:str is more than a:len
function l9#snipHead(str, len, mask)
if a:len >= len(a:str)
return a:str
elseif a:len <= len(a:mask)
return a:mask
endif
return a:mask . a:str[-a:len + len(a:mask):]
endfunction
" Snips a:str and add a:mask if the length of a:str is more than a:len
function l9#snipTail(str, len, mask)
if a:len >= len(a:str)
return a:str
elseif a:len <= len(a:mask)
return a:mask
endif
return a:str[:a:len - 1 - len(a:mask)] . a:mask
endfunction
" Snips a:str and add a:mask if the length of a:str is more than a:len
function l9#snipMid(str, len, mask)
if a:len >= len(a:str)
return a:str
elseif a:len <= len(a:mask)
return a:mask
endif
let len_head = (a:len - len(a:mask)) / 2
let len_tail = a:len - len(a:mask) - len_head
return (len_head > 0 ? a:str[: len_head - 1] : '') . a:mask .
\ (len_tail > 0 ? a:str[-len_tail :] : '')
endfunction
"
function l9#hash224(str)
let a = 0x00000800 " shift 11 bit (if unsigned)
let b = 0x001fffff " extract 11 bit (if unsigned)
let nHash = 7
let hashes = repeat([0], nHash)
for i in range(len(a:str))
let iHash = i % nHash
let hashes[iHash] = hashes[iHash] * a + hashes[iHash] / b
let hashes[iHash] += char2nr(a:str[i])
endfor
return join(map(hashes, 'printf("%08x", v:val)'), '')
endfunction
" wildcard -> regexp
function l9#convertWildcardToRegexp(expr)
let re = escape(a:expr, '\')
for [pat, sub] in [ [ '*', '\\.\\*' ], [ '?', '\\.' ], [ '[', '\\[' ], ]
let re = substitute(re, pat, sub, 'g')
endfor
return '\V' . re
endfunction
" }}}1
"=============================================================================
" LINES {{{1
" Removes from the line matching with a:begin first to the line matching with
" a:end next and returns removed lines.
" If matching range is not found, returns []
function l9#removeLinesBetween(lines, begin, end)
for i in range(len(a:lines) - 1)
if a:lines[i] =~ a:begin
break
endif
endfor
for j in range(i + 1, len(a:lines) - 1)
if a:lines[j] =~ a:end
let g:l0 += [a:lines[i : j]]
return remove(a:lines, i, j)
endif
endfor
return []
endfunction
" }}}1
"=============================================================================
" PATH {{{1
" returns the path separator charactor.
function l9#getPathSeparator()
return (!&shellslash && (has('win32') || has('win64')) ? '\' : '/')
endfunction
" [ 'a', 'b/', '/c' ] -> 'a/b/c'
function l9#concatPaths(paths)
let result = ''
for p in a:paths
if empty(p)
continue
elseif empty(result)
let result = p
else
let result = substitute(result, '[/\\]$', '', '') . l9#getPathSeparator()
\ . substitute(p, '^[/\\]', '', '')
endif
endfor
return result
endfunction
" path: '/a/b/c/d', dir: '/a/b' => 'c/d'
function l9#modifyPathRelativeToDir(path, dir)
let pathFull = fnamemodify(a:path, ':p')
let dirFull = fnamemodify(a:dir, ':p')
if len(pathFull) < len(dirFull) || pathFull[:len(dirFull) - 1] !=# dirFull
return pathFull
endif
return pathFull[len(dirFull):]
endfunction
" }}}1
"=============================================================================
" FILE {{{1
" Almost same as readfile().
function l9#readFile(...)
let args = copy(a:000)
let args[0] = expand(args[0])
try
return call('readfile', args)
catch
endtry
return []
endfunction
" Almost same as writefile().
function l9#writeFile(...)
let args = copy(a:000)
let args[1] = expand(args[1])
let dir = fnamemodify(args[1], ':h')
try
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
return call('writefile', args)
catch
endtry
return -1 " -1 is error code.
endfunction
" }}}1
"=============================================================================
" BUFFER {{{1
" :wall/:wall! wrapper. Useful for writing readonly buffers.
function l9#writeAll()
try
silent update " NOTE: avoiding a problem with a buftype=acwrite buffer.
silent wall
catch /^Vim/ " E45, E505
if l9#inputHl('Question', v:exception . "\nWrite readonly files? (Y/N) : ", 'Y') ==? 'y'
redraw
:wall!
endif
endtry
endfunction
" Loads given files with :edit command
function l9#loadFilesToBuffers(files)
for file in filter(copy(a:files), '!bufloaded(v:val)')
execute 'edit ' . fnameescape(file)
if !exists('bufNrFirst')
let bufNrFirst = bufnr('%')
endif
endfor
if exists('bufNrFirst')
execute bufNrFirst . 'buffer'
endif
endfunction
" Deletes all buffers except given files with :bdelete command
function l9#deleteAllBuffersExcept(files)
let bufNrExcepts = map(copy(a:files), 'bufnr("^" . v:val . "$")')
for bufNr in filter(range(1, bufnr('$')), 'bufloaded(v:val)')
if count(bufNrExcepts, bufNr) == 0
execute bufNr . 'bdelete'
endif
endfor
endfunction
" }}}1
"=============================================================================
" WINDOW {{{1
" move current window to next tabpage.
function l9#shiftWinNextTabpage()
if tabpagenr('$') < 2
return
endif
let bufnr = bufnr('%')
tabnext
execute bufnr . 'sbuffer'
tabprevious
if winnr('$') > 1
close
tabnext
else
close " if tabpage is closed, next tabpage will become current
endif
endfunction
" move current window to previous tabpage.
function l9#shiftWinPrevTabpage()
if tabpagenr('$') < 2
return
endif
let bufnr = bufnr('%')
tabprevious
execute bufnr . 'sbuffer'
tabnext
close
tabprevious
endfunction
" move to a window containing specified buffer.
" returns 0 if the buffer is not found.
function l9#moveToBufferWindowInCurrentTabpage(bufNr)
if bufnr('%') == a:bufNr
return 1
elseif count(tabpagebuflist(), a:bufNr) == 0
return 0
endif
execute bufwinnr(a:bufNr) . 'wincmd w'
return 1
endfunction