diff options
| author | 2016-09-03 22:46:54 +0000 | |
|---|---|---|
| committer | 2016-09-03 22:46:54 +0000 | |
| commit | b5500b9ca0102f1ccaf32f0e77e96d0739aded9b (patch) | |
| tree | e1b7ebb5a0231f9e6d8d3f6f719582cebd64dc98 /gnu/llvm/utils/vim | |
| parent | clarify purpose of src/gnu/ directory. (diff) | |
| download | wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.tar.xz wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.zip | |
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/utils/vim')
| -rw-r--r-- | gnu/llvm/utils/vim/README | 22 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/ftdetect/llvm-lit.vim | 1 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/ftdetect/llvm.vim | 1 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/ftdetect/tablegen.vim | 1 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/ftplugin/llvm.vim | 12 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/ftplugin/tablegen.vim | 12 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/indent/llvm.vim | 72 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/syntax/llvm.vim | 120 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/syntax/tablegen.vim | 54 | ||||
| -rw-r--r-- | gnu/llvm/utils/vim/vimrc | 228 |
10 files changed, 523 insertions, 0 deletions
diff --git a/gnu/llvm/utils/vim/README b/gnu/llvm/utils/vim/README new file mode 100644 index 00000000000..8aea87924eb --- /dev/null +++ b/gnu/llvm/utils/vim/README @@ -0,0 +1,22 @@ +-*- llvm/utils/vim/README -*- + +This directory contains settings for the vim editor to work on llvm *.ll and +tablegen *.td files. It comes with filetype detection rules in the (ftdetect), +syntax highlighting (syntax), some minimal sensible default settings (ftplugin) +and indentation plugins (indent). + +To install copy all subdirectories to your $HOME/.vim or if you prefer create +symlinks to the files here. Do not copy the vimrc file here it is only meant as an inspiration and starting point for those working on llvm c++ code. + +Note: If you notice missing or incorrect syntax highlighting, please contact +<llvm-bugs [at] lists.llvm.org>; if you wish to provide a patch to improve the +functionality, it will be most appreciated. Thank you. + +If you find yourself working with LLVM Makefiles often, but you don't get syntax +highlighting (because the files have names such as Makefile.rules or +TEST.nightly.Makefile), add the following to your ~/.vimrc: + + " LLVM Makefile highlighting mode + augroup filetype + au! BufRead,BufNewFile *Makefile* set filetype=make + augroup END diff --git a/gnu/llvm/utils/vim/ftdetect/llvm-lit.vim b/gnu/llvm/utils/vim/ftdetect/llvm-lit.vim new file mode 100644 index 00000000000..fa651e1268c --- /dev/null +++ b/gnu/llvm/utils/vim/ftdetect/llvm-lit.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile lit.*cfg set filetype=python diff --git a/gnu/llvm/utils/vim/ftdetect/llvm.vim b/gnu/llvm/utils/vim/ftdetect/llvm.vim new file mode 100644 index 00000000000..161ceb2bd55 --- /dev/null +++ b/gnu/llvm/utils/vim/ftdetect/llvm.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.ll set filetype=llvm diff --git a/gnu/llvm/utils/vim/ftdetect/tablegen.vim b/gnu/llvm/utils/vim/ftdetect/tablegen.vim new file mode 100644 index 00000000000..95efa6efdd0 --- /dev/null +++ b/gnu/llvm/utils/vim/ftdetect/tablegen.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.td set filetype=tablegen diff --git a/gnu/llvm/utils/vim/ftplugin/llvm.vim b/gnu/llvm/utils/vim/ftplugin/llvm.vim new file mode 100644 index 00000000000..bdf49c92ff2 --- /dev/null +++ b/gnu/llvm/utils/vim/ftplugin/llvm.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: LLVM Assembly +" Maintainer: The LLVM team, http://llvm.org/ + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal softtabstop=2 shiftwidth=2 +setlocal expandtab +setlocal comments+=:; diff --git a/gnu/llvm/utils/vim/ftplugin/tablegen.vim b/gnu/llvm/utils/vim/ftplugin/tablegen.vim new file mode 100644 index 00000000000..cfae846c818 --- /dev/null +++ b/gnu/llvm/utils/vim/ftplugin/tablegen.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: LLVM TableGen +" Maintainer: The LLVM team, http://llvm.org/ + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal matchpairs+=<:> +setlocal softtabstop=2 shiftwidth=2 +setlocal expandtab diff --git a/gnu/llvm/utils/vim/indent/llvm.vim b/gnu/llvm/utils/vim/indent/llvm.vim new file mode 100644 index 00000000000..d1d8c83d118 --- /dev/null +++ b/gnu/llvm/utils/vim/indent/llvm.vim @@ -0,0 +1,72 @@ +" Vim indent file +" Language: llvm +" Maintainer: The LLVM team, http://llvm.org/ +" What this indent plugin currently does: +" - If no other rule matches copy indent from previous non-empty, +" non-commented line +" - On '}' align the same as the line containing the matching '{' +" - If previous line ends with ':' increase indentation +" - If the current line ends with ':' indent at the same level as the +" enclosing '{'/'}' block +" Stuff that would be nice to add: +" - Continue comments on next line +" - If there is an opening+unclosed parenthesis on previous line indent to that +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal shiftwidth=2 expandtab + +setlocal indentkeys=0{,0},<:>,!^F,o,O,e +setlocal indentexpr=GetLLVMIndent() + +if exists("*GetLLVMIndent") + finish +endif + +function! FindOpenBrace(lnum) + call cursor(a:lnum, 1) + return searchpair('{', '', '}', 'bW') +endfun + +function! GetLLVMIndent() + " On '}' align the same as the line containing the matching '{' + let thisline = getline(v:lnum) + if thisline =~ '^\s*}' + call cursor(v:lnum, 1) + silent normal % + let opening_lnum = line('.') + if opening_lnum != v:lnum + return indent(opening_lnum) + endif + endif + + " Indent labels the same as the current opening block + if thisline =~ ':\s*$' + let blockbegin = FindOpenBrace(v:lnum) + if blockbegin > 0 + return indent(blockbegin) + endif + endif + + " Find a non-blank not-completely commented line above the current line. + let prev_lnum = prevnonblank(v:lnum - 1) + while prev_lnum > 0 && synIDattr(synID(prev_lnum, indent(prev_lnum)+1, 0), "name") =? "string\|comment" + let prev_lnum = prevnonblank(prev_lnum-1) + endwhile + " Hit the start of the file, use zero indent. + if prev_lnum == 0 + return 0 + endif + + let ind = indent(prev_lnum) + let prevline = getline(prev_lnum) + + " Add a 'shiftwidth' after lines that start a block or labels + if prevline =~ '{\s*$' || prevline =~ ':\s*$' + let ind = ind + &shiftwidth + endif + + return ind +endfunction diff --git a/gnu/llvm/utils/vim/syntax/llvm.vim b/gnu/llvm/utils/vim/syntax/llvm.vim new file mode 100644 index 00000000000..e623a7edd7f --- /dev/null +++ b/gnu/llvm/utils/vim/syntax/llvm.vim @@ -0,0 +1,120 @@ +" Vim syntax file +" Language: llvm +" Maintainer: The LLVM team, http://llvm.org/ +" Version: $Revision: 1.1.1.1 $ + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn case match + +" Types. +" Types also include struct, array, vector, etc. but these don't +" benefit as much from having dedicated highlighting rules. +syn keyword llvmType void half float double x86_fp80 fp128 ppc_fp128 +syn keyword llvmType label metadata x86_mmx +syn keyword llvmType type label opaque token +syn match llvmType /\<i\d\+\>/ + +" Instructions. +" The true and false tokens can be used for comparison opcodes, but it's +" much more common for these tokens to be used for boolean constants. +syn keyword llvmStatement add addrspacecast alloca and arcp ashr atomicrmw +syn keyword llvmStatement bitcast br call cmpxchg eq exact extractelement +syn keyword llvmStatement extractvalue fadd fast fcmp fdiv fence fmul fpext +syn keyword llvmStatement fptosi fptoui fptrunc free frem fsub getelementptr +syn keyword llvmStatement icmp inbounds indirectbr insertelement insertvalue +syn keyword llvmStatement inttoptr invoke landingpad load lshr malloc max min +syn keyword llvmStatement mul nand ne ninf nnan nsw nsz nuw oeq oge ogt ole +syn keyword llvmStatement olt one or ord phi ptrtoint resume ret sdiv select +syn keyword llvmStatement sext sge sgt shl shufflevector sitofp sle slt srem +syn keyword llvmStatement store sub switch trunc udiv ueq uge ugt uitofp ule ult +syn keyword llvmStatement umax umin une uno unreachable unwind urem va_arg +syn keyword llvmStatement xchg xor zext + +" Keywords. +syn keyword llvmKeyword acq_rel acquire sanitize_address addrspace alias align +syn keyword llvmKeyword alignstack alwaysinline appending arm_aapcs_vfpcc +syn keyword llvmKeyword arm_aapcscc arm_apcscc asm atomic available_externally +syn keyword llvmKeyword blockaddress byval c catch cc ccc cleanup coldcc common +syn keyword llvmKeyword constant datalayout declare default define deplibs +syn keyword llvmKeyword distinct dllexport dllimport except extern_weak external +syn keyword llvmKeyword externally_initialized fastcc filter gc global hhvmcc +syn keyword llvmKeyword hhvm_ccc hidden initialexec inlinehint inreg +syn keyword llvmKeyword intel_ocl_bicc inteldialect internal linkonce +syn keyword llvmKeyword linkonce_odr localdynamic localexec minsize module +syn keyword llvmKeyword monotonic msp430_intrcc musttail naked nest +syn keyword llvmKeyword noalias nocapture noimplicitfloat noinline nonlazybind +syn keyword llvmKeyword noredzone noreturn nounwind optnone optsize personality +syn keyword llvmKeyword private protected ptx_device ptx_kernel readnone +syn keyword llvmKeyword readonly release returns_twice sanitize_thread +syn keyword llvmKeyword sanitize_memory section seq_cst sideeffect signext +syn keyword llvmKeyword singlethread spir_func spir_kernel sret ssp sspreq +syn keyword llvmKeyword sspstrong tail target thread_local to triple +syn keyword llvmKeyword unnamed_addr unordered uwtable volatile weak weak_odr +syn keyword llvmKeyword x86_fastcallcc x86_stdcallcc x86_thiscallcc +syn keyword llvmKeyword x86_64_sysvcc x86_64_win64cc zeroext uselistorder +syn keyword llvmKeyword uselistorder_bb musttail + +" Obsolete keywords. +syn keyword llvmError getresult begin end + +" Misc syntax. +syn match llvmNoName /[%@!]\d\+\>/ +syn match llvmNumber /-\?\<\d\+\>/ +syn match llvmFloat /-\?\<\d\+\.\d*\(e[+-]\d\+\)\?\>/ +syn match llvmFloat /\<0x\x\+\>/ +syn keyword llvmBoolean true false +syn keyword llvmConstant zeroinitializer undef null +syn match llvmComment /;.*$/ +syn region llvmString start=/"/ skip=/\\"/ end=/"/ +syn match llvmLabel /[-a-zA-Z$._][-a-zA-Z$._0-9]*:/ +syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/ + +" Named metadata and specialized metadata keywords. +syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*$/ +syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/ +syn match llvmType /!\zs\a\+\ze\s*(/ +syn match llvmConstant /\<DW_TAG_[a-z_]\+\>/ +syn match llvmConstant /\<DW_ATE_[a-zA-Z_]\+\>/ +syn match llvmConstant /\<DW_OP_[a-zA-Z0-9_]\+\>/ +syn match llvmConstant /\<DW_LANG_[a-zA-Z0-9_]\+\>/ +syn match llvmConstant /\<DW_VIRTUALITY_[a-z_]\+\>/ +syn match llvmConstant /\<DIFlag[A-Za-z]\+\>/ + +" Syntax-highlight lit test commands and bug numbers. +syn match llvmSpecialComment /;\s*PR\d*\s*$/ +syn match llvmSpecialComment /;\s*REQUIRES:.*$/ +syn match llvmSpecialComment /;\s*RUN:.*$/ +syn match llvmSpecialComment /;\s*XFAIL:.*$/ + +if version >= 508 || !exists("did_c_syn_inits") + if version < 508 + let did_c_syn_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink llvmType Type + HiLink llvmStatement Statement + HiLink llvmNumber Number + HiLink llvmComment Comment + HiLink llvmString String + HiLink llvmLabel Label + HiLink llvmKeyword Keyword + HiLink llvmBoolean Boolean + HiLink llvmFloat Float + HiLink llvmNoName Identifier + HiLink llvmConstant Constant + HiLink llvmSpecialComment SpecialComment + HiLink llvmError Error + HiLink llvmIdentifier Identifier + + delcommand HiLink +endif + +let b:current_syntax = "llvm" diff --git a/gnu/llvm/utils/vim/syntax/tablegen.vim b/gnu/llvm/utils/vim/syntax/tablegen.vim new file mode 100644 index 00000000000..020578df04f --- /dev/null +++ b/gnu/llvm/utils/vim/syntax/tablegen.vim @@ -0,0 +1,54 @@ +" Vim syntax file +" Language: TableGen +" Maintainer: The LLVM team, http://llvm.org/ +" Version: $Revision: 1.1.1.1 $ + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" May be changed if you have a really slow machine +syntax sync minlines=100 + +syn case match + +syn keyword tgKeyword def let in code dag field include defm foreach +syn keyword tgType class int string list bit bits multiclass + +syn match tgNumber /\<\d\+\>/ +syn match tgNumber /\<\d\+\.\d*\>/ +syn match tgNumber /\<0b[01]\+\>/ +syn match tgNumber /\<0x[0-9a-fA-F]\+\>/ +syn region tgString start=/"/ skip=/\\"/ end=/"/ oneline + +syn region tgCode start=/\[{/ end=/}\]/ + +syn keyword tgTodo contained TODO FIXME +syn match tgComment /\/\/.*$/ contains=tgTodo +" Handle correctly imbricated comment +syn region tgComment2 matchgroup=tgComment2 start=+/\*+ end=+\*/+ contains=tgTodo,tgComment2 + +if version >= 508 || !exists("did_c_syn_inits") + if version < 508 + let did_c_syn_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink tgKeyword Statement + HiLink tgType Type + HiLink tgNumber Number + HiLink tgComment Comment + HiLink tgComment2 Comment + HiLink tgString String + " May find a better Hilight group... + HiLink tgCode Special + HiLink tgTodo Todo + + delcommand HiLink +endif + +let b:current_syntax = "tablegen" diff --git a/gnu/llvm/utils/vim/vimrc b/gnu/llvm/utils/vim/vimrc new file mode 100644 index 00000000000..49f53bc9b83 --- /dev/null +++ b/gnu/llvm/utils/vim/vimrc @@ -0,0 +1,228 @@ +" LLVM coding guidelines conformance for VIM +" $Revision: 1.1.1.1 $ +" +" Maintainer: The LLVM Team, http://llvm.org +" WARNING: Read before you source in all these commands and macros! Some +" of them may change VIM behavior that you depend on. +" +" You can run VIM with these settings without changing your current setup with: +" $ vim -u /path/to/llvm/utils/vim/vimrc + +" It's VIM, not VI +set nocompatible + +" A tab produces a 2-space indentation +set softtabstop=2 +set shiftwidth=2 +set expandtab + +" Highlight trailing whitespace and lines longer than 80 columns. +highlight LongLine ctermbg=DarkYellow guibg=DarkYellow +highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow +if v:version >= 702 + " Lines longer than 80 columns. + au BufWinEnter * let w:m0=matchadd('LongLine', '\%>80v.\+', -1) + + " Whitespace at the end of a line. This little dance suppresses + " whitespace that has just been typed. + au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1) + au InsertEnter * call matchdelete(w:m1) + au InsertEnter * let w:m2=matchadd('WhitespaceEOL', '\s\+\%#\@<!$', -1) + au InsertLeave * call matchdelete(w:m2) + au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1) +else + au BufRead,BufNewFile * syntax match LongLine /\%>80v.\+/ + au InsertEnter * syntax match WhitespaceEOL /\s\+\%#\@<!$/ + au InsertLeave * syntax match WhitespaceEOL /\s\+$/ +endif + +" Enable filetype detection +filetype on + +" Optional +" C/C++ programming helpers +augroup csrc + au! + autocmd FileType * set nocindent smartindent + autocmd FileType c,cpp set cindent +augroup END +" Set a few indentation parameters. See the VIM help for cinoptions-values for +" details. These aren't absolute rules; they're just an approximation of +" common style in LLVM source. +set cinoptions=:0,g0,(0,Ws,l1 +" Add and delete spaces in increments of `shiftwidth' for tabs +set smarttab + +" Highlight syntax in programming languages +syntax on + +" LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile, +" so it's important to categorize them as such. +augroup filetype + au! BufRead,BufNewFile *Makefile* set filetype=make +augroup END + +" In Makefiles, don't expand tabs to spaces, since we need the actual tabs +autocmd FileType make set noexpandtab + +" Useful macros for cleaning up code to conform to LLVM coding guidelines + +" Delete trailing whitespace and tabs at the end of each line +command! DeleteTrailingWs :%s/\s\+$// + +" Convert all tab characters to two spaces +command! Untab :%s/\t/ /g + +" Enable syntax highlighting for LLVM files. To use, copy +" utils/vim/llvm.vim to ~/.vim/syntax . +augroup filetype + au! BufRead,BufNewFile *.ll set filetype=llvm +augroup END + +" Enable syntax highlighting for tablegen files. To use, copy +" utils/vim/tablegen.vim to ~/.vim/syntax . +augroup filetype + au! BufRead,BufNewFile *.td set filetype=tablegen +augroup END + +" Enable syntax highlighting for reStructuredText files. To use, copy +" rest.vim (http://www.vim.org/scripts/script.php?script_id=973) +" to ~/.vim/syntax . +augroup filetype + au! BufRead,BufNewFile *.rst set filetype=rest +augroup END + +" Additional vim features to optionally uncomment. +"set showcmd +"set showmatch +"set showmode +"set incsearch +"set ruler + +" Clang code-completion support. This is somewhat experimental! + +" A path to a clang executable. +let g:clang_path = "clang++" + +" A list of options to add to the clang commandline, for example to add +" include paths, predefined macros, and language options. +let g:clang_opts = [ + \ "-x","c++", + \ "-D__STDC_LIMIT_MACROS=1","-D__STDC_CONSTANT_MACROS=1", + \ "-Iinclude" ] + +function! ClangComplete(findstart, base) + if a:findstart == 1 + " In findstart mode, look for the beginning of the current identifier. + let l:line = getline('.') + let l:start = col('.') - 1 + while l:start > 0 && l:line[l:start - 1] =~ '\i' + let l:start -= 1 + endwhile + return l:start + endif + + " Get the current line and column numbers. + let l:l = line('.') + let l:c = col('.') + + " Build a clang commandline to do code completion on stdin. + let l:the_command = shellescape(g:clang_path) . + \ " -cc1 -code-completion-at=-:" . l:l . ":" . l:c + for l:opt in g:clang_opts + let l:the_command .= " " . shellescape(l:opt) + endfor + + " Copy the contents of the current buffer into a string for stdin. + " TODO: The extra space at the end is for working around clang's + " apparent inability to do code completion at the very end of the + " input. + " TODO: Is it better to feed clang the entire file instead of truncating + " it at the current line? + let l:process_input = join(getline(1, l:l), "\n") . " " + + " Run it! + let l:input_lines = split(system(l:the_command, l:process_input), "\n") + + " Parse the output. + for l:input_line in l:input_lines + " Vim's substring operator is annoyingly inconsistent with python's. + if l:input_line[:11] == 'COMPLETION: ' + let l:value = l:input_line[12:] + + " Chop off anything after " : ", if present, and move it to the menu. + let l:menu = "" + let l:spacecolonspace = stridx(l:value, " : ") + if l:spacecolonspace != -1 + let l:menu = l:value[l:spacecolonspace+3:] + let l:value = l:value[:l:spacecolonspace-1] + endif + + " Chop off " (Hidden)", if present, and move it to the menu. + let l:hidden = stridx(l:value, " (Hidden)") + if l:hidden != -1 + let l:menu .= " (Hidden)" + let l:value = l:value[:l:hidden-1] + endif + + " Handle "Pattern". TODO: Make clang less weird. + if l:value == "Pattern" + let l:value = l:menu + let l:pound = stridx(l:value, "#") + " Truncate the at the first [#, <#, or {#. + if l:pound != -1 + let l:value = l:value[:l:pound-2] + endif + endif + + " Filter out results which don't match the base string. + if a:base != "" + if l:value[:strlen(a:base)-1] != a:base + continue + end + endif + + " TODO: Don't dump the raw input into info, though it's nice for now. + " TODO: The kind string? + let l:item = { + \ "word": l:value, + \ "menu": l:menu, + \ "info": l:input_line, + \ "dup": 1 } + + " Report a result. + if complete_add(l:item) == 0 + return [] + endif + if complete_check() + return [] + endif + + elseif l:input_line[:9] == "OVERLOAD: " + " An overload candidate. Use a crazy hack to get vim to + " display the results. TODO: Make this better. + let l:value = l:input_line[10:] + let l:item = { + \ "word": " ", + \ "menu": l:value, + \ "info": l:input_line, + \ "dup": 1} + + " Report a result. + if complete_add(l:item) == 0 + return [] + endif + if complete_check() + return [] + endif + + endif + endfor + + + return [] +endfunction ClangComplete + +" This to enables the somewhat-experimental clang-based +" autocompletion support. +set omnifunc=ClangComplete |
